win10安装glew方法-创新互联

开发环境是 visual studio 2012win10安装glew方法

1 : 下载 glew 2.0 , 地址 http://glew.sourceforge.net/

成都创新互联成立以来不断整合自身及行业资源、不断突破观念以使企业策略得到完善和成熟,建立了一套“以技术为基点,以客户需求中心、市场为导向”的快速反应体系。对公司的主营项目,如中高端企业网站企划 / 设计、行业 / 企业门户设计推广、行业门户平台运营、成都app软件开发公司移动网站建设、微信网站制作、软件开发、雅安服务器托管等实行标准化操作,让客户可以直观的预知到从成都创新互联可以获得的服务效果。

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 to C:Program Files (x86)Microsoft Visual Studio 11.0VCin

注意  lib 和 dll 都用32位的 , 因为 VS 在  C:Program Files (x86)

测试程序, 这个能跑起来就说明安装正确

#include 
#include
#include
//#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;
}

当前名称:win10安装glew方法-创新互联
网站URL:http://pwwzsj.com/article/ggsss.html