Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

emscripten: detect and start configuring accordingly #1609

Merged
merged 1 commit into from Oct 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions module/glcompat.h
Expand Up @@ -29,6 +29,10 @@

#define RENPY_GLES_2

#elif defined EMSCRIPTEN

#define RENPY_GLES_2

#elif defined RASPBERRY_PI

#define RENPY_GLES_2
Expand Down
8 changes: 6 additions & 2 deletions module/setup.py
Expand Up @@ -55,7 +55,7 @@ def setup_env(name):
setup_env("CXX")

import setuplib
from setuplib import android, ios, raspi, include, library, cython, cmodule, copyfile, find_unnecessary_gen
from setuplib import android, ios, emscripten, raspi, include, library, cython, cmodule, copyfile, find_unnecessary_gen

# These control the level of optimization versus debugging.
setuplib.extra_compile_args = [ "-Wno-unused-function" ]
Expand Down Expand Up @@ -189,6 +189,10 @@ def setup_env(name):
glew_libs = [ 'GLESv2', 'z', 'm' ]
gl2_only = True
egl = "egl_none.c"
elif emscripten:
glew_libs = []
gl2_only = True
egl = "egl_none.c"
elif raspi:
glew_libs = [ 'SDL2', 'GLESv2', 'EGL', 'z', 'm' ]
gl2_only = True
Expand All @@ -212,7 +216,7 @@ def setup_env(name):
cython("renpy.gl.glrtt_copy", libs=glew_libs)
cython("renpy.gl.glrtt_fbo", libs=glew_libs)

if not (android or ios):
if not (android or ios or emscripten):
# renpy.angle
def anglecopy(fn):
copyfile("renpy/gl/" + fn, "renpy/angle/" + fn, "DEF ANGLE = False", "DEF ANGLE = True")
Expand Down
7 changes: 5 additions & 2 deletions module/setuplib.py
Expand Up @@ -39,6 +39,9 @@
# True of we're building on raspberry pi.
raspi = "RENPY_RASPBERRY_PI" in os.environ

# True of we're building with emscripten.
emscripten = "RENPY_EMSCRIPTEN" in os.environ

# Is coverage enabled?
coverage = "RENPY_COVERAGE" in os.environ

Expand Down Expand Up @@ -92,7 +95,7 @@ def include(header, directory=None, optional=True):
If given, returns False rather than abandoning the process.
"""

if android or ios:
if android or ios or emscripten:
return True

for i in install:
Expand Down Expand Up @@ -131,7 +134,7 @@ def library(name, optional=False):
rather than reporting an error.
"""

if android or ios:
if android or ios or emscripten:
return True

for i in install:
Expand Down
5 changes: 4 additions & 1 deletion renpy/__init__.py
Expand Up @@ -70,6 +70,7 @@
linux = False
android = False
ios = False
emscripten = False

# Should we enable experimental features and debugging?
experimental = "RENPY_EXPERIMENTAL" in os.environ
Expand Down Expand Up @@ -121,11 +122,13 @@ class OSVERSIONINFOEXW(ctypes.Structure):
macintosh = True
elif "ANDROID_PRIVATE" in os.environ:
android = True
elif sys.platform == 'emscripten':
emscripten = True
else:
linux = True

# A flag that's true if we're on a smartphone or tablet-like platform.
mobile = android or ios
mobile = android or ios or emscripten

# A flag that's set to true if the game directory is bundled inside a mac app.
macapp = False
Expand Down
3 changes: 3 additions & 0 deletions renpy/config.py
Expand Up @@ -27,6 +27,7 @@

import collections
import os
import renpy

# Can we add more config variables?
locked = False
Expand Down Expand Up @@ -806,6 +807,8 @@

# Should the audio periodic callback run in its own thread.
audio_periodic_thread = True
if renpy.emscripten:
audio_periodic_thread = False

# A list of fonts to preload on Ren'Py startup.
preload_fonts = [ ]
Expand Down
2 changes: 2 additions & 0 deletions renpy/exports.py
Expand Up @@ -1783,6 +1783,8 @@ def version(tuple=False): # @ReservedAssignment
platform = "Android"
elif renpy.ios:
platform = "iOS"
elif sys.platform == "emscripten":
platform = "emscripten"
else:
platform = "Unknown"

Expand Down
2 changes: 1 addition & 1 deletion renpy/gl/gldraw.pyx
Expand Up @@ -557,7 +557,7 @@ cdef class GLDraw:

# Pick a texture environment subsystem.

if EGL or renpy.android or renpy.ios or (allow_shader and use_subsystem(
if EGL or renpy.android or renpy.ios or renpy.emscripten or (allow_shader and use_subsystem(
glenviron_shader,
"RENPY_GL_ENVIRON",
"shader",
Expand Down