|
Post by bluatigro on Jan 8, 2020 6:29:25 GMT -5
fount on www : www.opengl.org/archives/resources/code/samples/redbook/they are in c first try at hello.gb error : i get a empty black screen ''bluatigro 8 jan 2020 ''hello.gb ''based on : ''https://www.opengl.org/archives/resources/code/samples/redbook/
glclear( GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT ) glortho( 0.0 , 1.0 , 0.0 , 1.0 , -1.0 , 1.0 ) glbegin( GL_POLYGON ) glvertex3f( 0.25 , 0.25 , 0.0 ) glvertex3f( 0.75 , 0.25 , 0.0 ) glvertex3f( 0.75 , 0.75 , 0.0 ) glvertex3f( 0.25 , 0.75 , 0.0 ) glend()
glflush()
swapbuffers()
|
|
|
Post by matthew on Jan 8, 2020 10:17:36 GMT -5
You need to include some code at the beginning of your program to create a 2D screen (projection).
glMatrixMode(GL_PROJECTION) glLoadIdentity() glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0) glDisable(GL_DEPTH_TEST) glDrawBuffer(GL_FRONT) glMatrixMode (GL_MODELVIEW) glLoadIdentity() glClearColor(0.0, 0.0, 0.0, 0.0) glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT)
glBegin(GL_POLYGON) glVertex3f(0.25 ,0.25 ,0.0) glVertex3f(0.75 ,0.25 ,0.0) glVertex3f(0.75 ,0.75 ,0.0) glVertex3f(0.25 ,0.75 ,0.0) glEnd()
glFlush()
|
|