mirror of
https://github.com/CTCaer/RetroArch.git
synced 2025-02-01 01:03:11 +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)
|
||||
{
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
// Calculate projection.
|
||||
math_matrix proj;
|
||||
matrix_ortho(&proj, ortho->left, ortho->right,
|
||||
ortho->bottom, ortho->top, ortho->znear, ortho->zfar);
|
||||
|
||||
if (allow_rotate)
|
||||
{
|
||||
switch (gl->rotation)
|
||||
{
|
||||
case 90:
|
||||
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;
|
||||
}
|
||||
math_matrix rot;
|
||||
matrix_rotate_z(&rot, M_PI * gl->rotation / 180.0f);
|
||||
matrix_multiply(&proj, &rot, &proj);
|
||||
}
|
||||
|
||||
glVertexPointer(2, GL_FLOAT, 0, vertex_ptr);
|
||||
|
||||
glOrtho(ortho->left, ortho->right, ortho->bottom, ortho->top, ortho->znear, ortho->zfar);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
gl->mvp = proj;
|
||||
}
|
||||
|
||||
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.
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
|
||||
gl->mvp = proj;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
8
gfx/gl.c
8
gfx/gl.c
@ -203,14 +203,14 @@ static inline void gl_shader_deinit(void)
|
||||
#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
|
||||
gl_cg_set_proj_matrix();
|
||||
gl_cg_set_proj_matrix(mat);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_XML
|
||||
gl_glsl_set_proj_matrix();
|
||||
gl_glsl_set_proj_matrix(mat);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -440,7 +440,7 @@ void gl_set_projection(gl_t *gl, struct gl_ortho *ortho, bool allow_rotate)
|
||||
#endif
|
||||
|
||||
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)
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
#include "../general.h"
|
||||
#include "fonts/fonts.h"
|
||||
#include "math/matrix.h"
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "../config.h"
|
||||
@ -179,6 +180,7 @@ typedef struct gl
|
||||
unsigned last_height[TEXTURES];
|
||||
unsigned tex_w, tex_h;
|
||||
GLfloat tex_coords[8];
|
||||
math_matrix mvp;
|
||||
|
||||
#ifdef __CELLOS_LV2__
|
||||
GLuint pbo;
|
||||
|
@ -149,10 +149,10 @@ static void gl_cg_reset_attrib(void)
|
||||
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)
|
||||
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) \
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
#include "../boolean.h"
|
||||
#include "gl_common.h"
|
||||
#include "math/matrix.h"
|
||||
#include <stdint.h>
|
||||
|
||||
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_set_proj_matrix(void);
|
||||
void gl_cg_set_proj_matrix(const math_matrix *mat);
|
||||
|
||||
void gl_cg_set_params(unsigned width, unsigned 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)
|
||||
{
|
||||
|
@ -19,12 +19,13 @@
|
||||
|
||||
#include "../boolean.h"
|
||||
#include "gl_common.h"
|
||||
#include "math/matrix.h"
|
||||
|
||||
bool gl_glsl_init(const char *path);
|
||||
|
||||
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,
|
||||
unsigned tex_width, unsigned tex_height,
|
||||
|
Loading…
x
Reference in New Issue
Block a user