Using mingw to cross-compile an opengl application for windows

heya, I am running linux (ubuntu),

I have problems with this. I tried loading glut32.dll and pasting it into the mingw lib / directory, and setting the appropriate headers in include /, however, although compilation is fine - the linker has a serious problem finding characters.

How can i do this? how can i create an opengl application for windows using mingw?

thanks,

+3
source share
2 answers

Windows, - DLL, " ". , DLL. libglut32.a.

, , Visual ++ - ... ( , , , , .)

+2

GLUT, , libopengl32.a, native opengl32.dll .

typedef struct RENDER_SURFACE {
    void (*redraw)(struct RENDER_SURFACE*);
    HWND hWnd;
    HINSTANCE hInstance;
    HDC hdc;
    HGLRC hrc;
    int width;
    int height;
    int pix_fmt;
    float light_position[4];
    float light_ambient[4];
    float light_diffuse[4];
    float light_specular[4];
    float light_shininess;
} RENDER_SURFACE;

static LRESULT AppProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    RENDER_SURFACE* rs = (RENDER_SURFACE*)GetWindowLongPtr(hWnd, GWLP_USERDATA);
    if (uMsg == WM_CREATE)
    {
        RECT rc;
        PIXELFORMATDESCRIPTOR pfd;
        rs = (RENDER_SURFACE*)((LPCREATESTRUCT)lParam)->lpCreateParams;
        SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR)rs);
        rs->hWnd = hWnd;
        rs->hdc = GetDC(hWnd);
        GetClientRect(hWnd, &rc);
        rs->width = rc.right-rc.left;
        rs->height = rc.bottom-rc.top;
        memset(&pfd, 0, sizeof(pfd));
        pfd.nSize = sizeof(pfd);
        pfd.nVersion = 1;
        pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_DOUBLEBUFFER | PFD_SUPPORT_OPENGL;
        pfd.cColorBits = 24;
        pfd.cDepthBits = 32;
        rs->pix_fmt = ChoosePixelFormat(rs->hdc, &pfd); 
        if (!rs->pix_fmt)
        {
            MessageBox(hWnd, "ChoosePixelFormat FAILED!", "Fatal Error", MB_OK | MB_ICONSTOP);
            DestroyWindow(hWnd);
            return -1;
        }
        SetPixelFormat(rs->hdc, rs->pix_fmt, &pfd);
        rs->hrc = wglCreateContext(rs->hdc);
        wglMakeCurrent(rs->hdc, rs->hrc);
        /* SwapBuffers(rs->hdc); */
        return 0;
    }
    else if (uMsg == WM_PAINT)
    {
        /* other stuffs */
    }
    return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
0

Source: https://habr.com/ru/post/1719329/


All Articles