c - opengl white window - Visual Studio 2010 -
i opengl beginner. set dlls, library, header but, error occurred. development environment win7 ( 64bit ).
for reference - dlls : c:\windows\system32, c:\windows\syswow64 // glu32.dll, glut.dll, glut32.dll, opengl32.dll
libs : c:\program files (x86)\microsoft sdks\windows\v7.0a\lib, c:\program files (x86)\microsoft visual studio 10.0\vc\lib // glut.lib, glut32.lib
header : c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gl, c:\program files (x86)\microsoft visual studio 10.0\vc\include\gl // gl.h, glaux.h, glu.h, glut.h
#include <windows.h> #include <gl/glut.h> void dodisplay ( void ) { glclearcolor ( 0.0f, 0.0f, 1.0f, 1.0f ); glclear( gl_color_buffer_bit ); glbegin ( gl_triangles ); glvertex2f ( 0.0, 0.5 ); glvertex2f ( -0.5, -0.5 ); glvertex2f ( 0.5, -0.5 ); glend (); glflush (); } int main ( int argc, char ** argv ) { glutinit ( &argc, argv ); glutinitdisplaymode ( glut_rgb | glut_double ); glutinitwindowsize ( 300, 300 ); glutinitwindowposition ( 0, 0 ); glutcreatewindow ( "opengl" ); glutdisplayfunc ( dodisplay ); glutmainloop (); return 0; } edit :
white window : http://i.stack.imgur.com/9gjon.jpg
this code output white triangle.
win32 project -> console project.
problem not solved.. sorry.
- you're using immediate mode. have
glend()noglbegin() - as petert pointed out, have no call
glutinit - if paths specified way have printed, you'll run problem. have both forward , backslashes, @ least in experience ruins path.
- you're not clearing screen specific color, nor setting vertices specific color. may case of drawing polar bear in snow storm.
check out
glclear(gl_color_buffer_bit | gl_depth_buffer_bit); and
glclearcolor(r, g, b, a); - as drew mcgowen pointed out, you're not specifying transformation or projection matrices.
- i strongly recommend looking tutorial on opengl explanation of things need draw triangle , why. lighthouse3d, swiftless, ogldev - there many should show basics.
- one more point: you're trying learn code has been deprecated ~7 years. should learn new programmable pipeline instead of fixed function pipeline because faster , gives more control.
Comments
Post a Comment