barraq
Messages postés
89
Date d'inscription
mercredi 25 juin 2003
Statut
Membre
Dernière intervention
14 septembre 2007
8 avril 2005 à 11:12
ben pourtant voila comment je l'utilise :
bool WinGL::InitializeOpenGL ()
{
// Try to get the Device Context
if ( !(_hDC = GetDC(_OpenGLHwnd)) )
{
KillGLWindow(); // Reset the display
MessageBox(NULL,"Can't Create A GL Device Context.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return false;
}
// Are we able to set our pixel format/information
if ( !SetupPixelFormat() )
PostQuitMessage (0);
// Try to get the Rendering Context
if ( !(_hRC = wglCreateContext(_hDC)) )
{
KillGLWindow(); // Reset the display
MessageBox(NULL,"Can't Create A GL Rendering Context.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return false;
}
// Try to activate the Rendering Context
if( !wglMakeCurrent(_hDC,_hRC) )
{
KillGLWindow(); // Reset the display
MessageBox(NULL,"Can't Activate
The GL Rendering Context.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return false;
}
// Enable the multitexturing
_Terrain->EnableMultiTexturing();
_OpenGLHwnd.Show();
// Show the window
SetForegroundWindow(_OpenGLHwnd); // Slightly higher priority
ReSizeGLScene();
// Set up our perspective GL screen ( translations
and viewport )
return true; // Return a success!
}
et en suite dans SetPixelFormat :
bool WinGL::SetupPixelFormat()
{
int PixelFormat;
// Define the PixelFormatDescriptor
static PIXELFORMATDESCRIPTOR pfd= // pfd tells windows how we want things to be
{
sizeof(PIXELFORMATDESCRIPTOR), // Size of this pixel format descriptor
1,
// Version number
PFD_DRAW_TO_WINDOW |
// Format must support window
PFD_SUPPORT_OPENGL |
// Format must support OpenGL
PFD_DOUBLEBUFFER,
// Must support double buffering
PFD_TYPE_RGBA,
// Request an RGBA format
BITS,
// Select our color depth
0, 0, 0, 0, 0,
0,
// Color bits ignored
0,
// No alpha buffer
0,
// Shift bit ignored
0,
// No accumulation buffer
0, 0, 0,
0,
//
Accumulation bits ignored
16,
// 16Bit Z-Buffer (depth buffer)
0,
// No stencil buffer
0,
// No auxiliary buffer
PFD_MAIN_PLANE,
// Main drawing layer
0,
// Reserved
0, 0,
0
// Layer masks ignored
};
// Did windows find a matching pixel format?
if ( !(PixelFormat = ChoosePixelFormat(_hDC,&pfd)) )
{
KillGLWindow(); // Reset the display
MessageBox(NULL,"Can't Find A Suitable PixelFormat.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return false;
}
// Are we able to set the pixel format?
if( !SetPixelFormat(_hDC,PixelFormat,&pfd) )
{
KillGLWindow(); // Reset the display
MessageBox(NULL,"Can't Set The PixelFormat.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return false;
}
return true;
}
et voila quand je dessine :
int WinGL::DrawGLScene()
{
glClear(GL_COLOR_BUFFER_BIT |
GL_DEPTH_BUFFER_BIT); // Clear The Screen And The
Depth Buffer
glLoadIdentity();
// Reset The matrix
// Update our player view,pos,..., and send that to the network
_Camera->SetLook();
_NetWork->SetPosition(_Camera->GetPosition(), _Camera->GetView());
// Each frame we calculate the new frustum. In reality you only need to
// calculate the frustum when we move the camera.
_Frustum->CalculateFrustum();
// Draw the tree
_Terrain->DrawTree();
// Here we draw the octree, starting with the root node and recursing down each node.
// When we get to each of the end nodes we will draw the vertices assigned to them.
_Flag->_TotalNodesDrawn = 0;
_Octree->DrawOctree(_Octree);
_Terrain->CreateSkyBox(_Octree->GetCenter().x,_Octree->GetCenter().y,_Octree->GetCenter().z,
_Octree->GetSize()*2,_Octree->GetSize()*2,_Octree->GetSize()*2);
// Render the cube'd nodes to visualize the octree (in wire frame mode)
if( _Flag->_DoSeeOctree )
_SeeOctree->RenderSeeOctree();
// Draw player
_Terrain->DrawPlayer(_NetWork->GetPosition(), _NetWork->NumberOfUsers(), _Camera->GetRadious());
SwapBuffers(_hDC);
// Swap the backbuffers to the
foreground
return true; // Everything is OK
}
j'utilise pas glut, alors je peu pas tutiliser le truc : lutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH);
et je pense que je fais cette initialisation dans SetupPixelForma...
des idées ?
merci