Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Lurking

Points and Shapes not displaying?

This topic is 5935 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am writing my first 3d engine w/ OpenGL. I finished writing my MFC code to support opengl and it runs. Now i am trying to put shapes in the window i made and it doesn''t seem to work. I cant see anything. I am typing everything write according to tutorials at NeHe. Heres some of my code: //DrawGL int CWindow: rawGL(){ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); glTranslatef(-1.5f, 0.0f, -6.0f); glBegin(GL_TRIANGLES); glColor3f(1.0f,0.0f,0.0f); glVertex3f(0.0f,1.0f,0.0f); glColor3f(0.0f,1.0f,0.0f); glVertex3f(-1.0f,0.0f,0.0f); glColor3f(0.0f,0.0f,1.0f); glVertex3f(1.0f,0.0f,0.0f); glEnd(); glTranslatef(3.0f,0.0f,0.0f); glBegin(GL_QUADS); glColor3f(1.0f,0.0f,0.0f); glVertex3f(-1.0f,1.0f,0.0f); glColor3f(0.0f,1.0f,0.0f); glVertex3f(1.0f,1.0f,0.0f); glColor3f(0.0f,0.0f,1.0f); glVertex3f(1.0f,-1.0f,0.0f); glColor3f(1.0f,1.0f,1.0f); glVertex3f(-1.0f,-1.0f,0.0f); glEnd(); return TRUE; } //InitGL int CWindow::InitGL(){ glShadeModel(GL_SMOOTH); glClearColor(0.0f,0.0f,0.0f,0.0f); glClearDepth(1.0f); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); return TRUE; } //Paint afx_msg void CWindow::OnPaint(void){ CPaintDC dc(this); for(int count=1;count <= 100;count++) CWindow: rawGL(); SwapBuffers(mDC); } //Create afx_msg int CWindow::OnCreate(LPCREATESTRUCT lpCreateStruct){ mDC = ::GetDC( m_hWnd ); if(!SetPixelformat(mDC)){ ::MessageBox(::GetFocus(),"ERROR: Set Format Failed","Error",MB_OK); return -1; } else{ mRC = wglCreateContext(mDC); int i = wglMakeCurrent(mDC,mRC); InitGL(); return 0; } } that should give you an idea on what is going on. If you can help me out that would be great!

Share this post


Link to post
Share on other sites
Advertisement
first, when you post code it is easier to see if you use
[ source ] and [ /source ]

  
like this


secondly check that all the API functions are returning nice results. Check the wglCreateContext() and wglMakeCurrent() calls especially.

------------------------------
Baldur K

Share this post


Link to post
Share on other sites
i get no error messages when i test the wgl func in the OnCreate func. So what could be making it from not displaying the triangle and the square?

Share this post


Link to post
Share on other sites
Check all your API functions, I pasted the drawing code (minus the MFC stuff) into my own code and it was fine. Make sure texturing is not enabled.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!