PDA

View Full Version : output form is empty need help



sumanlama
08-17-2013, 10:57 AM
I am new to open Gl so i downloaded a C# opengl code and tried to change it by deleting all the draw triangles codes and changed it to draw line codes. The output remains empty (black screen) after compiling the code.
I am trying to plot EEG signals with open gl but I cannot even plot a simple line. Please help.
Can someone tell me what I am doing wrong?
Any help is appreciated.



The code is:

public Form1()
{
InitializeComponent();

int height = simpleOpenGlControl1.Height;
int width = simpleOpenGlControl1.Width;

simpleOpenGlControl1.InitializeContexts();
Gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);

Gl.glMatrixMode(Gl.GL_PROJECTION);
Gl.glLoadIdentity();
Glu.gluPerspective(45.0f, (double)width / (double)height, 0.01f, 5000.0f);
}


private void simpleOpenGlControl1_Paint(object sender, PaintEventArgs e) // OnPaint event
{


Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT); //clear buffers to preset values
Gl.glMatrixMode(Gl.GL_MODELVIEW);
Gl.glLoadIdentity(); // load the identity matrix
Gl.glBegin(Gl.GL_LINE);
Gl.glVertex3f(0.0f, 0.0f,0.0f);
Gl.glVertex3f(5.0f, 5.0f, 0.0f);
Gl.glEnd();
}

carsten neumann
08-17-2013, 02:21 PM
You are probably drawing outside the view furstum. If your eye position is in the origin and with your near/far values you will only see objects that have a world space z coordinate in [-0.01, -5000]. Try drawing your line at z = -10 or so.