无法将char转换为GluByte(如何使用Reinterpreted_cast)

时间:2015-10-06 17:17:40

标签: c++ opengl

我获得了一段代码,可以在我的笔记本电脑上运行系统测试,这样我的教授就可以基本了解我们所运行的系统(即将启动OpenGL课程)。我是OpenGL和C ++的新手(过去主要使用过Java),经过多年的努力来解决它没有找到正确的lib文件的问题,我现在得到了这个错误:

  

错误C2440:' =' :无法转换为' const GLubyte *'到#char; char *'   1 GT;指向的类型是无关的;转换需要reinterpret_cast,C风格的转换或函数式转换

我认为这意味着我必须施展它,但是由于我没有这种语言的经验,我不知道正确的格式或正确的方法,并研究它自从GL更新以来,我没有真正帮助过,我发现使用更新的glGetStringi推荐的大多数回复,以及我尝试过的其他一些无效的回复。

如果有人介意帮助我,我会非常感激,下面是我的代码的副本,错误即将出现" P = glGetString(GL_EXTENSIONS);"

#include <stdlib.h>
#include <stdio.h>
#include <windows.h>
#include <gl\gl.h>
#include <gl\glu.h>
#include <gl\glaux.h>

#define GL_MAX_TEXTURE_UNITS              0x84E2
#define APIENTRYP APIENTRY *
#define PADDR(functype,funcname) (funcname = (functype) wglGetProcAddress( #funcname ))
#define GLAPI extern


typedef void (APIENTRYP PFNGL) (void);
typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFEREXTPROC) (GLuint);
typedef void (APIENTRYP PFNGLBINDRENDERBUFFEREXTPROC) (GLenum target, GLuint renderbuffer);
typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFEREXTPROC) (GLuint framebuffer);
typedef void (APIENTRYP PFNGLBINDFRAMEBUFFEREXTPROC) (GLenum target, GLuint framebuffer);

PFNGL glActiveTexture;
PFNGL glMultiTexCoord2f;
PFNGL glTexImage3D;
PFNGLISRENDERBUFFEREXTPROC glIsRenderbufferEXT;
PFNGLBINDRENDERBUFFEREXTPROC glBindRenderbufferEXT;
PFNGLISFRAMEBUFFEREXTPROC glIsFramebufferEXT;
PFNGLBINDFRAMEBUFFEREXTPROC glBindFramebufferEXT;


void main(int argc, char **argv){
 const char *p;
 GLint naux,nlights,maxtxsize,maxviewsize[2],maxtxunits;
 auxInitDisplayMode(AUX_SINGLE | AUX_RGBA);
 auxInitPosition(0,0,400,400);
 auxInitWindow(argv[0]);
 printf("OpenGL Version:  %s\n", glGetString(GL_VERSION)); 
 printf("OpenGL Vendor :  %s\n", glGetString(GL_VENDOR)); 
 printf("OpenGL Renderer: %s\n", glGetString(GL_RENDERER)); 
 printf("\nGL Extensions Supported:\n\n");
 p=glGetString(GL_EXTENSIONS);
 while(*p != 0){
  putchar(*p); if(*p == ' ')printf("\n");
  p++;
 }
 glGetIntegerv(GL_AUX_BUFFERS,&naux);
 printf("No of aux buffers %ld\n",naux);
 glGetIntegerv(GL_MAX_LIGHTS,&nlights);
 printf("Max number of lights %ld\n",nlights);
 glGetIntegerv(GL_MAX_TEXTURE_SIZE,&maxtxsize);
 printf("Max texture size %ld\n",maxtxsize);
 glGetIntegerv(GL_MAX_TEXTURE_UNITS,&maxtxunits);
 printf("Max texture units %ld\n",maxtxunits);
 glGetIntegerv(GL_MAX_VIEWPORT_DIMS,maxviewsize);
 printf("Max viewsize %ld %ld\n",maxviewsize[0],maxviewsize[1]);
 printf("\n");
 PADDR(PFNGL, glActiveTexture); printf("Active texture function ");
 if(glActiveTexture == NULL)printf("Not found\n"); else printf("OK\n");
 PADDR(PFNGL, glMultiTexCoord2f); printf("MultiTex texture function ");
 if(glMultiTexCoord2f == NULL)printf("Not found\n"); else printf("OK\n");
 PADDR(PFNGL, glTexImage3D); printf("TexImage3D texture function ");
 if(glTexImage3D == NULL)printf("Not found\n"); else printf("OK\n");
 PADDR(PFNGLISRENDERBUFFEREXTPROC,glIsRenderbufferEXT); printf("IsRenderbuffer function ");
 if(glIsRenderbufferEXT == NULL)printf("Not found\n"); else printf("OK\n");
 PADDR(PFNGLBINDRENDERBUFFEREXTPROC, glBindRenderbufferEXT); printf("BindRenderbuffer function ");
 if(glBindRenderbufferEXT == NULL)printf("Not found\n"); else printf("OK\n");
 PADDR(PFNGLISFRAMEBUFFEREXTPROC,glIsFramebufferEXT); printf("IsFramebuffer function ");
 if(glIsFramebufferEXT == NULL)printf("Not found\n"); else printf("OK\n");
 PADDR(PFNGLBINDFRAMEBUFFEREXTPROC, glBindFramebufferEXT); printf("BindFramebuffer function ");
 if(glBindFramebufferEXT == NULL)printf("Not found\n"); else printf("OK\n");


 //getch();
 glFlush();
}

0 个答案:

没有答案