mirror of
https://github.com/libretro/RetroArch
synced 2025-03-01 16:13:40 +00:00
Remove libretro-test-gl - moved to libretro-samples
This commit is contained in:
parent
ac355066ec
commit
dd139641b4
@ -1,171 +0,0 @@
|
||||
ifeq ($(platform),)
|
||||
platform = unix
|
||||
ifeq ($(shell uname -a),)
|
||||
platform = win
|
||||
else ifneq ($(findstring MINGW,$(shell uname -a)),)
|
||||
platform = win
|
||||
else ifneq ($(findstring Darwin,$(shell uname -a)),)
|
||||
platform = osx
|
||||
arch = intel
|
||||
ifeq ($(shell uname -p),powerpc)
|
||||
arch = ppc
|
||||
endif
|
||||
else ifneq ($(findstring win,$(shell uname -a)),)
|
||||
platform = win
|
||||
endif
|
||||
endif
|
||||
|
||||
# system platform
|
||||
system_platform = unix
|
||||
ifeq ($(shell uname -a),)
|
||||
EXE_EXT = .exe
|
||||
system_platform = win
|
||||
else ifneq ($(findstring Darwin,$(shell uname -a)),)
|
||||
system_platform = osx
|
||||
arch = intel
|
||||
ifeq ($(shell uname -p),powerpc)
|
||||
arch = ppc
|
||||
endif
|
||||
else ifneq ($(findstring MINGW,$(shell uname -a)),)
|
||||
system_platform = win
|
||||
endif
|
||||
|
||||
TARGET_NAME = testgl
|
||||
|
||||
ifeq ($(platform), unix)
|
||||
TARGET := $(TARGET_NAME)_libretro.so
|
||||
fpic := -fPIC
|
||||
SHARED := -shared -Wl,--version-script=link.T -Wl,--no-undefined
|
||||
GL_LIB := -lGL
|
||||
else ifneq (,$(findstring osx,$(platform)))
|
||||
TARGET := $(TARGET_NAME)_libretro.dylib
|
||||
fpic := -fPIC
|
||||
SHARED := -dynamiclib
|
||||
GL_LIB := -framework OpenGL
|
||||
CFLAGS += -DOSX
|
||||
ifeq ($(arch),ppc)
|
||||
CFLAGS += -D__ppc__ -DOSX_PPC
|
||||
endif
|
||||
OSXVER = `sw_vers -productVersion | cut -d. -f 2`
|
||||
OSX_LT_MAVERICKS = `(( $(OSXVER) <= 9)) && echo "YES"`
|
||||
fpic += -mmacosx-version-min=10.1
|
||||
else ifeq ($(platform), pi)
|
||||
TARGET := $(TARGET_NAME)_libretro.so
|
||||
fpic := -fPIC
|
||||
SHARED := -shared -Wl,--version-script=link.T -Wl,--no-undefined
|
||||
CFLAGS += -I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads -I/opt/vc/include/vmcs_host/linux
|
||||
GLES := 1
|
||||
LIBS += -L/opt/vc/lib
|
||||
else ifneq (,$(findstring ios,$(platform)))
|
||||
TARGET := $(TARGET_NAME)_libretro_ios.dylib
|
||||
fpic := -fPIC
|
||||
SHARED := -dynamiclib
|
||||
|
||||
ifeq ($(IOSSDK),)
|
||||
IOSSDK := $(shell xcodebuild -version -sdk iphoneos Path)
|
||||
endif
|
||||
|
||||
GL_LIB := -framework OpenGLES
|
||||
DEFINES := -DIOS
|
||||
CFLAGS += -DHAVE_OPENGLES $(DEFINES)
|
||||
CC = cc -arch armv7 -isysroot $(IOSSDK)
|
||||
ifeq ($(platform),ios9)
|
||||
CC += -miphoneos-version-min=8.0
|
||||
CFLAGS += -miphoneos-version-min=8.0
|
||||
else
|
||||
CC += -miphoneos-version-min=5.0
|
||||
CFLAGS += -miphoneos-version-min=5.0
|
||||
endif
|
||||
else ifneq (,$(findstring qnx,$(platform)))
|
||||
TARGET := $(TARGET_NAME)_libretro_qnx.so
|
||||
fpic := -fPIC
|
||||
SHARED := -shared -Wl,--version-script=link.T
|
||||
GL_LIB := -lGL
|
||||
|
||||
CC = qcc -Vgcc_ntoarmv7le
|
||||
AR = qcc -Vgcc_ntoarmv7le
|
||||
GL_LIB := -lGLESv2
|
||||
GLES := 1
|
||||
else ifneq (,$(findstring armv,$(platform)))
|
||||
CC = gcc
|
||||
TARGET := $(TARGET_NAME)_libretro.so
|
||||
fpic := -fPIC
|
||||
SHARED := -shared -Wl,--version-script=link.T -Wl,--no-undefined
|
||||
CFLAGS += -I.
|
||||
ifneq (,$(findstring gles,$(platform)))
|
||||
GLES := 1
|
||||
else
|
||||
GL_LIB := -lGL
|
||||
endif
|
||||
ifneq (,$(findstring cortexa8,$(platform)))
|
||||
CFLAGS += -marm -mcpu=cortex-a8
|
||||
else ifneq (,$(findstring cortexa9,$(platform)))
|
||||
CFLAGS += -marm -mcpu=cortex-a9
|
||||
endif
|
||||
CFLAGS += -marm
|
||||
ifneq (,$(findstring neon,$(platform)))
|
||||
CFLAGS += -mfpu=neon
|
||||
endif
|
||||
ifneq (,$(findstring softfloat,$(platform)))
|
||||
CFLAGS += -mfloat-abi=softfp
|
||||
else ifneq (,$(findstring hardfloat,$(platform)))
|
||||
CFLAGS += -mfloat-abi=hard
|
||||
endif
|
||||
CFLAGS += -DARM
|
||||
# emscripten
|
||||
else ifeq ($(platform), emscripten)
|
||||
TARGET := $(TARGET_NAME)_libretro_emscripten.bc
|
||||
else
|
||||
CC = gcc
|
||||
TARGET := $(TARGET_NAME)_libretro.dll
|
||||
SHARED := -shared -static-libgcc -static-libstdc++ -s -Wl,--version-script=link.T -Wl,--no-undefined
|
||||
GL_LIB := -lopengl32
|
||||
CFLAGS += -I..
|
||||
endif
|
||||
|
||||
ifeq ($(DEBUG), 1)
|
||||
CFLAGS += -O0 -g
|
||||
else
|
||||
CFLAGS += -O3
|
||||
endif
|
||||
|
||||
ifneq (,$(findstring qnx,$(platform)))
|
||||
CFLAGS += -Wc,-std=c99
|
||||
else
|
||||
CFLAGS += -std=gnu99
|
||||
endif
|
||||
|
||||
OBJECTS := libretro_gl_test.o ../../libretro-common/glsym/rglgen.o
|
||||
CFLAGS += -Wall -pedantic $(fpic)
|
||||
|
||||
ifeq ($(GLES), 1)
|
||||
CFLAGS += -DHAVE_OPENGLES -DHAVE_OPENGLES2
|
||||
ifeq ($(GLES31), 1)
|
||||
CFLAGS += -DHAVE_OPENGLES3 -DHAVE_OPENGLES_3_1
|
||||
else ifeq ($(GLES3), 1)
|
||||
CFLAGS += -DHAVE_OPENGLES3
|
||||
endif
|
||||
LIBS += -lGLESv2 # Still link against GLESv2 when using GLES3 API, at least on desktop Linux.
|
||||
OBJECTS += ../../libretro-common/glsym/glsym_es2.o
|
||||
else
|
||||
OBJECTS += ../../libretro-common/glsym/glsym_gl.o
|
||||
LIBS += $(GL_LIB)
|
||||
endif
|
||||
|
||||
ifeq ($(CORE), 1)
|
||||
CFLAGS += -DCORE
|
||||
endif
|
||||
|
||||
all: $(TARGET)
|
||||
|
||||
$(TARGET): $(OBJECTS)
|
||||
$(CC) $(fpic) $(SHARED) $(INCLUDES) -o $@ $(OBJECTS) $(LIBS) -lm $(EXTRA_GL_LIBS)
|
||||
|
||||
%.o: %.c
|
||||
$(CC) -I../../libretro-common/include $(CFLAGS) $(fpic) -c -o $@ $<
|
||||
|
||||
clean:
|
||||
rm -f $(OBJECTS) $(TARGET)
|
||||
|
||||
.PHONY: clean
|
||||
|
@ -1,33 +0,0 @@
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE := retro-test-gl
|
||||
|
||||
ifeq ($(TARGET_ARCH),arm)
|
||||
LOCAL_CFLAGS += -DANDROID_ARM
|
||||
LOCAL_ARM_MODE := arm
|
||||
endif
|
||||
|
||||
ifeq ($(TARGET_ARCH),x86)
|
||||
LOCAL_CFLAGS += -DANDROID_X86
|
||||
endif
|
||||
|
||||
ifeq ($(TARGET_ARCH),mips)
|
||||
LOCAL_CFLAGS += -DANDROID_MIPS
|
||||
endif
|
||||
|
||||
ifeq ($(GLES), 3)
|
||||
LOCAL_CFLAGS += -DHAVE_OPENGLES3 -DGLES3
|
||||
GLES_LIB := -lGLESv3
|
||||
else
|
||||
LOCAL_CFLAGS += -DHAVE_OPENGLES2 -DGLES3
|
||||
GLES_LIB := -lGLESv2
|
||||
endif
|
||||
|
||||
LOCAL_SRC_FILES += $(addprefix ../,$(wildcard *.c) ../../../libretro-common/glsym/rglgen.c ../../../libretro-common/glsym/glsym_es2.c)
|
||||
LOCAL_CFLAGS += -O2 -Wall -std=gnu99 -ffast-math -DHAVE_OPENGLES -I../../../libretro-common/include
|
||||
LOCAL_LDLIBS += $(GLES_LIB)
|
||||
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
|
@ -1,7 +0,0 @@
|
||||
APP_ABI := all
|
||||
ifeq ($(GLES), 3)
|
||||
APP_PLATFORM := android-18
|
||||
else
|
||||
APP_PLATFORM := android-9
|
||||
endif
|
||||
|
@ -1,588 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <glsym/glsym.h>
|
||||
|
||||
#include <libretro.h>
|
||||
|
||||
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
|
||||
static struct retro_hw_render_callback hw_render;
|
||||
|
||||
#if defined(HAVE_PSGL)
|
||||
#define RARCH_GL_FRAMEBUFFER GL_FRAMEBUFFER_OES
|
||||
#define RARCH_GL_FRAMEBUFFER_COMPLETE GL_FRAMEBUFFER_COMPLETE_OES
|
||||
#define RARCH_GL_COLOR_ATTACHMENT0 GL_COLOR_ATTACHMENT0_EXT
|
||||
#elif defined(OSX_PPC)
|
||||
#define RARCH_GL_FRAMEBUFFER GL_FRAMEBUFFER_EXT
|
||||
#define RARCH_GL_FRAMEBUFFER_COMPLETE GL_FRAMEBUFFER_COMPLETE_EXT
|
||||
#define RARCH_GL_COLOR_ATTACHMENT0 GL_COLOR_ATTACHMENT0_EXT
|
||||
#else
|
||||
#define RARCH_GL_FRAMEBUFFER GL_FRAMEBUFFER
|
||||
#define RARCH_GL_FRAMEBUFFER_COMPLETE GL_FRAMEBUFFER_COMPLETE
|
||||
#define RARCH_GL_COLOR_ATTACHMENT0 GL_COLOR_ATTACHMENT0
|
||||
#endif
|
||||
|
||||
#define BASE_WIDTH 320
|
||||
#define BASE_HEIGHT 240
|
||||
#ifdef HAVE_OPENGLES
|
||||
#define MAX_WIDTH 1024
|
||||
#define MAX_HEIGHT 1024
|
||||
#else
|
||||
#define MAX_WIDTH 2048
|
||||
#define MAX_HEIGHT 2048
|
||||
#endif
|
||||
|
||||
static unsigned width = BASE_WIDTH;
|
||||
static unsigned height = BASE_HEIGHT;
|
||||
|
||||
static GLuint prog;
|
||||
static GLuint vbo;
|
||||
|
||||
#if defined(CORE)
|
||||
static bool context_alive;
|
||||
static bool multisample_fbo;
|
||||
static unsigned multisample;
|
||||
static GLuint vao;
|
||||
|
||||
static GLuint fbo;
|
||||
static GLuint rbo_color, rbo_depth_stencil;
|
||||
|
||||
static const char *vertex_shader[] = {
|
||||
"#version 140\n"
|
||||
"uniform mat4 uMVP;",
|
||||
"in vec2 aVertex;",
|
||||
"in vec4 aColor;",
|
||||
"out vec4 color;",
|
||||
"void main() {",
|
||||
" gl_Position = uMVP * vec4(aVertex, 0.0, 1.0);",
|
||||
" color = aColor;",
|
||||
"}",
|
||||
};
|
||||
|
||||
static const char *fragment_shader[] = {
|
||||
"#version 140\n"
|
||||
"in vec4 color;",
|
||||
"out vec4 FragColor;\n"
|
||||
"void main() {",
|
||||
" FragColor = color;",
|
||||
"}",
|
||||
};
|
||||
#else
|
||||
static const char *vertex_shader[] = {
|
||||
"uniform mat4 uMVP;",
|
||||
"attribute vec2 aVertex;",
|
||||
"attribute vec4 aColor;",
|
||||
"varying vec4 color;",
|
||||
"void main() {",
|
||||
" gl_Position = uMVP * vec4(aVertex, 0.0, 1.0);",
|
||||
" color = aColor;",
|
||||
"}",
|
||||
};
|
||||
|
||||
static const char *fragment_shader[] = {
|
||||
"#ifdef GL_ES\n",
|
||||
"precision mediump float;\n",
|
||||
"#endif\n",
|
||||
"varying vec4 color;",
|
||||
"void main() {",
|
||||
" gl_FragColor = color;",
|
||||
"}",
|
||||
};
|
||||
#endif
|
||||
|
||||
static void compile_program(void)
|
||||
{
|
||||
prog = glCreateProgram();
|
||||
GLuint vert = glCreateShader(GL_VERTEX_SHADER);
|
||||
GLuint frag = glCreateShader(GL_FRAGMENT_SHADER);
|
||||
|
||||
glShaderSource(vert, ARRAY_SIZE(vertex_shader), vertex_shader, 0);
|
||||
glShaderSource(frag, ARRAY_SIZE(fragment_shader), fragment_shader, 0);
|
||||
glCompileShader(vert);
|
||||
glCompileShader(frag);
|
||||
|
||||
glAttachShader(prog, vert);
|
||||
glAttachShader(prog, frag);
|
||||
glLinkProgram(prog);
|
||||
glDeleteShader(vert);
|
||||
glDeleteShader(frag);
|
||||
}
|
||||
|
||||
#if defined(CORE)
|
||||
static void init_multisample(unsigned samples)
|
||||
{
|
||||
multisample = samples;
|
||||
if (!context_alive)
|
||||
return;
|
||||
|
||||
if (rbo_color)
|
||||
glDeleteRenderbuffers(1, &rbo_color);
|
||||
if (rbo_depth_stencil)
|
||||
glDeleteRenderbuffers(1, &rbo_depth_stencil);
|
||||
if (fbo)
|
||||
glDeleteFramebuffers(1, &fbo);
|
||||
|
||||
rbo_color = rbo_depth_stencil = fbo = 0;
|
||||
multisample_fbo = false;
|
||||
if (samples <= 1)
|
||||
return;
|
||||
|
||||
if (glRenderbufferStorageMultisample)
|
||||
{
|
||||
glGenRenderbuffers(1, &rbo_color);
|
||||
glGenRenderbuffers(1, &rbo_depth_stencil);
|
||||
glGenFramebuffers(1, &fbo);
|
||||
|
||||
glBindRenderbuffer(GL_RENDERBUFFER, rbo_color);
|
||||
glRenderbufferStorageMultisample(GL_RENDERBUFFER,
|
||||
samples, GL_RGBA, MAX_WIDTH, MAX_HEIGHT);
|
||||
glBindRenderbuffer(GL_RENDERBUFFER, rbo_depth_stencil);
|
||||
glRenderbufferStorageMultisample(GL_RENDERBUFFER,
|
||||
samples, GL_DEPTH24_STENCIL8, MAX_WIDTH, MAX_HEIGHT);
|
||||
glBindRenderbuffer(GL_RENDERBUFFER, 0);
|
||||
|
||||
glGenFramebuffers(1, &fbo);
|
||||
glBindFramebuffer(RARCH_GL_FRAMEBUFFER, fbo);
|
||||
|
||||
glFramebufferRenderbuffer(RARCH_GL_FRAMEBUFFER, RARCH_GL_COLOR_ATTACHMENT0,
|
||||
GL_RENDERBUFFER, rbo_color);
|
||||
glFramebufferRenderbuffer(RARCH_GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT,
|
||||
GL_RENDERBUFFER, rbo_depth_stencil);
|
||||
|
||||
GLenum ret = glCheckFramebufferStatus(RARCH_GL_FRAMEBUFFER);
|
||||
if (ret == RARCH_GL_FRAMEBUFFER_COMPLETE)
|
||||
{
|
||||
fprintf(stderr, "Using multisampled FBO.\n");
|
||||
multisample_fbo = true;
|
||||
}
|
||||
else
|
||||
fprintf(stderr, "Multisampled FBO failed.\n");
|
||||
|
||||
glBindFramebuffer(RARCH_GL_FRAMEBUFFER, 0);
|
||||
}
|
||||
else
|
||||
fprintf(stderr, "Multisampled FBOs not supported.\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
static void setup_vao(void)
|
||||
{
|
||||
static const GLfloat vertex_data[] = {
|
||||
-0.5, -0.5,
|
||||
0.5, -0.5,
|
||||
-0.5, 0.5,
|
||||
0.5, 0.5,
|
||||
1.0, 1.0, 1.0, 1.0,
|
||||
1.0, 1.0, 0.0, 1.0,
|
||||
0.0, 1.0, 1.0, 1.0,
|
||||
1.0, 0.0, 1.0, 1.0,
|
||||
};
|
||||
|
||||
#if defined(CORE)
|
||||
glGenVertexArrays(1, &vao);
|
||||
#endif
|
||||
|
||||
glUseProgram(prog);
|
||||
|
||||
glGenBuffers(1, &vbo);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, vbo);
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(vertex_data), vertex_data, GL_STATIC_DRAW);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glUseProgram(0);
|
||||
}
|
||||
|
||||
void retro_init(void)
|
||||
{}
|
||||
|
||||
void retro_deinit(void)
|
||||
{}
|
||||
|
||||
unsigned retro_api_version(void)
|
||||
{
|
||||
return RETRO_API_VERSION;
|
||||
}
|
||||
|
||||
void retro_set_controller_port_device(unsigned port, unsigned device)
|
||||
{
|
||||
(void)port;
|
||||
(void)device;
|
||||
}
|
||||
|
||||
void retro_get_system_info(struct retro_system_info *info)
|
||||
{
|
||||
memset(info, 0, sizeof(*info));
|
||||
info->library_name = "TestCore GL";
|
||||
info->library_version = "v1";
|
||||
info->need_fullpath = false;
|
||||
info->valid_extensions = NULL; // Anything is fine, we don't care.
|
||||
}
|
||||
|
||||
void retro_get_system_av_info(struct retro_system_av_info *info)
|
||||
{
|
||||
info->timing = (struct retro_system_timing) {
|
||||
.fps = 60.0,
|
||||
.sample_rate = 30000.0,
|
||||
};
|
||||
|
||||
info->geometry = (struct retro_game_geometry) {
|
||||
.base_width = BASE_WIDTH,
|
||||
.base_height = BASE_HEIGHT,
|
||||
.max_width = MAX_WIDTH,
|
||||
.max_height = MAX_HEIGHT,
|
||||
.aspect_ratio = 4.0 / 3.0,
|
||||
};
|
||||
}
|
||||
|
||||
static retro_video_refresh_t video_cb;
|
||||
static retro_audio_sample_t audio_cb;
|
||||
static retro_audio_sample_batch_t audio_batch_cb;
|
||||
static retro_environment_t environ_cb;
|
||||
static retro_input_poll_t input_poll_cb;
|
||||
static retro_input_state_t input_state_cb;
|
||||
|
||||
void retro_set_environment(retro_environment_t cb)
|
||||
{
|
||||
environ_cb = cb;
|
||||
|
||||
struct retro_variable variables[] = {
|
||||
{
|
||||
"testgl_resolution",
|
||||
#ifdef HAVE_OPENGLES
|
||||
"Internal resolution; 320x240|360x480|480x272|512x384|512x512|640x240|640x448|640x480|720x576|800x600|960x720|1024x768",
|
||||
#else
|
||||
"Internal resolution; 320x240|360x480|480x272|512x384|512x512|640x240|640x448|640x480|720x576|800x600|960x720|1024x768|1024x1024|1280x720|1280x960|1600x1200|1920x1080|1920x1440|1920x1600|2048x2048",
|
||||
#endif
|
||||
},
|
||||
#ifdef CORE
|
||||
{ "testgl_multisample", "Multisampling; 1x|2x|4x" },
|
||||
#endif
|
||||
{ NULL, NULL },
|
||||
};
|
||||
|
||||
bool no_rom = true;
|
||||
cb(RETRO_ENVIRONMENT_SET_SUPPORT_NO_GAME, &no_rom);
|
||||
cb(RETRO_ENVIRONMENT_SET_VARIABLES, variables);
|
||||
}
|
||||
|
||||
void retro_set_audio_sample(retro_audio_sample_t cb)
|
||||
{
|
||||
audio_cb = cb;
|
||||
}
|
||||
|
||||
void retro_set_audio_sample_batch(retro_audio_sample_batch_t cb)
|
||||
{
|
||||
audio_batch_cb = cb;
|
||||
}
|
||||
|
||||
void retro_set_input_poll(retro_input_poll_t cb)
|
||||
{
|
||||
input_poll_cb = cb;
|
||||
}
|
||||
|
||||
void retro_set_input_state(retro_input_state_t cb)
|
||||
{
|
||||
input_state_cb = cb;
|
||||
}
|
||||
|
||||
void retro_set_video_refresh(retro_video_refresh_t cb)
|
||||
{
|
||||
video_cb = cb;
|
||||
}
|
||||
|
||||
static void update_variables(void)
|
||||
{
|
||||
struct retro_variable var = {
|
||||
.key = "testgl_resolution",
|
||||
};
|
||||
|
||||
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
|
||||
{
|
||||
char *pch;
|
||||
char str[100];
|
||||
snprintf(str, sizeof(str), "%s", var.value);
|
||||
|
||||
pch = strtok(str, "x");
|
||||
if (pch)
|
||||
width = strtoul(pch, NULL, 0);
|
||||
pch = strtok(NULL, "x");
|
||||
if (pch)
|
||||
height = strtoul(pch, NULL, 0);
|
||||
|
||||
fprintf(stderr, "[libretro-test]: Got size: %u x %u.\n", width, height);
|
||||
}
|
||||
|
||||
#ifdef CORE
|
||||
var.key = "testgl_multisample";
|
||||
var.value = NULL;
|
||||
|
||||
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
|
||||
{
|
||||
switch (*var.value)
|
||||
{
|
||||
case '1':
|
||||
init_multisample(1);
|
||||
break;
|
||||
|
||||
case '2':
|
||||
init_multisample(2);
|
||||
break;
|
||||
|
||||
case '4':
|
||||
init_multisample(4);
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static unsigned frame_count;
|
||||
|
||||
void retro_run(void)
|
||||
{
|
||||
bool updated = false;
|
||||
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE, &updated) && updated)
|
||||
update_variables();
|
||||
|
||||
input_poll_cb();
|
||||
|
||||
if (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
#ifdef CORE
|
||||
glBindVertexArray(vao);
|
||||
if (multisample_fbo)
|
||||
glBindFramebuffer(RARCH_GL_FRAMEBUFFER, fbo);
|
||||
else
|
||||
#endif
|
||||
glBindFramebuffer(RARCH_GL_FRAMEBUFFER, hw_render.get_current_framebuffer());
|
||||
|
||||
glClearColor(0.3, 0.4, 0.5, 1.0);
|
||||
glViewport(0, 0, width, height);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
||||
|
||||
glUseProgram(prog);
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, vbo);
|
||||
int vloc = glGetAttribLocation(prog, "aVertex");
|
||||
glVertexAttribPointer(vloc, 2, GL_FLOAT, GL_FALSE, 0, (void*)0);
|
||||
glEnableVertexAttribArray(vloc);
|
||||
int cloc = glGetAttribLocation(prog, "aColor");
|
||||
glVertexAttribPointer(cloc, 4, GL_FLOAT, GL_FALSE, 0, (void*)(8 * sizeof(GLfloat)));
|
||||
glEnableVertexAttribArray(cloc);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
|
||||
int loc = glGetUniformLocation(prog, "uMVP");
|
||||
|
||||
float angle = frame_count / 100.0;
|
||||
float cos_angle = cos(angle);
|
||||
float sin_angle = sin(angle);
|
||||
|
||||
const GLfloat mvp[] = {
|
||||
cos_angle, -sin_angle, 0, 0,
|
||||
sin_angle, cos_angle, 0, 0,
|
||||
0, 0, 1, 0,
|
||||
0, 0, 0, 1,
|
||||
};
|
||||
glUniformMatrix4fv(loc, 1, GL_FALSE, mvp);
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
|
||||
cos_angle *= 0.5;
|
||||
sin_angle *= 0.5;
|
||||
const GLfloat mvp2[] = {
|
||||
cos_angle, -sin_angle, 0, 0.0,
|
||||
sin_angle, cos_angle, 0, 0.0,
|
||||
0, 0, 1, 0,
|
||||
0.4, 0.4, 0.2, 1,
|
||||
};
|
||||
|
||||
glUniformMatrix4fv(loc, 1, GL_FALSE, mvp2);
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
glDisableVertexAttribArray(vloc);
|
||||
glDisableVertexAttribArray(cloc);
|
||||
|
||||
glUseProgram(0);
|
||||
|
||||
#ifdef CORE
|
||||
glBindVertexArray(0);
|
||||
if (multisample_fbo) // Resolve the multisample.
|
||||
{
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo);
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, hw_render.get_current_framebuffer());
|
||||
glBlitFramebuffer(0, 0, width, height,
|
||||
0, 0, width, height,
|
||||
GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
frame_count++;
|
||||
|
||||
video_cb(RETRO_HW_FRAME_BUFFER_VALID, width, height, 0);
|
||||
}
|
||||
|
||||
static void context_reset(void)
|
||||
{
|
||||
fprintf(stderr, "Context reset!\n");
|
||||
rglgen_resolve_symbols(hw_render.get_proc_address);
|
||||
|
||||
compile_program();
|
||||
setup_vao();
|
||||
#ifdef CORE
|
||||
context_alive = true;
|
||||
init_multisample(multisample);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void context_destroy(void)
|
||||
{
|
||||
fprintf(stderr, "Context destroy!\n");
|
||||
|
||||
#ifdef CORE
|
||||
glDeleteVertexArrays(1, &vao);
|
||||
vao = 0;
|
||||
init_multisample(0);
|
||||
context_alive = false;
|
||||
#endif
|
||||
glDeleteBuffers(1, &vbo);
|
||||
vbo = 0;
|
||||
glDeleteProgram(prog);
|
||||
prog = 0;
|
||||
}
|
||||
|
||||
#ifdef HAVE_OPENGLES
|
||||
static bool retro_init_hw_context(void)
|
||||
{
|
||||
#if defined(HAVE_OPENGLES_3_1)
|
||||
hw_render.context_type = RETRO_HW_CONTEXT_OPENGLES_VERSION;
|
||||
hw_render.version_major = 3;
|
||||
hw_render.version_minor = 1;
|
||||
#elif defined(HAVE_OPENGLES3)
|
||||
hw_render.context_type = RETRO_HW_CONTEXT_OPENGLES3;
|
||||
#else
|
||||
hw_render.context_type = RETRO_HW_CONTEXT_OPENGLES2;
|
||||
#endif
|
||||
hw_render.context_reset = context_reset;
|
||||
hw_render.context_destroy = context_destroy;
|
||||
hw_render.depth = true;
|
||||
hw_render.stencil = true;
|
||||
hw_render.bottom_left_origin = true;
|
||||
|
||||
if (!environ_cb(RETRO_ENVIRONMENT_SET_HW_RENDER, &hw_render))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
#else
|
||||
static bool retro_init_hw_context(void)
|
||||
{
|
||||
#if defined(CORE)
|
||||
hw_render.context_type = RETRO_HW_CONTEXT_OPENGL_CORE;
|
||||
hw_render.version_major = 3;
|
||||
hw_render.version_minor = 1;
|
||||
#else
|
||||
hw_render.context_type = RETRO_HW_CONTEXT_OPENGL;
|
||||
#endif
|
||||
hw_render.context_reset = context_reset;
|
||||
hw_render.context_destroy = context_destroy;
|
||||
hw_render.depth = true;
|
||||
hw_render.stencil = true;
|
||||
hw_render.bottom_left_origin = true;
|
||||
|
||||
if (!environ_cb(RETRO_ENVIRONMENT_SET_HW_RENDER, &hw_render))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool retro_load_game(const struct retro_game_info *info)
|
||||
{
|
||||
update_variables();
|
||||
|
||||
enum retro_pixel_format fmt = RETRO_PIXEL_FORMAT_XRGB8888;
|
||||
if (!environ_cb(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &fmt))
|
||||
{
|
||||
fprintf(stderr, "XRGB8888 is not supported.\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!retro_init_hw_context())
|
||||
{
|
||||
fprintf(stderr, "HW Context could not be initialized, exiting...\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
fprintf(stderr, "Loaded game!\n");
|
||||
(void)info;
|
||||
return true;
|
||||
}
|
||||
|
||||
void retro_unload_game(void)
|
||||
{}
|
||||
|
||||
unsigned retro_get_region(void)
|
||||
{
|
||||
return RETRO_REGION_NTSC;
|
||||
}
|
||||
|
||||
bool retro_load_game_special(unsigned type, const struct retro_game_info *info, size_t num)
|
||||
{
|
||||
(void)type;
|
||||
(void)info;
|
||||
(void)num;
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t retro_serialize_size(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool retro_serialize(void *data, size_t size)
|
||||
{
|
||||
(void)data;
|
||||
(void)size;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool retro_unserialize(const void *data, size_t size)
|
||||
{
|
||||
(void)data;
|
||||
(void)size;
|
||||
return false;
|
||||
}
|
||||
|
||||
void *retro_get_memory_data(unsigned id)
|
||||
{
|
||||
(void)id;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
size_t retro_get_memory_size(unsigned id)
|
||||
{
|
||||
(void)id;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void retro_reset(void)
|
||||
{}
|
||||
|
||||
void retro_cheat_reset(void)
|
||||
{}
|
||||
|
||||
void retro_cheat_set(unsigned index, bool enabled, const char *code)
|
||||
{
|
||||
(void)index;
|
||||
(void)enabled;
|
||||
(void)code;
|
||||
}
|
||||
|
@ -1,5 +0,0 @@
|
||||
{
|
||||
global: retro_*;
|
||||
local: *;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user