mirror of
https://github.com/CTCaer/RetroArch.git
synced 2025-02-08 04:39:34 +00:00
Use calculated MVP directly in shader params.
This commit is contained in:
parent
77b2ed5514
commit
a283a54bee
@ -356,34 +356,19 @@ const char *ps3_get_resolution_label(uint32_t resolution)
|
|||||||
|
|
||||||
void gfx_ctx_set_projection(gl_t *gl, const struct gl_ortho *ortho, bool allow_rotate)
|
void gfx_ctx_set_projection(gl_t *gl, const struct gl_ortho *ortho, bool allow_rotate)
|
||||||
{
|
{
|
||||||
glMatrixMode(GL_PROJECTION);
|
// Calculate projection.
|
||||||
glLoadIdentity();
|
math_matrix proj;
|
||||||
|
matrix_ortho(&proj, ortho->left, ortho->right,
|
||||||
|
ortho->bottom, ortho->top, ortho->znear, ortho->zfar);
|
||||||
|
|
||||||
if (allow_rotate)
|
if (allow_rotate)
|
||||||
{
|
{
|
||||||
switch (gl->rotation)
|
math_matrix rot;
|
||||||
{
|
matrix_rotate_z(&rot, M_PI * gl->rotation / 180.0f);
|
||||||
case 90:
|
matrix_multiply(&proj, &rot, &proj);
|
||||||
vertex_ptr = vertexes_90;
|
|
||||||
break;
|
|
||||||
case 180:
|
|
||||||
vertex_ptr = vertexes_180;
|
|
||||||
break;
|
|
||||||
case 270:
|
|
||||||
vertex_ptr = vertexes_270;
|
|
||||||
break;
|
|
||||||
case 0:
|
|
||||||
default:
|
|
||||||
vertex_ptr = default_vertex_ptr;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glVertexPointer(2, GL_FLOAT, 0, vertex_ptr);
|
gl->mvp = proj;
|
||||||
|
|
||||||
glOrtho(ortho->left, ortho->right, ortho->bottom, ortho->top, ortho->znear, ortho->zfar);
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
|
||||||
glLoadIdentity();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx_ctx_set_aspect_ratio(void *data, unsigned aspectratio_index)
|
void gfx_ctx_set_aspect_ratio(void *data, unsigned aspectratio_index)
|
||||||
|
@ -466,6 +466,8 @@ void gfx_ctx_set_projection(gl_t *gl, const struct gl_ortho *ortho, bool allow_r
|
|||||||
// TODO: Explicitly setting matrix modes is not used for GLES 2.0.
|
// TODO: Explicitly setting matrix modes is not used for GLES 2.0.
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
|
|
||||||
|
gl->mvp = proj;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
8
gfx/gl.c
8
gfx/gl.c
@ -203,14 +203,14 @@ static inline void gl_shader_deinit(void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void gl_shader_set_proj_matrix(void)
|
static inline void gl_shader_set_proj_matrix(const math_matrix *mat)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_CG
|
#ifdef HAVE_CG
|
||||||
gl_cg_set_proj_matrix();
|
gl_cg_set_proj_matrix(mat);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_XML
|
#ifdef HAVE_XML
|
||||||
gl_glsl_set_proj_matrix();
|
gl_glsl_set_proj_matrix(mat);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -440,7 +440,7 @@ void gl_set_projection(gl_t *gl, struct gl_ortho *ortho, bool allow_rotate)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
gfx_ctx_set_projection(gl, ortho, allow_rotate);
|
gfx_ctx_set_projection(gl, ortho, allow_rotate);
|
||||||
gl_shader_set_proj_matrix();
|
gl_shader_set_proj_matrix(&gl->mvp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gl_set_viewport(gl_t *gl, unsigned width, unsigned height, bool force_full, bool allow_rotate)
|
void gl_set_viewport(gl_t *gl, unsigned width, unsigned height, bool force_full, bool allow_rotate)
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include "../general.h"
|
#include "../general.h"
|
||||||
#include "fonts/fonts.h"
|
#include "fonts/fonts.h"
|
||||||
|
#include "math/matrix.h"
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
#include "../config.h"
|
#include "../config.h"
|
||||||
@ -179,6 +180,7 @@ typedef struct gl
|
|||||||
unsigned last_height[TEXTURES];
|
unsigned last_height[TEXTURES];
|
||||||
unsigned tex_w, tex_h;
|
unsigned tex_w, tex_h;
|
||||||
GLfloat tex_coords[8];
|
GLfloat tex_coords[8];
|
||||||
|
math_matrix mvp;
|
||||||
|
|
||||||
#ifdef __CELLOS_LV2__
|
#ifdef __CELLOS_LV2__
|
||||||
GLuint pbo;
|
GLuint pbo;
|
||||||
|
@ -149,10 +149,10 @@ static void gl_cg_reset_attrib(void)
|
|||||||
cg_attrib_index = 0;
|
cg_attrib_index = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gl_cg_set_proj_matrix(void)
|
void gl_cg_set_proj_matrix(const math_matrix *mat)
|
||||||
{
|
{
|
||||||
if (cg_active && prg[active_index].mvp)
|
if (cg_active && prg[active_index].mvp)
|
||||||
cgGLSetStateMatrixParameter(prg[active_index].mvp, CG_GL_MODELVIEW_PROJECTION_MATRIX, CG_GL_MATRIX_IDENTITY);
|
cgGLSetMatrixParameterfc(prg[active_index].mvp, mat->data);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define set_param_2f(param, x, y) \
|
#define set_param_2f(param, x, y) \
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include "../boolean.h"
|
#include "../boolean.h"
|
||||||
#include "gl_common.h"
|
#include "gl_common.h"
|
||||||
|
#include "math/matrix.h"
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
bool gl_cg_init(const char *path);
|
bool gl_cg_init(const char *path);
|
||||||
@ -26,7 +27,7 @@ bool gl_cg_reinit(const char *path);
|
|||||||
|
|
||||||
void gl_cg_deinit(void);
|
void gl_cg_deinit(void);
|
||||||
|
|
||||||
void gl_cg_set_proj_matrix(void);
|
void gl_cg_set_proj_matrix(const math_matrix *mat);
|
||||||
|
|
||||||
void gl_cg_set_params(unsigned width, unsigned height,
|
void gl_cg_set_params(unsigned width, unsigned height,
|
||||||
unsigned tex_width, unsigned tex_height,
|
unsigned tex_width, unsigned tex_height,
|
||||||
|
@ -1225,8 +1225,12 @@ void gl_glsl_set_params(unsigned width, unsigned height,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gl_glsl_set_proj_matrix(void)
|
void gl_glsl_set_proj_matrix(const math_matrix *mat)
|
||||||
{}
|
{
|
||||||
|
// If we're using FF-based GL, this matrix
|
||||||
|
// will be implicitly passed to the shader.
|
||||||
|
(void)mat;
|
||||||
|
}
|
||||||
|
|
||||||
void gl_glsl_use(unsigned index)
|
void gl_glsl_use(unsigned index)
|
||||||
{
|
{
|
||||||
|
@ -19,12 +19,13 @@
|
|||||||
|
|
||||||
#include "../boolean.h"
|
#include "../boolean.h"
|
||||||
#include "gl_common.h"
|
#include "gl_common.h"
|
||||||
|
#include "math/matrix.h"
|
||||||
|
|
||||||
bool gl_glsl_init(const char *path);
|
bool gl_glsl_init(const char *path);
|
||||||
|
|
||||||
void gl_glsl_deinit(void);
|
void gl_glsl_deinit(void);
|
||||||
|
|
||||||
void gl_glsl_set_proj_matrix(void);
|
void gl_glsl_set_proj_matrix(const math_matrix *mat);
|
||||||
|
|
||||||
void gl_glsl_set_params(unsigned width, unsigned height,
|
void gl_glsl_set_params(unsigned width, unsigned height,
|
||||||
unsigned tex_width, unsigned tex_height,
|
unsigned tex_width, unsigned tex_height,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user