如何查看自己的OpenGL版本

核心提示怎么知道自己电脑opengl是什么版本OpenGL是个专业的3D程序接口,是一个功能强大,调用方便的底层3D图形操作方法01方法一:1.检测显卡类型(Windows):1) 打开“运行”窗口。2)输入dxdiag进入 DirectX诊断工具

怎么知道自己电脑opengl是什么版本

OpenGL是个专业的3D程序接口,是一个功能强大,调用方便的底层3D图形

操作方法

01

方法一:1.检测显卡类型(Windows):1) 打开“运行”窗口。2)输入dxdiag进入 DirectX诊断工具,即列出显卡信息。

02

方法一:2.检测 OpenGL版本(Windows,Mac,移动设备)需要安装个第三方小软件。。名字叫:OpenGLExtension Viewer。Windows:下载并安装OpenGLExtension Viewer。Mac、移动设备:在OpenGLExtension Viewer网页中,对应的选择从 Mac App Store、iTunes Store、Android Market下载即可。

03

注:OpenGL Extension Viewer是个免费的应用程序,由 Realtech VR 开发。此工具可以显示当前安装的 OpenGL 版本,并且可以检测和升级显卡驱动。

04

方法二:大部分独立显卡以及少部分集成显卡都支持OPENGL。 可以看下电脑中安装的是哪种显卡。在桌面上我的计箕机上面点击右键,在列表中点击管理。 接着在弹出的计箕机管理的界面中点击设备管理器。就可以在右侧看到在列表中有一个显示适配器。前面的按钮就可以看到这里就是电脑所用的显卡。这里用的是NVIDIA是支持OPENGL

如何运行opengl红宝书中的源码

一、安装GLUT工具包

1下载OpenGL需要的库文件 ,一般可以选择下载glut库(内含所有必须文件)

2解压后将得到的glut.lib和glut32.lib这两个静态函数库复制到文件目录的lib文件夹下

X:Program Files (x86)Microsoft Visual Studio 12.0VClib

3将glut.dll,glut32.dll这两个动态库文件放到操作系统目录下面的C:Windowssystem32文件夹内(32位系统)或?C:WindowsSysWOW64(64位系统)。

为了兼容性考虑,最好在这两个目录下都复制相应的文件。

4将解压得到的头文件glut.h复制到目录如下目录下:

X:Program Files (x86)Microsoft Visual Studio 12.0VCincludeGL

提示:如果在incluce目录下没有GL文件夹,则需要手动创建

二、VS2013中的配置

创建一个空白的Win32控制台应用程序

在代码最前面添加包含目录

#include <GL/glut.h>

然后就可以编辑自己的OpenGL程序了

例如:复制如下代码到刚配置好的VS中

#include <GL/glut.h>

#include <stdlib.h>

#include <math.h>

#include <stdio.h>

static int year = 0,spin=0, day = 0;

static GLint fogMode;

const int n = 100;

const GLfloat R = 1.0f;

const GLfloat Pi = 3.1415926536f;

void DrawCircle()

{

int i;

glClear(GL_COLOR_BUFFER_BIT);

glBegin(GL_LINE_LOOP);

for (i = 0; i < n; ++i)

{

glColor3f(1.0, 0.0, 0.0);

glVertex2f(R*cos(2 * Pi / n*i), R*sin(2 * Pi / n*i));

}

glEnd();

glFlush();

}

void init(void)

{

GLfloat position[] = { 0.5, 0.5, 3.0, 0.0 };

glEnable(GL_DEPTH_TEST); //防止遮挡

glLightfv(GL_LIGHT0, GL_POSITION, position);

glEnable(GL_LIGHTING);

glEnable(GL_LIGHT0);

{

GLfloat mat[3] = { 0.1745, 0.01175, 0.01175 };

glMaterialfv(GL_FRONT, GL_AMBIENT, mat);

mat[0] = 0.61424; mat[1] = 0.04136; mat[2] = 0.04136;

glMaterialfv(GL_FRONT, GL_DIFFUSE, mat);

mat[0] = 0.727811; mat[1] = 0.626959; mat[2] = 0.626959;

glMaterialfv(GL_FRONT, GL_SPECULAR, mat);

glMaterialf(GL_FRONT, GL_SHININESS, 0.6*128.0);

}

glEnable(GL_FOG);

{

GLfloat fogColor[4] = { 0.5, 0.5, 0.5, 1.0 };

fogMode = GL_EXP;

glFogi(GL_FOG_MODE, fogMode);

glFogfv(GL_FOG_COLOR, fogColor);

glFogf(GL_FOG_DENSITY, 0.35);

glHint(GL_FOG_HINT, GL_DONT_CARE);

glFogf(GL_FOG_START, 1.0);

glFogf(GL_FOG_END, 5.0);

}

glClearColor(0.5, 0.9, 0.9, 1.0);

}

void display(void)

{

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glColor3f(0.0, 1.0, 1.0);

glPushMatrix(); //记住自己的位置

glutSolidSphere(1.0, 20, 16);

glRotatef(spin, 0.0, 1.0, 0.0); //自转,绕着一个向量以给定角度旋转(正的为逆时针)

glTranslatef(2.0, 1.0, 0.0);

glRotatef(spin, 1.0, 0.0, 0.0); //公转

glRectf(0.1,0.1,0.5,0.5);

glColor3f(0.0, 0.0, 1.0);

glutWireSphere(0.2, 8, 8);

glColor3f(1.0, 0.0, 0.0);

glTranslatef(2.0, 1.0, 0.0);

glRotatef(2 * spin, 0.0, 1.0, 0.0);

glutSolidSphere(0.5, 16, 8);

glPopMatrix();//回到原来的位置

glutSwapBuffers();

}

void spinDisplay(void)

{

spin = spin + 2;

if (spin > 360)

spin = spin - 360;

glutPostRedisplay();

}

void mouse(int button,int state,int x,int y )

{

switch (button)

{

case GLUT_LEFT_BUTTON:

if (state == GLUT_DOWN)

glutIdleFunc(spinDisplay);

break;

case GLUT_MIDDLE_BUTTON:

if (state == GLUT_DOWN)

glutIdleFunc(NULL);

break;

default:

break;

}

}

void reshape(int w, int h)

{

glViewport(0, 0, (GLsizei)w, (GLsizei)h);

glMatrixMode(GL_PROJECTION);

glLoadIdentity();

gluPerspective(60.0, (GLfloat)w / (GLfloat)h, 0.5, 20.0);

glMatrixMode(GL_MODELVIEW);

glLoadIdentity();

gluLookAt(0.0, 10.0, 10.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);

}

void keyboard(unsigned char key, int x, int y)

{

switch (key) {

case 'd':

day = (day + 10) % 360;

glutPostRedisplay();

break;

case 'D':

day = (day - 10) % 360;

glutPostRedisplay();

break;

case 'y':

year = (year + 5) % 360;

glutPostRedisplay();

break;

case 'Y':

year = (year - 5) % 360;

glutPostRedisplay();

break;

case 27:

exit(0);

break;

default:

break;

}

}

int main(int argc, char** argv)

{

glutInit(&argc, argv);

glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);

glutInitWindowSize(400, 400);

glutInitWindowPosition(100, 100);

glutCreateWindow("OpengGL 程序设计--杨超");

init();

//glutDisplayFunc(DrawCircle);

glutDisplayFunc(display);

glutReshapeFunc(reshape);

//glutKeyboardFunc(keyboard);

glutMouseFunc(mouse);

glutMainLoop();

return 0;

}

5编译后能正确运行说明配置成功!

 
友情链接
鄂ICP备19019357号-22