diff --git a/gfx/gl.c b/gfx/gl.c index effc59bc74..291da234a9 100644 --- a/gfx/gl.c +++ b/gfx/gl.c @@ -81,7 +81,9 @@ static const GLfloat white_color[] = { 1, 1, 1, 1, }; +#ifdef _WIN32 #define LOAD_SYM(sym) if (!p##sym) { SDL_SYM_WRAP(p##sym, #sym) } +#endif #ifdef HAVE_FBO #ifdef _WIN32 diff --git a/ps3/ps3_video_psgl.c b/ps3/ps3_video_psgl.c index 91f66be0fa..ca6ae0dcfc 100644 --- a/ps3/ps3_video_psgl.c +++ b/ps3/ps3_video_psgl.c @@ -17,7 +17,6 @@ #include "../driver.h" -#include "ps3_video_psgl.h" #include #include "../libretro.h" @@ -100,6 +99,38 @@ static const GLfloat white_color[] = { 1, 1, 1, 1, }; +#ifdef HAVE_FBO +#if defined(HAVE_OPENGLES) +#define pglGenFramebuffers glGenFramebuffersOES +#define pglBindFramebuffer glBindFramebufferOES +#define pglFramebufferTexture2D glFramebufferTexture2DOES +#define pglCheckFramebufferStatus glCheckFramebufferStatusOES +#define pglDeleteFramebuffers glDeleteFramebuffersOES +#define GL_FRAMEBUFFER GL_FRAMEBUFFER_OES +#define GL_COLOR_ATTACHMENT0 GL_COLOR_ATTACHMENT0_EXT +#define GL_FRAMEBUFFER_COMPLETE GL_FRAMEBUFFER_COMPLETE_OES +static bool load_fbo_proc(void) { return true; } +#else +#define pglGenFramebuffers glGenFramebuffers +#define pglBindFramebuffer glBindFramebuffer +#define pglFramebufferTexture2D glFramebufferTexture2D +#define pglCheckFramebufferStatus glCheckFramebufferStatus +#define pglDeleteFramebuffers glDeleteFramebuffers +static bool load_fbo_proc(void) { return true; } +#endif +#endif + +#define MAX_SHADERS 16 + +#if defined(HAVE_XML) || defined(HAVE_CG) +#define TEXTURES 8 +#else +#define TEXTURES 1 +#endif +#define TEXTURES_MASK (TEXTURES - 1) + +#include "ps3_video_psgl.h" + bool g_quitting; unsigned g_frame_count; void *g_gl; @@ -606,8 +637,10 @@ static bool gl_frame(void *data, const void *frame, unsigned width, unsigned hei if (gl->fbo_enabled) { + GLfloat fbo_tex_coords[8] = {0.0f}; + // Render the rest of our passes. - glTexCoordPointer(2, GL_FLOAT, 0, gl->fbo_tex_coords); + glTexCoordPointer(2, GL_FLOAT, 0, fbo_tex_coords); // It's kinda handy ... :) const struct gl_fbo_rect *prev_rect; @@ -624,14 +657,14 @@ static bool gl_frame(void *data, const void *frame, unsigned width, unsigned hei GLfloat xamt = (GLfloat)prev_rect->img_width / prev_rect->width; GLfloat yamt = (GLfloat)prev_rect->img_height / prev_rect->height; - set_texture_coords(gl->fbo_tex_coords, xamt, yamt); + set_texture_coords(fbo_tex_coords, xamt, yamt); fbo_info->tex = gl->fbo_texture[i - 1]; fbo_info->input_size[0] = prev_rect->img_width; fbo_info->input_size[1] = prev_rect->img_height; fbo_info->tex_size[0] = prev_rect->width; fbo_info->tex_size[1] = prev_rect->height; - memcpy(fbo_info->coord, gl->fbo_tex_coords, sizeof(gl->fbo_tex_coords)); + memcpy(fbo_info->coord, fbo_tex_coords, sizeof(fbo_tex_coords)); glBindFramebufferOES(GL_FRAMEBUFFER_OES, gl->fbo[i]); gl_cg_use(i + 1); @@ -656,7 +689,7 @@ static bool gl_frame(void *data, const void *frame, unsigned width, unsigned hei GLfloat xamt = (GLfloat)prev_rect->img_width / prev_rect->width; GLfloat yamt = (GLfloat)prev_rect->img_height / prev_rect->height; - set_texture_coords(gl->fbo_tex_coords, xamt, yamt); + set_texture_coords(fbo_tex_coords, xamt, yamt); // Render our FBO texture to back buffer. glBindFramebufferOES(GL_FRAMEBUFFER_OES, 0); diff --git a/ps3/ps3_video_psgl.h b/ps3/ps3_video_psgl.h index c7c24d4883..8dc65f9d33 100644 --- a/ps3/ps3_video_psgl.h +++ b/ps3/ps3_video_psgl.h @@ -27,10 +27,6 @@ #define FBO_INIT 1 #define FBO_REINIT 2 -#define MAX_SHADERS 16 - -#define TEXTURES 8 -#define TEXTURES_MASK (TEXTURES - 1) #define MIN_SCALING_FACTOR (1.0f) #define MAX_SCALING_FACTOR (4.0f) @@ -44,16 +40,20 @@ typedef struct gl { + bool vsync; + GLuint texture[TEXTURES]; + unsigned tex_index; /* For use with PREV. */ + struct gl_tex_info prev_info[TEXTURES]; + GLuint tex_filter; + + void *empty_buf; + bool block_swap; bool fbo_enabled; bool keep_aspect; - bool vsync; bool overscan_enable; - int fbo_pass; - unsigned base_size; /* 2 or 4*/ unsigned last_width[TEXTURES]; unsigned last_height[TEXTURES]; - unsigned tex_index; /* For use with PREV. */ unsigned tex_w, tex_h; unsigned vp_width, vp_out_width; unsigned vp_height, vp_out_height; @@ -61,24 +61,25 @@ typedef struct gl unsigned win_height; GLfloat overscan_amount; GLfloat tex_coords[8]; - GLfloat fbo_tex_coords[8]; + GLenum texture_type; /* XBGR1555 or ARGB*/ GLenum texture_fmt; + unsigned base_size; /* 2 or 4*/ + +#ifdef HAVE_FBO /* Render-to-texture, multipass shaders */ GLuint fbo[MAX_SHADERS]; GLuint fbo_texture[MAX_SHADERS]; + struct gl_fbo_rect fbo_rect[MAX_SHADERS]; + struct gl_fbo_scale fbo_scale[MAX_SHADERS]; + int fbo_pass; +#endif GLuint menu_texture_id; GLuint pbo; - GLuint texture[TEXTURES]; - GLuint tex_filter; CellVideoOutState g_video_state; PSGLdevice* gl_device; PSGLcontext* gl_context; - struct gl_fbo_rect fbo_rect[MAX_SHADERS]; - struct gl_fbo_scale fbo_scale[MAX_SHADERS]; - struct gl_tex_info prev_info[TEXTURES]; struct texture_image menu_texture; - void *empty_buf; } gl_t; bool ps3_setup_texture(void);