win 10 安装 glew 方法
生活随笔
收集整理的這篇文章主要介紹了
win 10 安装 glew 方法
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
開發環境是 visual studio 2012
1 : 下載 glew 2.0 , 地址http://glew.sourceforge.net/
2 : glew.h 文件copy to C:Program Files (x86)Windows Kits8.0Includeumgl
3 : glew.lib copy to C:Program Files (x86)Microsoft Visual Studio 11.0VClib
4 : glew32.dll copy toC:Program Files (x86)Microsoft Visual Studio 11.0VCin
注意 lib 和 dll 都用32位的 , 因為 VS 在C:Program Files (x86)
測試程序, 這個能跑起來就說明安裝正確
#include <stdio.h>
#include <GL/glew.h>
#include <GL/glut.h>
//#include "ogldev_math_3d.h"
#pragma comment(lib , "glut32.lib")
#pragma comment(lib , "glew32.lib")
struct Vector3f
{
float x;
float y;
float z;
Vector3f()
{
}
Vector3f(float _x, float _y, float _z)
{
x = _x;
y = _y;
z = _z;
}
Vector3f(float f)
{
x = y = z = f;
}
Vector3f& operator+=(const Vector3f& r)
{
x += r.x;
y += r.y;
z += r.z;
return *this;
}
Vector3f& operator-=(const Vector3f& r)
{
x -= r.x;
y -= r.y;
z -= r.z;
return *this;
}
Vector3f& operator*=(float f)
{
x *= f;
y *= f;
z *= f;
return *this;
}
operator const float*() const
{
return &(x);
}
Vector3f Cross(const Vector3f& v) const;
Vector3f& Normalize();
void Rotate(float Angle, const Vector3f& Axis);
void Print() const
{
printf("(%.02f, %.02f, %.02f)", x, y, z);
}
};
GLuint VBO;
static int i = 0;
static void RenderSceneCB()
{
int j ;
glClear(GL_COLOR_BUFFER_BIT);
glEnableVertexAttribArray(0);
//glBindBuffer(GL_ARRAY_BUFFER, VBO);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
j = (i++) % 2 ;
glDrawArrays(GL_POINTS, 0, 1);
glDrawArrays(GL_POINTS, 0, 2);
//glDrawArrays(GL_POINTS,j, 1);
glDisableVertexAttribArray(0);
glutSwapBuffers();
}
static void InitializeGlutCallbacks()
{
glutDisplayFunc(RenderSceneCB);
glutIdleFunc(RenderSceneCB);
}
static void CreateVertexBuffer()
{
Vector3f Vertices[2];
Vertices[0] = Vector3f(0.0f, 0.0f, 0.0f);
Vertices[1] = Vector3f(0.2f, 0.2f, 0.0f);
glPointSize(20.0);
glGenBuffers(1, &VBO);
glBindBuffer(GL_ARRAY_BUFFER, VBO);
glBufferData(GL_ARRAY_BUFFER, sizeof(Vertices), Vertices, GL_STATIC_DRAW);
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGBA);
glutInitWindowSize(1024, 768);
glutInitWindowPosition(100, 100);
glutCreateWindow("Tutorial 02");
InitializeGlutCallbacks();
// Must be done after glut is initialized!
GLenum res = glewInit();
if (res != GLEW_OK) {
fprintf(stderr, "Error: '%s'
", glewGetErrorString(res));
return 1;
}
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
CreateVertexBuffer();
glutMainLoop();
return 0;
}
總結
以上是生活随笔為你收集整理的win 10 安装 glew 方法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 在哪儿能找c语言编程题,C语言程序设计的
- 下一篇: 验证哥德巴赫猜想c语言算法,验证哥德巴赫