math - OpenGL - turn around projection -


i try turn around gui. have projection:

glm::mat4 my_projection = glm::mat4( 2.0/static_cast<float>(m_window->getsize().x), 0.0, 0.0, -1.0,                          0.0, 2.0/static_cast<float>(m_window->getsize().y), 0.0, -1.0,                          0.0, 0.0, -1.0, 0.0,                          0.0, 0.0, 0.0, 1.0); 

and shader:

#version 330 core  in vec3 pos; in vec2 uv; in vec4 col;  uniform vec2 translation; uniform mat4 my_projection;  out vec2 vecuv; out vec4 veccolor;  void main() {        vec3 tran_pos = vec3(pos + vec3(translation, 0.0f));     gl_position = vec4(tran_pos, 1.0f) * my_projection;     vecuv = uv;     veccolor = col; } 

and don't know how turn around, when change

m_window->getsize().x 

to

-m_window->getsize().x  

and

m_window->getsize().y  

to

-m_window->getsize().y 

everything disapear. how can turn around this?

edit: (solution)

glm::mat4 my_projection = glm::ortho(0.0f, (float)m_window->getsize().x, (float)m_window->getsize().y, 0.0f);   // shader: #version 330 core  in vec3 pos; in vec2 uv; in vec4 col;  uniform vec2 translation; uniform mat4 my_projection;  out vec2 vecuv; out vec4 veccolor;  void main() {               vec3 tran_pos = vec3(pos + vec3(translation, 0.0f));         gl_position = my_projection * vec4(tran_pos, 1.0f);         vecuv = uv;         veccolor = col; } 

just use glm function matrix projection , multiply projection position.


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -