1

我不明白编译器试图强制执行什么。我有一个设置 OpenGL 上下文的函数,并HGLRC通过指针返回:

BOOL SetupWin32Context(HDC hDC, HGLRC *phRC) {
    /* do bunch of work*/
    HGLRC hRC = wglCreateContext(hDC);
    *phRC = hRC;
    return TRUE;}

*phRC = hRC;得到:

    error C2297: '*' : illegal, right operand has type 'HGLRC *'

这对我来说没有任何意义。

从 pastebin 复制的完整代码

#include "Bindings.h"
#include <Windows.h>
#include <gl\GL.h>

BOOL SetupWin32Context(HDC hDC, HGLRC *phRC)
{
        HGLRC hRC = NULL;
    PIXELFORMATDESCRIPTOR pfd =
    {
        sizeof(PIXELFORMATDESCRIPTOR),
        1,
        PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER,
        PFD_TYPE_RGBA,
        32, /* Colordepth of the framebuffer. */
        0, 0, 0, 0, 0, 0,
        0,
        0,
        0,
        0, 0, 0, 0,
        0, /* Bits of the depthbuffer. */
        0, /* Bits of the stencilbuffer. */
        0, /* Number of Aux buffers. */
        PFD_MAIN_PLANE,
        0,
        0, 0, 0
    };

        int format = ChoosePixelFormat(hDC, &pfd);
        if(format == 0) return FALSE;
        if(!SetPixelFormat(hDC,format, &pfd)) return FALSE;
        hRC = wglCreateContext(hDC);
        if(hRC == 0)
                hRC = wglCreateContext(hDC);
        if(hRC == 0)
                return FALSE;
        wglMakeCurrent(hDC, hRC)
        *phRC = hRC;
        return TRUE;
}
4

1 回答 1

4

在实际代码中,后面需要一个分号

wglMakeCurrent(hDC, hRC)

像这样:

wglMakeCurrent(hDC, hRC);
于 2013-09-29T23:17:31.850 回答