Hi all
I have made small program using OpenGL under Linux using GTKGLarea.
D works fine, but when I try to write 3D, then it doesn’t show up at all.
Here is code:
gint glarea_init (GtkWidget* widget) {
if (gtk_gl_area_make_current (GTK_GL_AREA(widget))) {
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClearDepth(1.0);
glDepthFunc(GL_LESS);
glShadeModel(GL_SMOOTH); glColorMaterial(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE);
glEnable(GL_COLOR_MATERIAL);
glEnable(GL_DEPTH_TEST);
}
return true
}
gint glarea_reshape (GtkWidget* widget, GdkEventConfigure* event) {
int w = widget->allocation.width;
int h = widget->allocation.height;
if (gtk_gl_area_make_current (GTK_GL_AREA(widget))) {
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective( 55.0f, (GLfloat)w/(GLfloat)h, 0.1f, 100.0f);
glMatrixMode(GL_MODELVIEW);
}
return (TRUE);
}
gint glarea_draw (GtkWidget* widget, GdkEventExpose* event) {
int w = widget->allocation.width;
int h = widget->allocation.height;
if (event->count > 0) {
return(TRUE);
}
if (gtk_gl_area_make_current(GTK_GL_AREA(widget))) {
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glBegin(GL_LINES);
glVertex3f( 0.0, 0.0, 500.0);
glVertex3f(0.0,0.0, -500.0);
glEnd();
gtk_gl_area_swapbuffers (GTK_GL_AREA(widget));
}
return (TRUE);
}
That’s about it.
Any sugestions?
Thanx