【问题标题】:Why doesn't my OpenGL work?为什么我的 OpenGL 不起作用?
【发布时间】:2014-08-19 16:33:39
【问题描述】:

我第一次在 Visual Studio 2013 中尝试使用 SDL 的 openGL。

SDL 运行良好,但不知该如何设置我的项目才能使用 openGL。

我在链接器输入中包含了“openGL32.lib”,在“GL\gl.h”标头中有一个#include,但出现编译错误,错误似乎在我包含的 gl.h 中.代码如下:

#include <stdio.h>
#include <stdlib.h>
/* If using gl3.h */
/* Ensure we are using opengl's core profile only */
#define GL3_PROTOTYPES 1
#include <C:\Program Files\Microsoft SDKs\Windows\v7.1A\Include\gl\gl.h>

#include <SDL.h>
#define PROGRAM_NAME "Tutorial1"

/* A simple function that prints a message, the error code returned by SDL,
* and quits the application */
void sdldie(const char *msg)
{
    printf("%s: %s\n", msg, SDL_GetError());
    SDL_Quit();
    exit(1);
}


void checkSDLError(int line = -1)
{
#ifndef NDEBUG
    const char *error = SDL_GetError();
    if (*error != '\0')
    {
        printf("SDL Error: %s\n", error);
        if (line != -1)
            printf(" + line: %i\n", line);
        SDL_ClearError();
    }
#endif
}


/* Our program's entry point */
int main(int argc, char *argv[])
{
SDL_Window *mainwindow; /* Our window handle */
SDL_GLContext maincontext; /* Our opengl context handle */

if (SDL_Init(SDL_INIT_VIDEO) < 0) /* Initialize SDL's Video subsystem */
    sdldie("Unable to initialize SDL"); /* Or die on error */

/* Request opengl 3.2 context.
* SDL doesn't have the ability to choose which profile at this time of writing,
* but it should default to the core profile */
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);

/* Turn on double buffering with a 24bit Z buffer.
* You may need to change this to 16 or 32 for your system */
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);

/* Create our window centered at 512x512 resolution */
mainwindow = SDL_CreateWindow(PROGRAM_NAME, SDL_WINDOWPOS_CENTERED,                           SDL_WINDOWPOS_CENTERED,
    512, 512, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN);
if (!mainwindow) /* Die if creation failed */
    sdldie("Unable to create window");

checkSDLError(__LINE__);

/* Create our opengl context and attach it to our window */
maincontext = SDL_GL_CreateContext(mainwindow);
checkSDLError(__LINE__);


/* This makes our buffer swap syncronized with the monitor's vertical refresh */
SDL_GL_SetSwapInterval(1);

/* Clear our buffer with a red background */
glClearColor(1.0, 0.0, 0.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT);
/* Swap our back buffer to the front */
SDL_GL_SwapWindow(mainwindow);
/* Wait 2 seconds */
SDL_Delay(2000);

/* Same as above, but green */
glClearColor(0.0, 1.0, 0.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT);
SDL_GL_SwapWindow(mainwindow);
SDL_Delay(2000);

/* Same as above, but blue */
glClearColor(0.0, 0.0, 1.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT);
SDL_GL_SwapWindow(mainwindow);
SDL_Delay(2000);

/* Delete our opengl context, destroy our window, and shutdown SDL */
SDL_GL_DeleteContext(maincontext);
SDL_DestroyWindow(mainwindow);
SDL_Quit();

return 0;
}

这是我得到的错误:

1>------ Build started: Project: SDL_OGL_Learning, Configuration: Debug Win32 ------
1>  Source.cpp
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1152): error C2144: syntax error : 'void' should be preceded by ';'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1152): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1152): error C2146: syntax error : missing ';' before identifier 'glAccum'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1152): error C2182: 'APIENTRY' : illegal use of type 'void'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1153): error C2144: syntax error : 'void' should be preceded by ';'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1153): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1153): error C2086: 'int WINGDIAPI' : redefinition
1>          c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1152) : see declaration of 'WINGDIAPI'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1153): error C2146: syntax error : missing ';' before identifier 'glAlphaFunc'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1153): error C2182: 'APIENTRY' : illegal use of type 'void'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1153): error C2086: 'int APIENTRY' : redefinition
1>          c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1152) : see declaration of 'APIENTRY'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1154): error C2146: syntax error : missing ';' before identifier 'GLboolean'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1154): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1154): error C2086: 'int WINGDIAPI' : redefinition
1>          c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1152) : see declaration of 'WINGDIAPI'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1154): error C2146: syntax error : missing ';' before identifier 'glAreTexturesResident'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1154): error C2371: 'APIENTRY' : redefinition; different basic types
1>          c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1152) : see declaration of 'APIENTRY'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1155): error C2144: syntax error : 'void' should be preceded by ';'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1155): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1155): error C2086: 'int WINGDIAPI' : redefinition
1>          c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1152) : see declaration of 'WINGDIAPI'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1155): error C2146: syntax error : missing ';' before identifier 'glArrayElement'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1155): error C2182: 'APIENTRY' : illegal use of type 'void'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1155): error C2086: 'int APIENTRY' : redefinition
1>          c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1152) : see declaration of 'APIENTRY'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1156): error C2144: syntax error : 'void' should be preceded by ';'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1156): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1156): error C2086: 'int WINGDIAPI' : redefinition
1>          c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1152) : see declaration of 'WINGDIAPI'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1156): error C2146: syntax error : missing ';' before identifier 'glBegin'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1156): error C2182: 'APIENTRY' : illegal use of type 'void'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1156): error C2086: 'int APIENTRY' : redefinition
1>          c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1152) : see declaration of 'APIENTRY'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1157): error C2144: syntax error : 'void' should be preceded by ';'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1157): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1157): error C2086: 'int WINGDIAPI' : redefinition
1>          c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1152) : see declaration of 'WINGDIAPI'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1157): error C2146: syntax error : missing ';' before identifier 'glBindTexture'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1157): error C2182: 'APIENTRY' : illegal use of type 'void'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1157): error C2086: 'int APIENTRY' : redefinition
1>          c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1152) : see declaration of 'APIENTRY'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1158): error C2144: syntax error : 'void' should be preceded by ';'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1158): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1158): error C2086: 'int WINGDIAPI' : redefinition
1>          c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1152) : see declaration of 'WINGDIAPI'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1158): error C2146: syntax error : missing ';' before identifier 'glBitmap'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1158): error C2182: 'APIENTRY' : illegal use of type 'void'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1158): error C2086: 'int APIENTRY' : redefinition
1>          c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1152) : see declaration of 'APIENTRY'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1159): error C2144: syntax error : 'void' should be preceded by ';'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1159): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1159): error C2086: 'int WINGDIAPI' : redefinition
1>          c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1152) : see declaration of 'WINGDIAPI'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1159): error C2146: syntax error : missing ';' before identifier 'glBlendFunc'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1159): error C2182: 'APIENTRY' : illegal use of type 'void'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1159): error C2086: 'int APIENTRY' : redefinition
1>          c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1152) : see declaration of 'APIENTRY'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1160): error C2144: syntax error : 'void' should be preceded by ';'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1160): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1160): error C2086: 'int WINGDIAPI' : redefinition
1>          c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1152) : see declaration of 'WINGDIAPI'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1160): error C2146: syntax error : missing ';' before identifier 'glCallList'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1160): error C2182: 'APIENTRY' : illegal use of type 'void'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1160): error C2086: 'int APIENTRY' : redefinition
1>          c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1152) : see declaration of 'APIENTRY'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1161): error C2144: syntax error : 'void' should be preceded by ';'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1161): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1161): error C2086: 'int WINGDIAPI' : redefinition
1>          c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1152) : see declaration of 'WINGDIAPI'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1161): error C2146: syntax error : missing ';' before identifier 'glCallLists'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1161): error C2182: 'APIENTRY' : illegal use of type 'void'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1161): error C2086: 'int APIENTRY' : redefinition
1>          c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1152) : see declaration of 'APIENTRY'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1162): error C2144: syntax error : 'void' should be preceded by ';'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1162): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1162): error C2086: 'int WINGDIAPI' : redefinition
1>          c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1152) : see declaration of 'WINGDIAPI'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1162): error C2146: syntax error : missing ';' before identifier 'glClear'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1162): error C2182: 'APIENTRY' : illegal use of type 'void'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1162): error C2086: 'int APIENTRY' : redefinition
1>          c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1152) : see declaration of 'APIENTRY'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1163): error C2144: syntax error : 'void' should be preceded by ';'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1163): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1163): error C2086: 'int WINGDIAPI' : redefinition
1>          c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1152) : see declaration of 'WINGDIAPI'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1163): error C2146: syntax error : missing ';' before identifier 'glClearAccum'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1163): error C2182: 'APIENTRY' : illegal use of type 'void'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1163): error C2086: 'int APIENTRY' : redefinition
1>          c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1152) : see declaration of 'APIENTRY'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1164): error C2144: syntax error : 'void' should be preceded by ';'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1164): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1164): error C2086: 'int WINGDIAPI' : redefinition
1>          c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1152) : see declaration of 'WINGDIAPI'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1164): error C2146: syntax error : missing ';' before identifier 'glClearColor'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1164): error C2182: 'APIENTRY' : illegal use of type 'void'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1164): error C2086: 'int APIENTRY' : redefinition
1>          c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1152) : see declaration of 'APIENTRY'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1165): error C2144: syntax error : 'void' should be preceded by ';'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1165): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1165): error C2086: 'int WINGDIAPI' : redefinition
1>          c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1152) : see declaration of 'WINGDIAPI'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1165): error C2146: syntax error : missing ';' before identifier 'glClearDepth'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1165): error C2182: 'APIENTRY' : illegal use of type 'void'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1165): error C2086: 'int APIENTRY' : redefinition
1>          c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1152) : see declaration of 'APIENTRY'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1166): error C2144: syntax error : 'void' should be preceded by ';'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1166): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1166): error C2086: 'int WINGDIAPI' : redefinition
1>          c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1152) : see declaration of 'WINGDIAPI'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1166): error C2146: syntax error : missing ';' before identifier 'glClearIndex'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1166): error C2182: 'APIENTRY' : illegal use of type 'void'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1166): error C2086: 'int APIENTRY' : redefinition
1>          c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1152) : see declaration of 'APIENTRY'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1167): error C2144: syntax error : 'void' should be preceded by ';'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1167): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1167): error C2086: 'int WINGDIAPI' : redefinition
1>          c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1152) : see declaration of 'WINGDIAPI'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1167): error C2146: syntax error : missing ';' before identifier 'glClearStencil'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1167): error C2182: 'APIENTRY' : illegal use of type 'void'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1167): error C2086: 'int APIENTRY' : redefinition
1>          c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1152) : see declaration of 'APIENTRY'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1168): error C2144: syntax error : 'void' should be preceded by ';'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1168): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1168): error C2086: 'int WINGDIAPI' : redefinition
1>          c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1152) : see declaration of 'WINGDIAPI'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1168): error C2146: syntax error : missing ';' before identifier 'glClipPlane'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1168): error C2182: 'APIENTRY' : illegal use of type 'void'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1168): error C2086: 'int APIENTRY' : redefinition
1>          c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1152) : see declaration of 'APIENTRY'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1169): error C2144: syntax error : 'void' should be preceded by ';'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1169): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1169): error C2086: 'int WINGDIAPI' : redefinition
1>          c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1152) : see declaration of 'WINGDIAPI'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1169): error C2146: syntax error : missing ';' before identifier 'glColor3b'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1169): error C2182: 'APIENTRY' : illegal use of type 'void'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1169): error C2086: 'int APIENTRY' : redefinition
1>          c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1152) : see declaration of 'APIENTRY'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1170): error C2144: syntax error : 'void' should be preceded by ';'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1170): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1170): error C2086: 'int WINGDIAPI' : redefinition
1>          c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1152) : see declaration of 'WINGDIAPI'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1170): error C2146: syntax error : missing ';' before identifier 'glColor3bv'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1170): error C2182: 'APIENTRY' : illegal use of type 'void'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1170): error C2086: 'int APIENTRY' : redefinition
1>          c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1152) : see declaration of 'APIENTRY'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1171): error C2144: syntax error : 'void' should be preceded by ';'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1171): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1171): error C2086: 'int WINGDIAPI' : redefinition
1>          c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1152) : see declaration of 'WINGDIAPI'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1171): error C2146: syntax error : missing ';' before identifier 'glColor3d'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1171): error C2182: 'APIENTRY' : illegal use of type 'void'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1171): error C2086: 'int APIENTRY' : redefinition
1>          c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1152) : see declaration of 'APIENTRY'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1172): error C2144: syntax error : 'void' should be preceded by ';'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1172): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1172): error C2086: 'int WINGDIAPI' : redefinition
1>          c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1152) : see declaration of 'WINGDIAPI'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1172): error C2146: syntax error : missing ';' before identifier 'glColor3dv'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1172): error C2182: 'APIENTRY' : illegal use of type 'void'
1>c:\program files\microsoft sdks\windows\v7.1a\include\gl\gl.h(1172): fatal error C1003:             error count exceeds 100; stopping compilation
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

我该怎么办?

【问题讨论】:

    标签: visual-studio opengl sdl


    【解决方案1】:

    看来您应该首先包含&lt;Windows.h&gt; 以获取Windows API 定义,例如APIENTRY

    【讨论】:

    • 是的!那行得通,但是现在当它执行并加载窗口时,我从 sdl 收到一个错误,说它无法创建 GL 上下文。现在呢?
    • 好的,知道了。好像我的机器不支持 ogl 3.2。谢谢你的回答!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-11-25
    • 2016-06-13
    • 1970-01-01
    • 2022-01-21
    • 1970-01-01
    • 2015-09-25
    • 2018-03-05
    相关资源
    最近更新 更多