First the code:
// from the create method
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClearDepth(1.0f);
// TODO: Add your specialized creation code here
static PIXELFORMATDESCRIPTOR pfd = {
sizeof (PIXELFORMATDESCRIPTOR), // strcut size
1, // Version number
PFD_DRAW_TO_WINDOW | // Flags, draw to a window,
PFD_SUPPORT_OPENGL, // use OpenGL
PFD_TYPE_RGBA, // RGBA pixel values
24, // 24-bit color
0, 0, 0, // RGB bits & shift sizes.
0, 0, 0, // Don’t care about them
0, 0, // No alpha buffer info
0, 0, 0, 0, 0, // No accumulation buffer
32, // 32-bit depth buffer
0, // No stencil buffer
0, // No auxiliary buffers
PFD_MAIN_PLANE, // Layer type
0, // Reserved (must be 0)
0, // No layer mask
0, // No visible mask
0 // No damage mask
};
int nMyPixelFormatID;
HGLRC hRC;
CDC *pDC = GetDC();
nMyPixelFormatID = ChoosePixelFormat(pDC->m_hDC, &pfd );
// catch errors here.
if(pfd.dwFlags & PFD_NEED_PALETTE)
{
int what = 1;
}
// If nMyPixelFormat is zero, then there's
// something wrong... most likely the window's
// style bits are incorrect (in CreateWindow() )
// or OpenGl isn't installed on this machine
SetPixelFormat( pDC->m_hDC, nMyPixelFormatID, &pfd );
hRC = wglCreateContext( pDC->m_hDC );
ReleaseDC(pDC );
m_hrc = hRC;
glEnable(GL_POLYGON_SMOOTH);
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
// From the Draw routine
BOOL bResult = wglMakeCurrent (pDC->m_hDC, m_hrc);
if (!bResult)
{
TRACE("wglMakeCurrent Failed %x
", GetLastError() ) ;
}
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
glFrustum(5,5,5,5,5,100);
// move the viewpoint
glTranslatef( (float)m_x, (float)m_y, (float)m_z );
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_TRIANGLE_STRIP );
{
// front face
glColor3f(1.0f, 0.0f, 0.0f);// blue
Vector2Vertex(cubelist[3]);
Vector2Vertex(cubelist[0]);
Vector2Vertex(cubelist[2]);
Vector2Vertex(cubelist[1]);
// bottom face
glColor3f(1.0f, 1.0f, 0.0f);
Vector2Vertex(cubelist[0]);
Vector2Vertex(cubelist[4]);
Vector2Vertex(cubelist[1]);
Vector2Vertex(cubelist[5]);
//right face
glColor3f(0.0f, 1.0f, 0.0f);
Vector2Vertex(cubelist[2]);
Vector2Vertex(cubelist[1]);
Vector2Vertex(cubelist[6]);
Vector2Vertex(cubelist[5]);
}// glBegin
glEnd();
Now the synopsis:
I am trying to test culling with half a cube, one plane in each direction and culling makes the lines look right on the corners where planes intersect. I haven’t succeeded in getting culling to do anything.
I have six keys that move my x, y, and z on my viewpoint so I see sides and such.
The ideal solution would define an entire cube each face with its own color and from above, below, left, or right, the cube would look correct.
All suggestions welcome,
cam