Setting up for 2d ortho

I recently migrated to OpenGL 3.3 and I’m trying to draw a menu/title screen.

I’m leaving the Modelview Matrix as the identity matrix.

Am I right to assume that this means the ‘camera’ is at the origin, looking down the -z axis?

That means I should specify my vertices with a z component of, say, -1.

I’m not sure what the x and y components will be. It would be nice if 1.0 x or y unit == 1 pixel in the image, so I could specify corners like this, at the origin where the image size is 304x80 pixels:

float lverts[20] = {
	0.f, 0.f, -1.f,
	0.f, 0.f,
	304.f, 0.f, -1.f,
	1.f, 0.f,
	304.f, 80.f, -1.f,
	1.f, 1.f,
	0.f, 80.f, -1.f,
	0.f, 1.f

The Projection matrix I am setting with a function I think I found in this forum:

void BuildOrthoProjMat(float* amat, float al, float ar, float ab, float at, float azn, float azf){
	float tx = -(ar+al)/(ar-al);
	float ty = -(at+ab)/(at-ab);
	float tz = -(azf+azn)/(azf-azn);

	amat[0] = 2/(ar-al);
	amat[5] = 2/(at-ab);
	amat[10] = -2/(azf-azn);
	amat[12] = tx;
	amat[13] = ty;
	amat[14] = tz;

I’m unsure what to pass for the left, right, bottom, and top (al, ar, ab, at). My screen width is 800 and screen height is 600.

Haven’t got anything draw yet.

Looking down the -z axis is a bit of a misnomer. In a way, yes. Your projection will squeeze everything into the [-1x1]x[-1x1]x[-1x1] box and OpenGL will still convert the screen z value from [-1x1] to [0,1].

The left, right, bottom, and top values are the ranges of world space you’re squeezing onto your screen. For example, if you want your screen to see everything between -500 and 500 for x, that’s your left and right. If you want to map the world space directly to the screen, you’d pass it 0xwidth and 0xheight for left, right, bottom, and top.

Hmm yep. I think it might be a problem with my initialization or shader.