Game Development Community

OpenGL Init Problems

by Frank Huang · in Technical Issues · 04/29/2004 (2:32 pm) · 10 replies

I'm having problems using OpenGL in my game -- I have an 'engine' with classes for system functions (window creation), graphics functions (OpenGL), input, and audio. Right now, I am creating a window and initializing OpenGL, but when I draw anything to the screen, or even clear the screen, absolutely nothing happens. I think that's it's an init problem. Can anyone help? I will post source if requested.

About the author

Recent Threads

  • Altitude Forums
  • MS-Linux

  • #1
    04/29/2004 (2:34 pm)
    I can help.
    have you created the context and set it current?
    are you doing this with multi threading?
    how did you configure the Pixel format Descriptor?
    #2
    04/29/2004 (2:38 pm)
    Multi-threading : yes. I have one thread, the message handling thread, which picks up Windows messages, and another one: the game thread, which is a linear function that runs the game.

    The message thread creates the window, calls a user-defined Init() function, creates the game thread, and proceeds to process messages.

    Let's see -- for the context:

    // Create a rendering context
    if ( !( GLRC = wglCreateContext( hDC ) ) )
    {
    GDLGlobal->ShowError( "Couldn't create rendering context.", true );
    return GDL_BOOL_FAILED;
    }

    // Activate rendering context
    if ( !wglMakeCurrent( hDC, GLRC ) )
    {
    GDLGlobal->ShowError( "Couldn't activate rendering context.", true );
    return GDL_BOOL_FAILED;
    }

    Will that work? And the PFD:

    dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
    iPixelType = PFD_TYPE_RGBA;
    cColorBits = DisplayBPP (32 in this case);
    cDepthBits = 16;
    iLayerType = PFD_MAIN_PLANE;

    This is in correspondence with every OpenGL tutorial I have found on the Internet, so it should work...
    #3
    04/29/2004 (2:40 pm)
    Yup the gl stuff is fine
    your problem is your thread.

    look into some more Multi threading renderer info.

    you are prolly abusing who started the context and who is using it.
    #4
    04/29/2004 (2:42 pm)
    I haven't been here very long, so, can I find help on GarageGames about multithreaded rendering? Does that mean that only the thread that started the context can use it?
    #5
    04/29/2004 (2:46 pm)
    Negative you wont find anything here about multi threaded rendering.

    well .. not that I have seen anyhow.. maybe a link to a book.

    do you have access to the OpenGL Super Bible?
    it has some stuff there should be some code online somewhere from that. (i think it had the code!!)

    anyhow indeed there is an interprocess relationship.
    you cant make call's to your context without managing the process rights to it.

    to be brutally honest I've never set one up.
    but I do know that by default you cannot send commands to a gl context from a thread that did not start it.
    can you change that relationship?
    I dont know.
    #6
    04/29/2004 (2:48 pm)
    Uh, OpenGL Super Bible???

    Anyways, thanks for all your help! I never would've thought it was the multithreading.
    #7
    04/29/2004 (3:02 pm)
    Heh np.
    when I get home I will dig around if your still here.
    see If I can help somemore.
    #8
    04/29/2004 (3:08 pm)
    Well, I have 56k dial-up, so I really can't be online for too long. So, what's the OpenGL Super Bible?
    #9
    03/14/2005 (4:28 am)
    Hi,

    I am using a system with following config to run Torque, but it is not opening even the demo page .My system config is P-3-600Mhz,256MB RAM with SIS 6326AGP card.I was not able to locate the OpenGL drivers for windows 2000 for the above AGP card. Can anyone help me..Please..

    Rgds

    Siby
    #10
    03/14/2005 (4:38 am)
    @Frank

    GL works by creating a context and attaching said context to a window. You don't simply create a window and then create a context without tying the two together. This would result in you rendering to an invisible view.

    The GL code you have shown simply creates a context that will do precisely nothing without a window to render into.