backend: gl_common: no need to store maximum viewport size
Just get it from GL_MAX_VIEWPORT_DIMS Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
parent
77d733f521
commit
0b377537ec
|
@ -748,11 +748,14 @@ static int gl_win_shader_from_string(const char *vshader_str, const char *fshade
|
||||||
* Callback to run on root window size change.
|
* Callback to run on root window size change.
|
||||||
*/
|
*/
|
||||||
void gl_resize(struct gl_data *gd, int width, int height) {
|
void gl_resize(struct gl_data *gd, int width, int height) {
|
||||||
|
GLint viewport_dimensions[2];
|
||||||
|
glGetIntegerv(GL_MAX_VIEWPORT_DIMS, viewport_dimensions);
|
||||||
|
|
||||||
gd->height = height;
|
gd->height = height;
|
||||||
gd->width = width;
|
gd->width = width;
|
||||||
|
|
||||||
assert(gd->vp_width >= gd->width);
|
assert(viewport_dimensions[0] >= gd->width);
|
||||||
assert(gd->vp_height >= gd->height);
|
assert(viewport_dimensions[1] >= gd->height);
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, gd->back_texture);
|
glBindTexture(GL_TEXTURE_2D, gd->back_texture);
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, width, height, 0, GL_BGR,
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, width, height, 0, GL_BGR,
|
||||||
|
@ -956,8 +959,10 @@ void *gl_create_blur_context(backend_t *base, enum blur_method method, void *arg
|
||||||
// Set projection matrix to gl viewport dimensions so we can use screen
|
// Set projection matrix to gl viewport dimensions so we can use screen
|
||||||
// coordinates for all vertices
|
// coordinates for all vertices
|
||||||
// Note: OpenGL matrices are column major
|
// Note: OpenGL matrices are column major
|
||||||
GLfloat projection_matrix[4][4] = {{2.0f / (GLfloat)gd->vp_width, 0, 0, 0},
|
GLint viewport_dimensions[2];
|
||||||
{0, 2.0f / (GLfloat)gd->vp_height, 0, 0},
|
glGetIntegerv(GL_MAX_VIEWPORT_DIMS, viewport_dimensions);
|
||||||
|
GLfloat projection_matrix[4][4] = {{2.0f / (GLfloat)viewport_dimensions[0], 0, 0, 0},
|
||||||
|
{0, 2.0f / (GLfloat)viewport_dimensions[1], 0, 0},
|
||||||
{0, 0, 0, 0},
|
{0, 0, 0, 0},
|
||||||
{-1, -1, 0, 1}};
|
{-1, -1, 0, 1}};
|
||||||
|
|
||||||
|
@ -1177,10 +1182,7 @@ bool gl_init(struct gl_data *gd, session_t *ps) {
|
||||||
// buffer are skipped anyways, this should have no impact on performance.
|
// buffer are skipped anyways, this should have no impact on performance.
|
||||||
GLint viewport_dimensions[2];
|
GLint viewport_dimensions[2];
|
||||||
glGetIntegerv(GL_MAX_VIEWPORT_DIMS, viewport_dimensions);
|
glGetIntegerv(GL_MAX_VIEWPORT_DIMS, viewport_dimensions);
|
||||||
gd->vp_width = viewport_dimensions[0];
|
glViewport(0, 0, viewport_dimensions[0], viewport_dimensions[1]);
|
||||||
gd->vp_height = viewport_dimensions[1];
|
|
||||||
|
|
||||||
glViewport(0, 0, gd->vp_width, gd->vp_height);
|
|
||||||
|
|
||||||
// Clear screen
|
// Clear screen
|
||||||
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
||||||
|
@ -1201,8 +1203,8 @@ bool gl_init(struct gl_data *gd, session_t *ps) {
|
||||||
// Set projection matrix to gl viewport dimensions so we can use screen
|
// Set projection matrix to gl viewport dimensions so we can use screen
|
||||||
// coordinates for all vertices
|
// coordinates for all vertices
|
||||||
// Note: OpenGL matrices are column major
|
// Note: OpenGL matrices are column major
|
||||||
GLfloat projection_matrix[4][4] = {{2.0f / (GLfloat)gd->vp_width, 0, 0, 0},
|
GLfloat projection_matrix[4][4] = {{2.0f / (GLfloat)viewport_dimensions[0], 0, 0, 0},
|
||||||
{0, 2.0f / (GLfloat)gd->vp_height, 0, 0},
|
{0, 2.0f / (GLfloat)viewport_dimensions[1], 0, 0},
|
||||||
{0, 0, 0, 0},
|
{0, 0, 0, 0},
|
||||||
{-1, -1, 0, 1}};
|
{-1, -1, 0, 1}};
|
||||||
|
|
||||||
|
|
|
@ -70,8 +70,6 @@ struct gl_data {
|
||||||
bool is_nvidia;
|
bool is_nvidia;
|
||||||
// Height and width of the root window
|
// Height and width of the root window
|
||||||
int height, width;
|
int height, width;
|
||||||
// Height and width of the gl viewport
|
|
||||||
int vp_height, vp_width;
|
|
||||||
gl_win_shader_t win_shader;
|
gl_win_shader_t win_shader;
|
||||||
gl_brightness_shader_t brightness_shader;
|
gl_brightness_shader_t brightness_shader;
|
||||||
gl_fill_shader_t fill_shader;
|
gl_fill_shader_t fill_shader;
|
||||||
|
|
Loading…
Reference in New Issue