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
3 changes: 1 addition & 2 deletions src/efb.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ void _ogx_efb_set_content_type_real(OgxEfbContentType content_type);
/* We inline this part since most of the times the desired content type will be
* the one already active */
static inline void _ogx_efb_set_content_type(OgxEfbContentType content_type) {
if (content_type == _ogx_efb_content_type &&
(content_type != OGX_EFB_SCENE || _ogx_fbo_state.dirty.all == 0))
if (content_type == _ogx_efb_content_type)
return;
_ogx_efb_set_content_type_real(content_type);
}
Expand Down
25 changes: 25 additions & 0 deletions src/fbo.c
Original file line number Diff line number Diff line change
Expand Up @@ -367,3 +367,28 @@ void glFramebufferTexture3D(GLenum target, GLenum attachment, GLenum textarget,
warning("glFramebufferTexture3D is unsupported");
set_error(GL_INVALID_OPERATION);
}

void ogx_enable_module_fbo() {
_ogx_add_extension("GL_EXT_framebuffer_object");
}

/* FBOs are in OpenGL 3.0, and in older versions as an extension */
#define PROC(name) \
{ #name, name }, \
{ #name "EXT", name }
static const OgxProcMap s_proc_map[] = {
PROC(glBindFramebuffer),
PROC(glCheckFramebufferStatus),
PROC(glDeleteFramebuffers),
PROC(glFramebufferTexture1D),
PROC(glFramebufferTexture2D),
PROC(glFramebufferTexture3D),
PROC(glGenFramebuffers),
PROC(glIsFramebuffer),
};
#define NUM_PROCS (sizeof(s_proc_map) / sizeof(s_proc_map[0]))

OgxFunctions _ogx_fbo_functions = {
NUM_PROCS,
s_proc_map,
};
8 changes: 7 additions & 1 deletion src/fbo.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,11 @@ bool _ogx_fbo_get_integerv(GLenum pname, GLint *params);
void _ogx_fbo_scene_save_from_efb(OgxEfbContentType next_content_type);
void _ogx_fbo_scene_load_into_efb(void);

#ifndef BUILDING_FBO_CODE
#ifdef BUILDING_FBO_CODE

extern OgxFunctions _ogx_fbo_functions;

#else /* BUILDING_FBO_CODE not defined */

OgxFboState _ogx_fbo_state __attribute__((weak)) = { 0, 0 };

Expand All @@ -106,6 +110,8 @@ void __attribute__((weak)) _ogx_fbo_scene_load_into_efb()
_ogx_scene_load_into_efb();
}

OgxFunctions _ogx_fbo_functions __attribute__((weak)) = { 0, NULL };

#endif /* BUILDING_FBO_CODE */

#ifdef __cplusplus
Expand Down
10 changes: 10 additions & 0 deletions src/functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/

#define GL_GLEXT_PROTOTYPES 1
#include "fbo.h"
#include "opengx.h"
#include "shader.h"
#include "types.h"
Expand All @@ -51,7 +52,9 @@ static const OgxProcMap s_proc_map[] = {
PROC(glBindBuffer), /* OpenGL 1.5 */
PROC(glBindTexture),
PROC(glBitmap),
PROC(glBlendEquation),
PROC(glBlendFunc),
PROC(glBlendFuncSeparate),
PROC(glBufferData), /* OpenGL 1.5 */
PROC(glBufferSubData), /* OpenGL 1.5 */
PROC(glCallList),
Expand Down Expand Up @@ -470,5 +473,12 @@ void *ogx_get_proc_address(const char *proc)
proc);
if (ret) return ret;
}

if (_ogx_fbo_functions.num_functions > 0) {
ret = search_in_functions(_ogx_fbo_functions.functions,
_ogx_fbo_functions.num_functions,
proc);
if (ret) return ret;
}
return search_in_functions(s_proc_map, NUM_PROCS, proc);
}
7 changes: 7 additions & 0 deletions src/gc_gl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1670,6 +1670,13 @@ void glBlendFunc(GLenum sfactor, GLenum dfactor)
glparamstate.dirty.bits.dirty_blend = 1;
}

void glBlendFuncSeparate(GLenum sfactor_rgb, GLenum dfactor_rgb,
GLenum sfactor_alpha, GLenum dfactor_alpha)
{
/* This is not correct, but better than nothing */
glBlendFunc(sfactor_rgb, dfactor_rgb);
}

void glPointSize(GLfloat size)
{
unsigned int gxsize = size;
Expand Down
10 changes: 8 additions & 2 deletions src/getters.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ POSSIBILITY OF SUCH DAMAGE.
#include <string.h>

static const GLubyte gl_null_string[1] = { 0 };
/* This is not static because we might modify it in place */
static GLubyte s_extension_string[] =
/* This is not const because we might modify it in place.
* Make sure that this buffer is large enough to fit all added extensions. */
static GLubyte s_extension_string[256] =
"GL_ARB_multitexture "
"GL_ARB_vertex_buffer_object ";

Expand Down Expand Up @@ -72,6 +73,11 @@ static GLubyte *get_extension_string(int index)
return ptr;
}

void _ogx_add_extension(const GLubyte *name)
{
strcat(s_extension_string, name);
}

GLenum glGetError(void)
{
GLenum error = glparamstate.error;
Expand Down
3 changes: 3 additions & 0 deletions src/opengx.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,9 @@ static inline void ogx_shader_set_modelview_gl(const GLfloat *matrix)
* matrices, and uploads them separately to GX. */
void ogx_shader_set_mvp_gl(const GLfloat *matrix);

/* Force the inclusion of the FBO code into the program */
void ogx_enable_module_fbo();

#ifdef __cplusplus
} // extern C
#endif
Expand Down
2 changes: 2 additions & 0 deletions src/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,8 @@ void _ogx_set_projection(const Mtx44 matrix);
bool _ogx_setup_render_stages(void);
void _ogx_update_vertex_array_readers(OgxDrawMode mode);

void _ogx_add_extension(const GLubyte *name);

#ifdef __cplusplus
} // extern C
#endif
Expand Down
Loading