SDL-emscripten icon indicating copy to clipboard operation
SDL-emscripten copied to clipboard

CMake fails to build any video devices

Open mtsr opened this issue 10 years ago • 4 comments

Building with cmake fails to build any video devices (see below). This means SDL_Init(SDL_INIT_VIDEO) fails with "No video device available". When listing them only dummy shows up. This is confirmed by the cmake log:

--   VIDEO_COCOA            (Wanted: OFF): OFF
--   VIDEO_DIRECTFB         (Wanted: OFF): OFF
--   VIDEO_DUMMY            (Wanted: ON): ON
--   VIDEO_MIR              (Wanted: ON): OFF
--   VIDEO_OPENGL           (Wanted: ON): OFF
--   VIDEO_OPENGLES         (Wanted: ON): OFF
--   VIDEO_WAYLAND          (Wanted: ON): OFF
--   VIDEO_X11              (Wanted: ON): OFF
--   VIDEO_X11_XCURSOR      (Wanted: ON): OFF
--   VIDEO_X11_XINERAMA     (Wanted: ON): OFF
--   VIDEO_X11_XINPUT       (Wanted: ON): OFF
--   VIDEO_X11_XRANDR       (Wanted: ON): OFF
--   VIDEO_X11_XSCRNSAVER   (Wanted: ON): OFF
--   VIDEO_X11_XSHAPE       (Wanted: ON): OFF
--   VIDEO_X11_XVM          (Wanted: ON): OFF

mtsr avatar Jul 24 '14 13:07 mtsr

Looks like the Emscripten path in CMake doesn't check for any video devices. Try dropping in a line

CheckOpenGLESX11()

inside this if (EMSCRIPTEN) section here: https://github.com/gsathya/SDL-emscripten/blob/master/CMakeLists.txt#L666

Does that help?

juj avatar Jul 24 '14 16:07 juj

That helps, at least gles2 is now being included, but there are still no devices available. I think SDL_VIDEO_DRIVER_EMSCRIPTEN is not set.

Edit: Yep, that's got something to do with it. I've tried deleting the incorrect SDL_config.h in the include dir, but that doesn't help, even though the SDL_config.h in the build dir has #define SDL_VIDEO_DRIVER_EMSCRIPTEN.

mtsr avatar Jul 24 '14 18:07 mtsr

Ok, I'm leaving CMake alone for now.

mtsr avatar Jul 24 '14 20:07 mtsr

(Didn't notice these issues)

Part ot the fix for this is changing the checks in the emscripten block to actually enable the backends:

  if(SDL_AUDIO)
    set(SDL_AUDIO_DRIVER_EMSCRIPTEN 1)
    file(GLOB EM_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/emscripten/*.c)
    set(SOURCE_FILES ${SOURCE_FILES} ${EM_AUDIO_SOURCES})
    set(HAVE_SDL_AUDIO TRUE)
  endif()
  if(SDL_FILESYSTEM)
    set(SDL_FILESYSTEM_EMSCRIPTEN 1)
    file(GLOB EM_FILESYSTEM_SOURCES ${SDL2_SOURCE_DIR}/src/filesystem/emscripten/*.c)
    set(SOURCE_FILES ${SOURCE_FILES} ${EM_FILESYSTEM_SOURCES})
    set(HAVE_SDL_FILESYSTEM TRUE)
  endif()
  if(SDL_JOYSTICK)
    set(SDL_JOYSTICK_EMSCRIPTEN 1)
    file(GLOB EM_JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/emscripten/*.c)
    set(SOURCE_FILES ${SOURCE_FILES} ${EM_JOYSTICK_SOURCES})
    set(HAVE_SDL_JOYSTICK TRUE)
  endif()
  if(SDL_POWER)
    set(SDL_POWER_EMSCRIPTEN 1)
    file(GLOB EM_POWER_SOURCES ${SDL2_SOURCE_DIR}/src/power/emscripten/*.c)
    set(SOURCE_FILES ${SOURCE_FILES} ${EM_POWER_SOURCES})
    set(HAVE_SDL_POWER TRUE)
  endif()
  if(SDL_VIDEO)
    set(SDL_VIDEO_DRIVER_EMSCRIPTEN 1)
    file(GLOB EM_VIDEO_SOURCES ${SDL2_SOURCE_DIR}/src/video/emscripten/*.c)
    set(SOURCE_FILES ${SOURCE_FILES} ${EM_VIDEO_SOURCES})
    set(HAVE_SDL_VIDEO TRUE)

    #enable gles
    if(VIDEO_OPENGLES)
      set(SDL_VIDEO_OPENGL_EGL 1)
      set(HAVE_VIDEO_OPENGLES TRUE)
      set(SDL_VIDEO_OPENGL_ES 1)
      set(SDL_VIDEO_RENDER_OGL_ES 1)
    endif()
  endif()

The other part is: Daft-Freak@5825841694523308f3b2d707323f7ee3e9e1d2b7

Daft-Freak avatar Aug 10 '14 09:08 Daft-Freak