Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions Docs/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,15 @@ try:

supermodel game.zip -res=1920,1080 -fullscreen

Rendering resolution is controlled independently with '-render-scale'.
The default value of 0 renders at the output surface resolution.
Values 1 through 8 select scales based on the origianl Model 3 resolution.
In standard aspect mode, these produce targets from 496x384 through 3968x3072.
In wide-screen mode, the target height remains 384 times the selected scale while its
width follows the output aspect ratio; for example, scale 3 at 16:9 renders at 2048x1152.
The result is then scaled to the output surface resolution.
This setting does not affect the 2D layers or Supersampling multiplying with '-ss'.

Video settings may also be specified globally or on a per-game basis in the
configuration file, described elsewhere in this manual.

Expand Down Expand Up @@ -1234,6 +1243,19 @@ not. All options are case sensitive.

----------------

Option: -render-scale=<n>

Description: Sets the New3D rendering resolution. Valid values are 0
through 8 and the default is 0, which renders at the
output-surface resolution. Positive values select fixed
integer scales based on a height of 384 pixels. Standard
aspect mode uses a width of 496 pixels per scale; wide-
screen mode derives the width from the output aspect ratio.
This setting works with the New3D rendering engine and is
independent of supersampling.

----------------

Option: -crtcolors=<mode>

Description: Emulates other regional TV standards of the time.
Expand Down Expand Up @@ -1423,6 +1445,22 @@ All settings are case sensitive.

----------------

Name: RenderScale

Argument: Integer.

Description: Controls the New3D rendering resolution. The default is 0
and valid values are 0 through 8. A value of 0 uses the
output-surface resolution. Positive values select fixed
integer scales based on a height of 384 pixels. Standard
aspect mode uses a width of 496 pixels per scale; wide-
screen mode derives the width from the output aspect ratio.
This setting works with the New3D rendering engine and is
independent of Supersampling.
Equivalent to the '-render-scale' command line option.

----------------

Name: FragmentShader
VertexShader

Expand Down
33 changes: 32 additions & 1 deletion Makefiles/Makefile.UNIX
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,27 @@ PKG_TYPE = tgz
#
include Makefiles/Options.inc

#
# Optional OpenGL ES 3.2 build. This is intentionally supported only by the
# UNIX/Linux makefile; macOS uses desktop OpenGL.
#
GLES =
ifneq ($(filter $(strip $(GLES)),0 1),$(strip $(GLES)))
override GLES =
endif
SUPERMODEL_GLES_BUILD =

#
# Optional SDL Wayland-preferred build. SDL still owns the platform backend;
# no direct Wayland libraries are required by Supermodel.
#
WAYLAND =
ifneq ($(words $(strip $(WAYLAND))),1)
override WAYLAND =
else ifneq ($(filter $(strip $(WAYLAND)),0 1),$(strip $(WAYLAND)))
override WAYLAND =
endif

#
# Toolchain
#
Expand All @@ -71,8 +92,18 @@ SDL2_LIBS += -lSDL2_net
#

PLATFORM_CXXFLAGS = $(SDL2_CFLAGS) -O3
PLATFORM_LDFLAGS = $(SDL2_LIBS) -lGL -lGLU -lz -lm -lstdc++ -lpthread
ifeq ($(strip $(WAYLAND)),1)
PLATFORM_CXXFLAGS += -DSUPERMODEL_PREFER_WAYLAND
endif
ifeq ($(strip $(GLES)),1)
SUPERMODEL_GLES_BUILD = 1
PLATFORM_CXXFLAGS += -DSUPERMODEL_GLES -DIMGUI_IMPL_OPENGL_ES3
PLATFORM_LDFLAGS = $(SDL2_LIBS) -lGLESv2 -lz -lm -lstdc++ -lpthread
else
PLATFORM_LDFLAGS = $(SDL2_LIBS) -lGL -lGLU -lz -lm -lstdc++ -lpthread
endif
PLATFORM_BINARY_EXTENSION =
PLATFORM_TRACK_BUILD_CONFIG = 1


###############################################################################
Expand Down
51 changes: 45 additions & 6 deletions Makefiles/Rules.inc
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
# Output Locations
###############################################################################

OBJ_DIR = obj$(strip $(BITS))
BIN_DIR = bin$(strip $(BITS))
OBJ_DIR = obj$(strip $(BITS))$(PLATFORM_BUILD_SUFFIX)
BIN_DIR = bin$(strip $(BITS))$(PLATFORM_BUILD_SUFFIX)

SUPERMODEL_BINARY = supermodel$(PLATFORM_BINARY_EXTENSION)
DISASSEMBLER_BINARY = ppcd$(PLATFORM_BINARY_EXTENSION)
Expand Down Expand Up @@ -79,7 +79,11 @@ endif
#
# Construct the compiler (C and C++) and linker flags
#
COMMON_CFLAGS = -c $(ARCH) $(OPT) $(WARN) $(addprefix -I,$(sort $(INCLUDE_DIRS))) -DGLEW_STATIC $(SUPERMODEL_BUILD_FLAGS)
GLEW_CFLAGS = -DGLEW_STATIC
ifeq ($(strip $(SUPERMODEL_GLES_BUILD)),1)
GLEW_CFLAGS =
endif
COMMON_CFLAGS = -c $(ARCH) $(OPT) $(WARN) $(addprefix -I,$(sort $(INCLUDE_DIRS))) $(GLEW_CFLAGS) $(SUPERMODEL_BUILD_FLAGS)
CFLAGS = $(COMMON_CFLAGS) $(CSTD)
CXXFLAGS = $(PLATFORM_CXXFLAGS) $(COMMON_CFLAGS) $(CXXSTD)
LDFLAGS = -o $(BIN_DIR)/$(SUPERMODEL_BINARY) $(PLATFORM_LDFLAGS) $(LDOPT)
Expand All @@ -98,7 +102,7 @@ SRC_FILES = \
Src/Pkgs/ioapi.cpp \
Src/Model3/93C46.cpp \
Src/JTAG.cpp \
Src/Pkgs/glew.cpp \
Src/Pkgs/glew.c \
Src/Graphics/Shader.cpp \
Src/Model3/Real3D.cpp \
Src/Graphics/New3D/GLSLShader.cpp \
Expand Down Expand Up @@ -177,15 +181,20 @@ SRC_FILES = \
Src/Network/SimNetBoard.cpp \
$(PLATFORM_SRC_FILES)

ifeq ($(strip $(SUPERMODEL_GLES_BUILD)),1)
SRC_FILES := $(filter-out Src/Pkgs/glew.c,$(SRC_FILES))
endif

ifeq (,$(findstring -DSUPERMODEL_OSX,$(PLATFORM_CXXFLAGS)))
# -DSUPERMODEL_OSX not present: we are not compiling for macOS and can
# therefore include the legacy renderer
ifneq ($(strip $(SUPERMODEL_GLES_BUILD)),1)
# macOS and OpenGL ES builds cannot include the legacy renderer
SRC_FILES += \
Src/Graphics/Legacy3D/Error.cpp \
Src/Graphics/Legacy3D/Legacy3D.cpp \
Src/Graphics/Legacy3D/Models.cpp \
Src/Graphics/Legacy3D/TextureRefs.cpp
endif
endif

ifeq ($(strip $(ENABLE_DEBUGGER)),1)
SRC_FILES += \
Expand Down Expand Up @@ -339,6 +348,36 @@ $(OBJ_DIR): | $(PLATFORM_DIRS)
$(info Creating directory : $(OBJ_DIR))
$(SILENT)mkdir $(OBJ_DIR)

ifeq ($(strip $(PLATFORM_TRACK_BUILD_CONFIG)),1)
BUILD_CONFIG_STAMP = $(OBJ_DIR)/.build-config

.PHONY: force_build_config
force_build_config:

$(BUILD_CONFIG_STAMP): force_build_config | $(OBJ_DIR)
$(SILENT)printf '%s\n' \
'BITS=$(strip $(BITS))' \
'DEBUG=$(strip $(DEBUG))' \
'EXTRA_DEBUG=$(strip $(EXTRA_DEBUG))' \
'ENABLE_DEBUGGER=$(strip $(ENABLE_DEBUGGER))' \
'GLES=$(strip $(GLES))' \
'WAYLAND=$(strip $(WAYLAND))' \
'CC=$(CC)' \
'CXX=$(CXX)' \
'CFLAGS=$(strip $(CFLAGS))' \
'CXXFLAGS=$(strip $(CXXFLAGS))' \
'LDFLAGS=$(strip $(LDFLAGS))' \
'SRC_FILES=$(strip $(SRC_FILES))' > $@.tmp
$(SILENT)if test -r $@ && cmp -s $@.tmp $@; then \
rm -f $@.tmp; \
else \
rm -f $(OBJ_FILES) $(AUTODEPS); \
mv -f $@.tmp $@; \
fi

$(OBJ_FILES): $(BUILD_CONFIG_STAMP)
endif


###############################################################################
# Rules
Expand Down
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,45 @@ And then build Supermodel:
make -f Makefiles/Makefile.UNIX
```

The default build leaves video-driver selection to SDL, preserving the existing
X11 and other platform behavior. To build a variant that prefers native
Wayland when available, use:

```
make -f Makefiles/Makefile.UNIX WAYLAND=1
```

It requires an SDL2 installation built with Wayland support, but Supermodel
does not link directly to Wayland libraries. If SDL cannot initialize its
native Wayland video backend, the application retries SDL's normal video-driver
selection. Window or OpenGL context failures after successful backend
initialization are reported normally; set `SDL_VIDEODRIVER=x11` to force the
X11 backend in that case. An explicit `SDL_VIDEODRIVER` environment variable
always takes precedence, so either backend can be selected manually:

```
SDL_VIDEODRIVER=wayland ./bin/supermodel
SDL_VIDEODRIVER=x11 ./bin/supermodel
```

Wayland compositors control fullscreen output modes and window placement.
Consequently, native Wayland uses compositor fullscreen and does not attempt
the custom 57.524 Hz X11 display-mode switch.

Desktop OpenGL is used by default. On Linux/UNIX systems with OpenGL ES development headers and libraries (for example, `libgles2-mesa-dev` on Ubuntu), build the GLES version with:

```
make -f Makefiles/Makefile.UNIX GLES=1
```

Wayland preference and GLES can be enabled together:

```
make -f Makefiles/Makefile.UNIX WAYLAND=1 GLES=1
```

The GLES build requires an OpenGL ES 3.1-capable display/device and uses the New3D renderer. Legacy3D is not supported. Triangle rendering is used by default and supports ES 3.1 or newer. `-quad-rendering` requires the ES 3.2 geometry-shader path; if an ES 3.2 context cannot be created, Supermodel retries ES 3.1 and automatically disables quad rendering. Quad rendering may also be slower on some tile-based ARM GPUs. macOS builds continue to use desktop OpenGL.

### macOS

Ensure Apple's Xcode Command Line Tools are installed:
Expand Down
2 changes: 1 addition & 1 deletion Src/Graphics/FBO.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef _FBO_H_
#define _FBO_H_

#include <GL/glew.h>
#include "Graphics/GL.h"

class FBO
{
Expand Down
10 changes: 10 additions & 0 deletions Src/Graphics/GL.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#ifndef INCLUDED_GRAPHICS_GL_H
#define INCLUDED_GRAPHICS_GL_H

#ifdef SUPERMODEL_GLES
#include <GLES3/gl32.h>
#else
#include <GL/glew.h>
#endif

#endif // INCLUDED_GRAPHICS_GL_H
62 changes: 62 additions & 0 deletions Src/Graphics/GLSL.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#ifndef INCLUDED_GRAPHICS_GLSL_H
#define INCLUDED_GRAPHICS_GLSL_H

#include "Graphics/GL.h"
#include <string>

namespace GLSL
{

enum class ShaderStage
{
Vertex,
Geometry,
Fragment
};

inline const char *VersionDirective()
{
#ifdef SUPERMODEL_GLES
// The vendored ImGui backend selects its ES shader variant specifically for 300.
// GLSL ES 3.00 shaders are valid on every supported OpenGL ES context.
return "#version 300 es";
#else
return "#version 410";
#endif
}

inline std::string PrepareSource(const char *source, ShaderStage stage)
{
std::string shaderSource(source == nullptr ? "" : source);

#ifdef SUPERMODEL_GLES
const size_t versionPos = shaderSource.find("#version");
if (versionPos != std::string::npos)
{
const size_t lineEnd = shaderSource.find('\n', versionPos);
shaderSource.erase(versionPos, lineEnd == std::string::npos ? std::string::npos : lineEnd - versionPos + 1);
}

GLint majorVersion = 0;
GLint minorVersion = 0;
glGetIntegerv(GL_MAJOR_VERSION, &majorVersion);
glGetIntegerv(GL_MINOR_VERSION, &minorVersion);

const int version = majorVersion * 100 + minorVersion * 10;
std::string header = version >= 320 ? "#version 320 es\n" : "#version 310 es\n";

header += "#define SUPERMODEL_GLES 1\nprecision highp float;\nprecision highp int;\n";
if (stage == ShaderStage::Fragment)
{
header += "precision highp sampler2D;\nprecision highp usampler2D;\n";
}
return header + shaderSource;
#else
(void)stage;
return shaderSource;
#endif
}

} // namespace GLSL

#endif // INCLUDED_GRAPHICS_GLSL_H
2 changes: 1 addition & 1 deletion Src/Graphics/Legacy3D/Legacy3D.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

#include "TextureRefs.h"
#include "Graphics/IRender3D.h"
#include <GL/glew.h>
#include "Graphics/GL.h"
#include "Util/NewConfig.h"
#include "Types.h"

Expand Down
Loading