Skip to main content
GameDev.net gamedev.net
🔒 Locked

Setup a 2d matrix in GLSL

Started by iliak Mar 31, 2010 at 7:58 AM 3 replies 3.7k views
Original Post
iliak
iliak
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.
- Iliak -
[ ArcEngine: An open source .Net gaming framework ]
[ Dungeon Eye: An open source remake of Eye of the Beholder II ]
karwosts
karwosts
glOrtho documents page describes how to setup an orthographic matrix:

glOrtho
[size=2]My Projects:
[size=2]Portfolio Map for Android - Free Visual Portfolio Tracker
[size=2]Electron Flux for Android - Free Puzzle/Logic Game
iliak
iliak
glOrtho is removed from the OpenGL 3.2 core profile and present only in the OpenGL 3.2 compatibility profile.
- Iliak -
[ ArcEngine: An open source .Net gaming framework ]
[ Dungeon Eye: An open source remake of Eye of the Beholder II ]
karwosts
karwosts
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?
[size=2]My Projects:
[size=2]Portfolio Map for Android - Free Visual Portfolio Tracker
[size=2]Electron Flux for Android - Free Puzzle/Logic Game
iliak
iliak
My problem was to setup the mathematic. I found this link at khronos.

Thanks
- Iliak -
[ ArcEngine: An open source .Net gaming framework ]
[ Dungeon Eye: An open source remake of Eye of the Beholder II ]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.