Thread: opengl DC question

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User SAMSAM's Avatar
    Join Date
    Nov 2001
    Posts
    218

    opengl DC question

    Hi every1;

    Ok, im done on reviewing vector math.

    now im reading this code in this book"game programming with opengl". i have 3 questions for three parts.

    i broke the parts in 3 sections.

    Code:
    HDC  g_HDC                //global  DC
    question 1:is this device context similar in concept to the hdc memory context that we create in win API to write onto (like in
    DDB bitmap functions , bitblt ,,stretchblt)?


    Code:
    HGLRC  hRC;
    HDC  hdc;
    ////////////
    
    case WM_CREATE:
    
    hdc = GetDC(hwnd);
    g_HDC = hdc;
    SetupPixelFormat(hdc);
    
    
    hRC = wglCreateContext(hdc);
    wglMakeCurrent(hdc, hRC);
    
    return 0;
    break;
    question 2: why there is no ReleaseDC(hwnd, hdc); function
    in the above code. as its routily done in win API?


    then in the body of opengl code during rendering phase we have:

    Code:
    //////////////
    glTranslatef(,,,,,,,,,,,,,);
    glRotatef(,,,,,,,,,,,,,,,,,);
    glColor3f(,,,,,,,,,,,,,,,,,,);
    glBegin(GL_TRIANGLE);
    glVertex3f(,,,,,,,,,,,,,,,,)
    
    glVertex3f(,,,,,,,,,,,,,,,,)
    
    glVertex3f(,,,,,,,,,,,,,,,,)
    
    glEnd();
    
    SwapBuffers(g_HDC);       //bring back buffer to forground
    
    TranslateMessage(&msg);
    DispatchMessage(&msg);
    
    ///////////////////////////
    *if answer to question 1 is yes disregard this one.

    question 3: why couldnt we simply make hdc global like;

    HDC hdc;

    and use it throuout the program so we dont need a second copy of it as g_HDC .? is it because we have to have 2 different device context , one for window procedure and one for opengl calls
    .so how come they are identical?

    why there is no ReleaseDC function for g_HDC neither?


    thanks
    silver or travis should know these.
    Last edited by SAMSAM; 02-24-2003 at 01:45 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. OpenGL Camera Question
    By Astra in forum Game Programming
    Replies: 2
    Last Post: 03-25-2007, 01:53 PM
  2. first opengl game, problems.
    By n3v in forum Game Programming
    Replies: 1
    Last Post: 07-11-2006, 08:22 PM
  3. OpenGL question
    By sand_man in forum Game Programming
    Replies: 4
    Last Post: 11-08-2004, 07:05 AM
  4. OpenGL question
    By rayrayj52 in forum Game Programming
    Replies: 6
    Last Post: 11-07-2004, 03:54 PM