我有一个项目,我首先使用gcc构建gl3w.c
,然后使用g ++构建自己的OGLGraphics.cpp
文件。 Gcc成功编译gl3w.c
但是当g ++尝试编译包含gl3w.h
的文件时,我收到了以下错误:
In file included from /mnt/hgfs/grace/src/grace-output/graphics/OGLGraphics.cpp:22:0:
/mnt/hgfs/grace/src/grace-output/include/GL3/gl3w.h:69:8: error: ‘PFNGLDRAWARRAYSPROC’ does not name a type
/mnt/hgfs/grace/src/grace-output/include/GL3/gl3w.h:70:8: error: ‘PFNGLDRAWELEMENTSPROC’ does not name a type
/mnt/hgfs/grace/src/grace-output/include/GL3/gl3w.h:71:8: error: ‘PFNGLGETPOINTERVPROC’ does not name a type
/mnt/hgfs/grace/src/grace-output/include/GL3/gl3w.h:72:8: error: ‘PFNGLPOLYGONOFFSETPROC’ does not name a type
/mnt/hgfs/grace/src/grace-output/include/GL3/gl3w.h:73:8: error: ‘PFNGLCOPYTEXIMAGE1DPROC’ does not name a type
/mnt/hgfs/grace/src/grace-output/include/GL3/gl3w.h:74:8: error: ‘PFNGLCOPYTEXIMAGE2DPROC’ does not name a type
/mnt/hgfs/grace/src/grace-output/include/GL3/gl3w.h:75:8: error: ‘PFNGLCOPYTEXSUBIMAGE1DPROC’ does not name a type
/mnt/hgfs/grace/src/grace-output/include/GL3/gl3w.h:76:8: error: ‘PFNGLCOPYTEXSUBIMAGE2DPROC’ does not name a type
/mnt/hgfs/grace/src/grace-output/include/GL3/gl3w.h:77:8: error: ‘PFNGLTEXSUBIMAGE1DPROC’ does not name a type
/mnt/hgfs/grace/src/grace-output/include/GL3/gl3w.h:78:8: error: ‘PFNGLTEXSUBIMAGE2DPROC’ does not name a type
/mnt/hgfs/grace/src/grace-output/include/GL3/gl3w.h:79:8: error: ‘PFNGLBINDTEXTUREPROC’ does not name a type
/mnt/hgfs/grace/src/grace-output/include/GL3/gl3w.h:80:8: error: ‘PFNGLDELETETEXTURESPROC’ does not name a type
/mnt/hgfs/grace/src/grace-output/include/GL3/gl3w.h:81:8: error: ‘PFNGLGENTEXTURESPROC’ does not name a type
/mnt/hgfs/grace/src/grace-output/include/GL3/gl3w.h:82:8: error: ‘PFNGLISTEXTUREPROC’ does not name a type
我不知道为什么它适用于C文件但不适用于C ++?
答案 0 :(得分:6)
您是否遵循了GL3W自述文件中列出的程序?具体来说,在任何OpenGL文件之前,包括gl3w.h
首先的部分。
哦,在window.h
之前,可以包括gl.h
。
答案 1 :(得分:0)
extern PFNGLDRAWARRAYSPROC gl3wDrawArrays; <—— unknown type name PFNGLDRAWARRAYSPROC
此错误是由代码中包含#include <OpenGL/gl.h>
引起的,例如GLTriangleBatch.h。如果用#include“GL / gl3w.h”代替,这是OpenGL 3/4调用,那么这将删除错误。我认为不同版本的OpenGL调用之间存在冲突,这会导致未知类型错误当我试图将SuperBible 5代码移植到SB6中时,我自己遇到了同样的问题。