【发布时间】:2016-06-12 14:11:17
【问题描述】:
我想创建一个 OpenGL+SDL2 程序,并使用 Emscripten 编译它。但不幸的是,我什至无法启动它,因为我在包含时收到错误:
#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
【问题讨论】:
-
出于好奇:为什么在 C++ 程序中使用 C 图形 API?像 SFML 这样的图形 API 更适合 C++ 程序。
标签: c++ opengl-es-2.0 sdl-2 glew emscripten