# OpenGL 2D orthographic projection problem [closed]

I'm trying to use an orthographic projection to allow me to specify the dimensions and position of rendered objects using exact pixel coordinates (like in this tutorial: https://learnopengl.com/#!In-Practice/2D-Game/Rendering-Sprites)

So I have this vertex data, and I setup the ortho projection matrix like this:

glm::vec2 vertices[] = {
// X, Y
glm::vec2(0.0f, 1.0f),
glm::vec2(1.0f, 0.0f),
glm::vec2(0.0f, 0.0f),

glm::vec2(0.0f, 1.0f),
glm::vec2(1.0f, 1.0f),
glm::vec2(1.0f, 0.0f),
};

glm::mat4 projection = glm::ortho(0.0f, 1024.0f, 768.0f, 0.0f, -1.0f, 1.0f);


and I set my shader's projection uniform to that value.

The problem is that I can't see any rendered objects if I use the projection matrix. I know that the rest of my program works, because I can see the rendered square if I remove the projection matrix from my shader:

gl_Position = model * view * vec4(position.xy, 0.0, 1.0);


Then the triangles are rendered as you would expect. But in the tutorial, they use integers to specify the exact size and position (in screen pixels) to render the object, which doesn't work without the orthographic projection matrix.

My full code is here: https://github.com/Oddity/basic-2D-opengl (sorry about the hand-made Python 2 build script)

## closed as off-topic by Gnemlock, DMGregory♦, Alexandre Vaillancourt♦, Tyyppi_77, doppelgreenerJul 21 '17 at 18:50

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "Questions about debugging a problem must provide a minimal, complete, verifiable example of the issue so that readers can diagnose it without needing to guess, read all of your code, or engage in extensive back-and-forth dialog. For more information, see this meta thread." – Gnemlock, DMGregory, Alexandre Vaillancourt, Tyyppi_77, doppelgreener
If this question can be reworded to fit the rules in the help center, please edit the question.

• If your having a problem that needs to be debugged, you need to provide us with a minimal and verifiable example of the code. We can not be expected to dig through your github repo to find the solution, sorry. – Gnemlock Jul 11 '17 at 6:51
• The github repo is a minimal and verifiable example of the code. – Terran Jul 11 '17 at 9:10
• Maybe so; I have not looked. We don't include links when judging questions; mostly because links die. If your github contains the minimum example, you need to copy it into the body of your question. – Gnemlock Jul 11 '17 at 11:24
• Seems like a projection 1 pix = 1 unit, and since the triangles are half a square unit, I wouldn't be surprised if they were too small to be noticed when rendered. – wondra Jul 11 '17 at 13:03

gl_Position = projection * LookAt * model * vec4(position.xy, 0.0, 1.0);