Jump to content
  • Advertisement
Sign in to follow this  
iliak

OpenGL Setup a 2d matrix in GLSL

This topic is 3011 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm porting my framework to OpenGL 3.2 world, dropping deprecated features. In need to setup in ortho mode but I can't succed. Here's my vertex shader code
#version 150

uniform mat4 projectionMatrix;
uniform mat4 modelViewMatrix;
uniform mat4 ViewProjectionMatrix;

in vec4 vertex;

void main(void)
{
	gl_Position = vertex;
	//gl_Position = vertex * projectionMatrix;
	//gl_Position = vertex * modelViewMatrix;
	//gl_Position =  projectionMatrix * modelViewMatrix * vertex;
	//gl_Position = ViewProjectionMatrix * vertex;
}
Here's init code (C# & OpenTK) :
Matrix4 projection = Matrix4.CreateOrthographicOffCenter(Display.ViewPort.Left, Display.ViewPort.Width, Display.ViewPort.Height, Display.ViewPort.Top, -1, 1);
GL.UniformMatrix4(projectionLocation, false, ref projection);
Matrix4 modelview = Matrix4.Identity;
GL.UniformMatrix4(modelViewLocation, false, ref modelview);

Matrix4 viewproj = Matrix4.CreateOrthographicOffCenter(Display.ViewPort.Left, Display.ViewPort.Width, Display.ViewPort.Height, Display.ViewPort.Top, -1, 1);
GL.UniformMatrix4(viewprojectionLocation, false, ref viewproj);

I'm a little bit lost. I don't know where to look at tu setup my matrix in ortho mode.

Share this post


Link to post
Share on other sites
Advertisement
glOrtho is removed from the OpenGL 3.2 core profile and present only in the OpenGL 3.2 compatibility profile.

Share this post


Link to post
Share on other sites
I am aware of that. But if you just read the page it presents all of the equations that you need to setup your own orthographic matrix (without calling glOrtho).

Also this really doesn't have anything to do with GLSL.

EDIT:

Maybe I'm not understanding you correctly. Are you having difficulty calculating the 16 floats that make up an orthographic matrix, or are you having trouble understanding how to pass a matrix to GLSL?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!