我正在检查我的OpenGL安装是否正常,但是我的示例程序在执行上崩溃(没有真正的错误消息提示)。我正在使用非官方的GLSDK (http://glsdk.sourceforge.net/docs/html/index.html)发行版,并在windows 8下编译它。
程序(http://www.transmissionzero.co.uk/computing/using-glut-with-mingw/)
#include <glload/gl_3_2_comp.h>
#include <GL/freeglut.h>
void keyboard(unsigned char key, int x, int y);
void display(void);
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutCreateWindow("GLUT Test");
glutKeyboardFunc(&keyboard);
glutDisplayFunc(&display);
glutMainLoop();
return EXIT_SUCCESS;
}
void keyboard(unsigned char key, int x, int y)
{
switch (key)
{
case '\x1B':
exit(EXIT_SUCCESS);
break;
}
}
void display()
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0f, 0.0f, 0.0f);
glBegin(GL_POLYGON);
glVertex2f(-0.5f, -0.5f);
glVertex2f( 0.5f, -0.5f);
glVertex2f( 0.5f, 0.5f);
glVertex2f(-0.5f, 0.5f);
glEnd();
glFlush();
}我知道#include <glload/gl_3_2_comp.h>是罪魁祸首,因为如果我将这一行改为#include <GL/gl.h>,那么示例程序运行良好,并在黑色背景上显示一个漂亮的红色方块.或者,如果我删除display()函数的内容,程序也会运行良好。
问题是:我需要使用OpenGL 3.x或更高的API,所以我不能只包含过时的操作系统头(Windows8)。
我的链接器设置(在代码::块中):
包括路径:
#定义:
发布于 2015-03-23 02:54:24
基于GL负载文档,您似乎需要显式地初始化它:
#include <glload/gl_load.h>
...
ogl_LoadFunctions();在设置了过剩之后,ogl_LoadFunctions()调用需要在哪里。
https://stackoverflow.com/questions/29201290
复制相似问题