I made a openGL rect window inside a MFC dialog application.
But the glClearColor doesn´t work
I used this code in my drawOpenGL class:
void COpenGL::OnPaint()
{
CPaintDC dc(this); // device context for painting
redraw();
}
void COpenGL::redraw()
{
HDC hdc = ::GetDC(m_hWnd);
HGLRC hglrc;
// TODO: Add your message handler code here
glClearColor(0.5, 0.0, 0.5, 1.0);
//glColor3f(1, 1, 1);
if (hglrc = wglCreateContext(hdc))
{
// try to make it the thread's current rendering context
if(wglMakeCurrent(hdc, hglrc))
{
glClear(GL_COLOR_BUFFER_BIT);
std::vector<std::vector<std::vector<int> > > MyVector = m_PunktDaten.getVector();
// The following commands should induce OpenGL to create round points and
// antialias points and lines. (This is implementation dependent unfortunately, and
// may slow down rendering considerably.)
// You may comment these out if you wish.
glEnable(GL_POINT_SMOOTH);
glEnable(GL_LINE_SMOOTH);
glHint(GL_POINT_SMOOTH_HINT, GL_NICEST); // Make round points, not square points
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); // Antialias the lines
for (unsigned int i = 0; i < MyVector.size(); i++) // loops through AllObjects
{
// DRAW LINES
glLineWidth(2.0);
glBegin(GL_LINE_STRIP);
for (unsigned int j = 0; j < MyVector[i].size(); j++) // loops through Points
{
glColor3f (1.0, 0.0, 0.0);
GLfloat iObjx = (MyVector[i][j][1] /(float)(m_WindowSize.right - m_WindowSize.left) )*2-1.0;
GLfloat iObjy = -((MyVector[i][j][2]/(float)(m_WindowSize.bottom -m_WindowSize.top ) )*2-1.0);
//TRACE("X = %i ",MyVector[i][j][1]); // Print Points value X
//TRACE("Y = %i
",MyVector[i][j][2]); // Print Points value X
glVertex2f(iObjx,iObjy);
}
glEnd();
// DRAW POINTS
glPointSize(4.0); // Point Size
glBegin(GL_POINTS);
for (unsigned int j = 0; j < MyVector[i].size(); j++) // loops through Points
{
GLfloat iObjx = (MyVector[i][j][1] /(float)(m_WindowSize.right - m_WindowSize.left) )*2-1.0;
GLfloat iObjy = -((MyVector[i][j][2]/(float)(m_WindowSize.bottom -m_WindowSize.top ) )*2-1.0);
if (MyVector[i][j][0] == 0)glColor3f (0.0, 1.0, 0.0); // Normal Point color
if (MyVector[i][j][0] == 1)glColor3f (0.0, 0.0, 1.0); // Select Point color
glVertex2f(iObjx,iObjy);
}
glEnd();
}
//if (mode == GL_RENDER){
SwapBuffers(hdc);
//}
}
}
Any ideas what i did wrong ?