bit-hack / softgl

Software Rendered OpenGL implementation
11 stars 1 forks source link

How to use this library? #11

Closed luoxz-ai closed 4 years ago

luoxz-ai commented 4 years ago

Hello, may I ask if there are any sample programs using this library?

hwnd = CreateWindowEx

HDC   hDC =  GetDC(hwnd);   //  **Is there a problem in it????????????**

wglSwapBuffers_imp    -> GdiHook.invalidate(gl_context->window.getHwnd());

Call exception???

luoxz-ai commented 4 years ago

step1:

    hwnd = CreateWindowEx(NULL,                 // extended style
        "Windows API",                          // class name
        "OpenGL",      // app name
        dwStyle | WS_CLIPCHILDREN |
        WS_CLIPSIBLINGS,
        0, 0,                               // x,y coordinate
        windowRect.right - windowRect.left,
        windowRect.bottom - windowRect.top, // width, height
        NULL,                               // handle to parent
        NULL,                               // handle to menu
        hInstance,                          // application instance
        NULL);                              // no extra params

    ShowWindow(hwnd, SW_SHOW);          // display the window
    UpdateWindow(hwnd);                 // update the window
    hDC = ::GetDC(hwnd);   //   **Is there a problem in it????????????**

step2:

        pixelFormat = wglChoosePixelFormat_my(hDC, &pfd)
        wglSetPixelFormat_my(hDC, pixelFormat, &pfd)
    hRC = wglCreateContext(hDC);
    wglMakeCurrent(hDC, hRC);
    glViewport_my(0, 0, width, height);
    glMatrixMode_my(GL_PROJECTION);
    glLoadIdentity_my();
    glMatrixMode_my(GL_MODELVIEW);
    glLoadIdentity_my();

step3:

    while (true)
    {
        (*drawGraphics)();

        wglSwapBuffers_my(hDC);   **------->  exception error**

    }

Please tell me how to do it ? thank you very much.

luoxz-ai commented 4 years ago

Can GDI HOOK place 3D models in any window?

Is there a library usage demonstration?

bit-hack commented 4 years ago

SoftGL is intended to be used in one situation only. You build it as a dynamic library (.dll) and place it next to any Game that uses OpenGL 1.2. That game will be forced to use SoftGL instead of your graphics card providers OpenGL implementation. It is a work in progress however and will certainly contain a vast number of issues, so it will be a rough ride.

You can see what it does here, where I used it to play quake: https://www.youtube.com/watch?v=qy6tSDsbm6o

Its not a library that you link into your own code in the traditional sense.