codeblocks - Cannot seem to get GLFW/OpenGL Depth Testing working -


i cannot depth testing working glfw using codeblocks in project, using default template provided codeblocks when start new project, below.

any appreciated know must doing wrong haven't been able find it.

#include <gl/glfw.h>  int main() { int     width, height; int     frame = 0; bool    running = true;  glfwinit();  if( !glfwopenwindow( 512, 512, 0, 0, 0, 0, 0, 0, glfw_window ) ) {     glfwterminate();     return 0; }  glfwsetwindowtitle("glfw application");  glenable(gl_depth_test);  while(running) {     frame++;      glfwgetwindowsize( &width, &height );     height = height > 0 ? height : 1;      glviewport( 0, 0, width, height );      glclearcolor( 0.0f, 0.0f, 0.0f, 0.0f );     glclear( gl_color_buffer_bit | gl_depth_buffer_bit);      glmatrixmode( gl_projection );     glloadidentity();     gluperspective( 65.0f, (glfloat)width/(glfloat)height, 1.0f, 100.0f );      // draw rotating garbage     glmatrixmode( gl_modelview );     glloadidentity();     glulookat(0.0f, -10.0f, 0.0f,             0.0f, 0.0f, 0.0f,             0.0f, 0.0f, 1.0f );      //gltranslatef( 1.0f, 1.0f, 0.0f );     glrotatef(frame, 0.25f, 1.0f, 0.75f);     glbegin( gl_triangles );       glcolor3f(0.1f, 0.0f, 0.0f );       glvertex3f(0.0f, 3.0f, -4.0f);       glcolor3f(0.0f, 1.0f, 0.0f );       glvertex3f(3.0f, -2.0f, -4.0f);       glcolor3f(0.0f, 0.0f, 1.0f );       glvertex3f(-3.0f, -2.0f, -4.0f);     glend();     glbegin( gl_triangles );       glcolor3f(0.0f, 0.1f, 0.0f );       glvertex3f(0.0f, 3.0f, -3.0f);       glcolor3f(0.0f, 0.0f, 1.0f );       glvertex3f(3.0f, -2.0f, -2.0f);       glcolor3f(1.0f, 0.0f, 0.0f );       glvertex3f(-3.0f, -2.0f, 2.0f);     glend();     glfwswapbuffers();      // exit if esc pressed or window closed     running = !glfwgetkey(glfw_key_esc) && glfwgetwindowparam( glfw_opened); }  glfwterminate();  return 0; 

}

from glfw2 documentation (emphasis mine):

int glfwopenwindow     (     int width, int height,     int redbits, int greenbits, int bluebits,     int alphabits,     int depthbits,     int stencilbits,     int mode     ) 

depthbits: number of bits use depth buffer (0 means no depth buffer).

and code:

glfwopenwindow( 512, 512, 0, 0, 0, 0, 0, 0, glfw_window )                                       ^ no depth bits 

you can't (usefully) use depth buffer without depth bits.


Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -