opengl编译问题,解决重奖(microsoft对opengl的打压)
#include <GL/gl.h>
#include <GL/glu.h>
#include <stdlib.h>
#include "aux.h"
/* Clear the screen. Set the current color to white.
* Draw the wire frame cube.
*/
void display (void)
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f (1.0, 1.0, 1.0);
glLoadIdentity (); /* clear the matrix */
glTranslatef (0.0, 0.0, -5.0); /* viewing transformation */
glScalef (1.0, 2.0, 1.0); /* modeling transformation */
auxWireCube(1.0); /* draw the cube */
glFlush();
}
void myinit (void) {
glShadeModel (GL_FLAT);
}
/* Called when the window is first opened and whenever
* the window is reconfigured (moved or resized).
*/
void myReshape(int w, int h)
{
glMatrixMode (GL_PROJECTION); /* prepare for and then */
glLoadIdentity (); /* define the projection */
glFrustum (-1.0, 1.0, -1.0, 1.0, 1.5, 20.0); /* transformation */
glMatrixMode (GL_MODELVIEW); /* back to modelview matrix */
glViewport (0, 0, w, h); /* define the viewport */
}
/* Main Loop
* Open window with initial window size, title bar,
* RGBA display mode, and handle input events.
*/
int main(int argc, char** argv)
{
auxInitDisplayMode (AUX_SINGLE | AUX_RGB);
auxInitPosition (0, 0, 500, 500);
auxInitWindow (argv[0]);
myinit ();
auxReshapeFunc (myReshape);
auxMainLoop(display);
}
-----------------------------------
编译是,输出为:
------ 已启动生成: 项目: cube, 配置: Debug Win32 ------
正在编译...
cube.cpp
d:\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\gl\GL.h(1152) : error C2144: 语法错误 : “void”的前面应有“;”
d:\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\gl\GL.h(1152) : error C2501: “WINGDIAPI” : 缺少存储类或类型说明符
d:\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\gl\GL.h(1152) : error C2146: 语法错误 : 缺少“;”(在标识符“glAccum”的前面)
d:\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\gl\GL.h(1166) : error C2144: 语法错误 : “void”的前面应有“;”
d:\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\gl\GL.h(1166) : error C2501: “WINGDIAPI” : 缺少存储类或类型说明符
d:\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\gl\GL.h(1166) : error C2086: “int WINGDIAPI” : 重定义
d:\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\gl\GL.h(1152) : 参见“WINGDIAPI”的声明
d:\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\gl\GL.h(1166) : error C2146: 语法错误 : 缺少“;”(在标识符“glClearIndex”的前面)
d:\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\gl\GL.h(1166) : error C2182: “APIENTRY” : 非法使用“void”类型
d:\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\gl\GL.h(1166) : error C2086: “int APIENTRY” : 重定义
d:\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\gl\GL.h(1152) : 参见“APIENTRY”的声明
d:\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\gl\GL.h(1167) : error C2144: 语法错误 : “void”的前面应有“;”
d:\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\gl\GL.h(1167) : error C2501: “WINGDIAPI” : 缺少存储类或类型说明符
d:\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\gl\GL.h(1167) : error C2086: “int WINGDIAPI” : 重定义
d:\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\gl\GL.h(1152) : 参见“WINGDIAPI”的声明
d:\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\gl\GL.h(1167) : error C2146: 语法错误 : 缺少“;”(在标识符“glClearStencil”的前面)
d:\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\gl\GL.h(1167) : error C2182: “APIENTRY” : 非法使用“void”类型
d:\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\gl\GL.h(1167) : error C2086: “int APIENTRY” : 重定义
d:\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\gl\GL.h(1152) : 参见“APIENTRY”的声明
d:\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\gl\GL.h(1168) : error C2144: 语法错误 : “void”的前面应有“;”
d:\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\gl\GL.h(1168) : error C2501: “WINGDIAPI” : 缺少存储类或类型说明符
d:\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\gl\GL.h(1168) : error C2086: “int WINGDIAPI” : 重定义
d:\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\gl\GL.h(1152) : 参见“WINGDIAPI”的声明
.
.
.
d:\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\gl\GL.h(1169) : error C2144: 语法错误 : “void”的前面应有“;”
d:\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\gl\GL.h(1169) : error C2501: “WINGDIAPI” : 缺少存储类或类型说明符
d:\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\gl\GL.h(1169) : fatal error C1003: 错误计数超过 100;正在停止编译
生成日志保存在“file://d:\我的项目\OpenGL\cube\Debug\BuildLog.htm”中
cube - 102 错误,0 警告
---------------------- 完成 ---------------------
生成: 0 已成功, 1 已失败, 0 已跳过
-----------------------------------
用的是vs.net 2003,输出说gl.h出错,这难道要我改gl.h?
各位遇到过这种问题没?怎么解决的?
如果是gl.h的问题,只能说明microsoft对opengl实行打压,这样会失去人心的