openGL扩展与版本有关问题
openGL扩展与版本问题
测试显卡支持的openGL版本为2.1.0,要加载什么版本的glew库合适呢,是越高版本的越好吗?现在加的是glew是1.5.2版本的,可是有的函数识别不了,有的还发生中断,比如说glPrimitiveRestartIndex函数。如果是低版本的就无法识别,高版本的就发生中断,很纠结。新手,望大家多加指教!
------解决方案--------------------
用freeglut(freeglut.sourceforge.net/)吧。
------解决方案--------------------
是的,它的用法挺简单的,这里有一个例子:
测试显卡支持的openGL版本为2.1.0,要加载什么版本的glew库合适呢,是越高版本的越好吗?现在加的是glew是1.5.2版本的,可是有的函数识别不了,有的还发生中断,比如说glPrimitiveRestartIndex函数。如果是低版本的就无法识别,高版本的就发生中断,很纠结。新手,望大家多加指教!
扩展
------解决方案--------------------
用freeglut(freeglut.sourceforge.net/)吧。
------解决方案--------------------
是的,它的用法挺简单的,这里有一个例子:
//
// This code was created by Jeff Molofee '99 (ported to Linux/GLUT by Richard Campbell '99)
//
// If you've found this code useful, please let me know.
//
// Visit me at www.demonews.com/hosted/nehe
// (email Richard Campbell at ulmont@bellsouth.net)
//
#include <GL/glut.h> // Header File For The GLUT Library
#include <GL/gl.h> // Header File For The OpenGL32 Library
#include <GL/glu.h> // Header File For The GLu32 Library
#include <unistd.h> // needed to sleep
/* ASCII code for the escape key. */
#define ESCAPE 27
/* The number of our GLUT window */
int window;
/* rotation angle for the triangle. */
float rtri = 0.0f;
/* rotation angle for the quadrilateral. */
float rquad = 0.0f;
/* A general OpenGL initialization function. Sets all of the initial parameters. */
void InitGL(int Width, int Height) // We call this right after our OpenGL window is created.
{
glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // This Will Clear The Background Color To Black
glClearDepth(1.0); // Enables Clearing Of The Depth Buffer
glDepthFunc(GL_LESS); // The Type Of Depth Test To Do
glEnable(GL_DEPTH_TEST); // Enables Depth Testing
glShadeModel(GL_SMOOTH); // Enables Smooth Color Shading
glMatrixMode(GL_PROJECTION);
glLoadIdentity(); // Reset The Projection Matrix
gluPerspective(45.0f,(GLfloat)Width/(GLfloat)Height,0.1f,100.0f); // Calculate The Aspect Ratio Of The Window
glMatrixMode(GL_MODELVIEW);
}
/* The function called when our window is resized (which shouldn't happen, because we're fullscreen) */
void ReSizeGLScene(int Width, int Height)
{
if (Height==0) // Prevent A Divide By Zero If The Window Is Too Small
Height=1;
glViewport(0, 0, Width, Height); // Reset The Current Viewport And Perspective Transformation
glMatrixMode(GL_PROJECTION);
glLoadIdentity();