gl.h
glew.h
gl.h included before glew.h
如果包含了glew,就不用再包含gl.h
包含的地方
- cocos/cocos2d.h
- cocos/platform/CCGL.h
- CCGL-win32.h
#ifndef __CCGL_H__
#define __CCGL_H__
#include "platform/CCPlatformConfig.h"
#if CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
#include "GL/glew.h"
#define CC_GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
#endif // __CCGL_H__
- glew.h
#if defined(__gl_h_) || defined(__GL_H__) || defined(__X_GL_H)
#error gl.h included before glew.h
#endif
#if defined(__glext_h_) || defined(__GLEXT_H_)
#error glext.h included before glew.h
#endif
#if defined(__gl_ATI_h_)
#error glATI.h included before glew.h
#endif
最终解决办法
#include <qsize.h>
// 对顺序有要求
#ifdef Q_OS_WIN
#include "cocos2d.h"
#include <qopenglwidget.h>
#include <qopenglfunctions.h>
#include <qopenglextrafunctions.h>
#else
// todo 验证mac
#include <qopenglwidget.h>
#include <qopenglfunctions.h>
#include <qopenglextrafunctions.h>
#include "cocos2d.h"
#endif
#include <qsize.h>是一个无关的头文件,在引入后续OpenGL相关头文件的时候,必须有引入一个头文件,否则也会报错,所以我就随便写了一个无关的头文件,具体原因为啥,我也不清楚