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!