From f4e9547e686ce03a76812d8ec04349cf182886f0 Mon Sep 17 00:00:00 2001 From: Themaister Date: Fri, 29 Mar 2013 02:12:08 +0100 Subject: [PATCH] Fix Win32 HW render. --- gfx/gl.c | 18 +++++++++++++++--- libretro-test-gl/Makefile | 3 ++- libretro-test-gl/libretro-test.c | 1 + 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/gfx/gl.c b/gfx/gl.c index eba64aba59..3807c9ef6e 100644 --- a/gfx/gl.c +++ b/gfx/gl.c @@ -700,10 +700,13 @@ void gl_init_fbo(void *data, unsigned width, unsigned height) gl->fbo_inited = true; } -void gl_init_hw_render(gl_t *gl, unsigned width, unsigned height) +bool gl_init_hw_render(gl_t *gl, unsigned width, unsigned height) { RARCH_LOG("[GL]: Initializing HW render (%u x %u).\n", width, height); + if (!load_fbo_proc(gl)) + return false; + glBindTexture(GL_TEXTURE_2D, 0); pglGenFramebuffers(TEXTURES, gl->hw_render_fbo); @@ -713,11 +716,15 @@ void gl_init_hw_render(gl_t *gl, unsigned width, unsigned height) pglFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, gl->texture[i], 0); GLenum status = pglCheckFramebufferStatus(GL_FRAMEBUFFER); if (status != GL_FRAMEBUFFER_COMPLETE) + { RARCH_ERR("[GL]: Failed to create HW render FBO.\n"); + return false; + } } pglBindFramebuffer(GL_FRAMEBUFFER, 0); gl->hw_render_fbo_init = true; + return true; } #endif @@ -1936,8 +1943,13 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo // Set up render to texture. gl_init_fbo(gl, gl->tex_w, gl->tex_h); - if (g_extern.system.hw_render_callback.context_type == RETRO_HW_CONTEXT_OPENGL) - gl_init_hw_render(gl, gl->tex_w, gl->tex_h); + if (g_extern.system.hw_render_callback.context_type == RETRO_HW_CONTEXT_OPENGL + && !gl_init_hw_render(gl, gl->tex_w, gl->tex_h)) + { + context_destroy_func(); + free(gl); + return NULL; + } #endif if (input && input_data) diff --git a/libretro-test-gl/Makefile b/libretro-test-gl/Makefile index 30a0eaed59..2ec4542b85 100644 --- a/libretro-test-gl/Makefile +++ b/libretro-test-gl/Makefile @@ -27,6 +27,7 @@ else TARGET := retro.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) @@ -48,7 +49,7 @@ endif all: $(TARGET) $(TARGET): $(OBJECTS) - $(CC) $(fpic) $(SHARED) $(LIBS) $(INCLUDES) -o $@ $(OBJECTS) -lm + $(CC) $(fpic) $(SHARED) $(INCLUDES) -o $@ $(OBJECTS) $(LIBS) -lm %.o: %.c $(CC) $(CFLAGS) -c -o $@ $< diff --git a/libretro-test-gl/libretro-test.c b/libretro-test-gl/libretro-test.c index e8ff2ff14e..54f6ddd838 100644 --- a/libretro-test-gl/libretro-test.c +++ b/libretro-test-gl/libretro-test.c @@ -277,6 +277,7 @@ bool retro_load_game(const struct retro_game_info *info) if (!environ_cb(RETRO_ENVIRONMENT_SET_HW_RENDER, &hw_render)) return false; + fprintf(stderr, "Loaded game!\n"); (void)info; return true; }