Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Typedef redefinition with different types (Emscripten SDL2+OpenGL)

I would like to create an OpenGL+SDL2 program, and compile it using Emscripten. But unfortunately I can not even start it, because I get an error at the includes:

#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>

The error is:

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;

The #define GLFW_INCLUDE_ES2 line was added later, but it haven't solved the issue.

I compile it using this parameters:

USE_SDL=2 -s USE_SDL_IMAGE=2 -s SDL2_IMAGE_FORMATS=['png'] -s USE_SDL_TTF=2
like image 495
Iter Ator Avatar asked Jan 22 '26 19:01

Iter Ator


1 Answers

The official version of glew does not support OpenGL ES at all, only desktop OpenGL (OpenGLES is for mobile devices, despite that it can still work on most desktop computers but glew is not made to be compatible with it)

So you need to either use classic OpenGL (won't work on mobile) or get rid of glew.

Note that some unofficial forks of glew exist, such as Linaro's glew-es, that do support OpenGL ES.

Credits to Arcane Engineer, see his answer here: https://stackoverflow.com/a/31474052/5085551

like image 77
VB_overflow Avatar answered Jan 24 '26 11:01

VB_overflow