游戏开发论坛

 找回密码
 立即注册
搜索
查看: 2050|回复: 1

关于OpenGL中VBO扩展编程的一个错误,感觉很小就是解决不

[复制链接]

8

主题

20

帖子

20

积分

注册会员

Rank: 2

积分
20
发表于 2005-4-13 18:53:00 | 显示全部楼层 |阅读模式
我自己定义了一个Mesh类,定义如下:
#include "Mesh.h"  其中包括了glext.h和wglext.h
#include "Scene.h"

编译的错误总是说我类型转换的问题,请高手指教?


PFNGLBINDBUFFERARBPROC glBindBufferARB = NULL;
PFNGLBINDBUFFERARBPROC glGenBuffersARB = NULL;
PFNGLBINDBUFFERARBPROC glBufferDataARB = NULL;
PFNGLBINDBUFFERARBPROC glDeleteBuffersARB = NULL;

bool LVBO_mesh::InitGL()
{

       
        glGenBuffersARB = (PFNGLGENBUFFERSARBPROC) wglGetProcAddress("glGenBuffersARB");
        glBufferDataARB = (PFNGLBUFFERDATAARBPROC) wglGetProcAddress("glBufferDataARB");
        glBindBufferARB = (PFNGLBINDBUFFERARBPROC) wglGetProcAddress("glBindBufferARB");

        glGenBuffersARB(1, &_VBOv);
        glBindBufferARB(GL_ARRAY_BUFFER_ARB, _VBOv);
        glBufferDataARB(GL_ARRAY_BUFFER_ARB, _vertnum * sizeof(float) * 3, _vert, GL_STATIC_DRAW_ARB);

        glGenBuffersARB(1, &_VBOn);
        glBindBufferARB(GL_ARRAY_BUFFER_ARB, _VBOn);
        glBufferDataARB(GL_ARRAY_BUFFER_ARB, _vertnum * sizeof(float) * 3, _normal, GL_STATIC_DRAW_ARB);

        glGenBuffersARB(1, &_VBOt);
        glBindBufferARB(GL_ARRAY_BUFFER_ARB, _VBOt);
        glBufferDataARB(GL_ARRAY_BUFFER_ARB, _vertnum * sizeof(float) * 2, _tvvert, GL_STATIC_DRAW_ARB);

        return true;
}

/************************************************************************/
/* 采用VBO模式绘制下的析构函数                                          */
/************************************************************************/
LVBO_mesh::~LVBO_mesh ()
{
        glDeleteBuffersARB = (PFNGLBINDBUFFERARBPROC) wglGetProcAddress("glDeleteBuffersARB");
        glDeleteBuffersARB(1, &_VBOv);
        glDeleteBuffersARB(1, &_VBOn);
        glDeleteBuffersARB(1, &_VBOt);

}

/************************************************************************/
/* 采用VBO模式绘制                                                      */
/************************************************************************/
void LVBO_mesh :: Display()
{
        switch(rstate)
        {
        case RENDER_FACE:
                glPolygonMode(GL_FRONT, GL_FILL);
                _mat->SetGL();
                break;
        case RENDER_EDGE:
                glDisable(GL_LIGHTING);
                glDisable(GL_TEXTURE_2D);
                glPolygonMode(GL_FRONT, GL_LINE);
                glColor3f(0.8f, 0.8f, 0.8f);
                break;
        }

        glEnableClientState(GL_VERTEX_ARRAY);
        glEnableClientState(GL_NORMAL_ARRAY);
        glEnableClientState(GL_TEXTURE_COORD_ARRAY);

        glBindBufferARB(GL_ARRAY_BUFFER_ARB, _VBOv);
        glVertexPointer(3, GL_FLOAT, 0, _vert);

        glBindBufferARB(GL_ARRAY_BUFFER_ARB, _VBOn);
        glNormalPointer(GL_FLOAT, 0, _normal);

        glBindBufferARB(GL_ARRAY_BUFFER_ARB, _VBOt);
        glTexCoordPointer(2, GL_FLOAT, 0, _tvvert);
       
        glDrawElements (GL_TRIANGLES, _facenum * 3, GL_UNSIGNED_INT, _faces);
        GLERR();

       
}


编译总是报这几个扩展函数出错?请教?为什么?
Deleting intermediate files and output files for project 'Large - Win32 Debug'.
--------------------Configuration: Large - Win32 Debug--------------------
Compiling...
MainFrame.cpp
Map.cpp
Camera.cpp
Mesh.cpp
f:\code\large\mesh.cpp(123) : error C2440: '=' : cannot convert from 'void (__stdcall *)(int,unsigned int *)' to 'void (__stdcall *)(unsigned int,unsigned int)'
        This conversion requires a reinterpret_cast, a C-style cast or function-style cast
f:\code\large\mesh.cpp(124) : error C2440: '=' : cannot convert from 'void (__stdcall *)(unsigned int,int,const void *,unsigned int)' to 'void (__stdcall *)(unsigned int,unsigned int)'
        This conversion requires a reinterpret_cast, a C-style cast or function-style cast
f:\code\large\mesh.cpp(127) : error C2664: 'void (unsigned int,unsigned int)' : cannot convert parameter 2 from 'unsigned int *' to 'unsigned int'
        This conversion requires a reinterpret_cast, a C-style cast or function-style cast
f:\code\large\mesh.cpp(129) : error C2197: 'void (__stdcall *)(unsigned int,unsigned int)' : too many actual parameters
f:\code\large\mesh.cpp(131) : error C2664: 'void (unsigned int,unsigned int)' : cannot convert parameter 2 from 'unsigned int *' to 'unsigned int'
        This conversion requires a reinterpret_cast, a C-style cast or function-style cast
f:\code\large\mesh.cpp(133) : error C2197: 'void (__stdcall *)(unsigned int,unsigned int)' : too many actual parameters
f:\code\large\mesh.cpp(135) : error C2664: 'void (unsigned int,unsigned int)' : cannot convert parameter 2 from 'unsigned int *' to 'unsigned int'
        This conversion requires a reinterpret_cast, a C-style cast or function-style cast
f:\code\large\mesh.cpp(137) : error C2197: 'void (__stdcall *)(unsigned int,unsigned int)' : too many actual parameters
f:\code\large\mesh.cpp(148) : error C2664: 'void (unsigned int,unsigned int)' : cannot convert parameter 2 from 'unsigned int *' to 'unsigned int'
        This conversion requires a reinterpret_cast, a C-style cast or function-style cast
f:\code\large\mesh.cpp(149) : error C2664: 'void (unsigned int,unsigned int)' : cannot convert parameter 2 from 'unsigned int *' to 'unsigned int'
        This conversion requires a reinterpret_cast, a C-style cast or function-style cast
f:\code\large\mesh.cpp(150) : error C2664: 'void (unsigned int,unsigned int)' : cannot convert parameter 2 from 'unsigned int *' to 'unsigned int'
        This conversion requires a reinterpret_cast, a C-style cast or function-style cast
Scene.cpp
Error executing cl.exe.
Creating browse info file...

Large.exe - 11 error(s), 0 warning(s)


55

主题

175

帖子

193

积分

注册会员

Rank: 2

积分
193
发表于 2005-4-14 13:30:00 | 显示全部楼层

Re:关于OpenGL中VBO扩展编程的一个错误,感觉很小就是解决

PFNGLBINDBUFFERARBPROC glBindBufferARB = NULL;
PFNGLBINDBUFFERARBPROC glGenBuffersARB = NULL;
PFNGLBINDBUFFERARBPROC glBufferDataARB = NULL;
PFNGLBINDBUFFERARBPROC glDeleteBuffersARB = NULL;

拜托不要跟别人说你是学OpenGL的.
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2024-12-23 20:24

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表