2016-06-12 79 views
3

我想創建一個OpenGL + SDL2程序,並使用Emscripten進行編譯。但不幸的是,我不能甚至開始,因爲我得到一個錯誤的包括:不同類型的Typedef重定義(Emscripten SDL2 + OpenGL)

#include <iostream> 
#include <string> 

#include <emscripten.h> 

#include <SDL.h> 
#include <SDL_image.h> 
#include <SDL_ttf.h> 

#define GLFW_INCLUDE_ES2 
#include <GL/glew.h> 
#include <SDL_opengles2.h> 
#include <GL/glu.h> 

的錯誤是:

D:\Emscripten\emscripten\1.35.0\system\include\GLES2/gl2.h:39:26: error: 
     typedef redefinition with different types ('khronos_ssize_t' (aka 'long') 
     vs 'ptrdiff_t' (aka 'int')) 
typedef khronos_ssize_t GLsizeiptr; 

#define GLFW_INCLUDE_ES2線以後增加了,但它並沒有解決問題。

我用這個參數編譯:

USE_SDL=2 -s USE_SDL_IMAGE=2 -s SDL2_IMAGE_FORMATS=['png'] -s USE_SDL_TTF=2 
+0

出於好奇:爲什麼使用C++程序一個C API的圖形?像SFML這樣的圖形api更適用於C++程序。 – Boiethios

回答

1

,GLEW的官方版本不支持OpenGL ES可言,只有桌面的OpenGL(OpenGLES是移動設備,儘管它仍然可以大多數桌面上工作電腦,但glew不會與它兼容)

所以,你需要使用經典的OpenGL(不會在手機上工作)或擺脫笨拙。

請注意,一些非官方的glew叉會存在,如Linaro的glew-es,它們支持OpenGL ES。

積分奧術工程師,看到他的答案在這裏:https://stackoverflow.com/a/31474052/5085551

相關問題