LWJGL - 0, 0 at Top Left, FBO issue

I’ve been making my own sort of 2D game engine matching my code style for fun. As a personal challenge I tried to give it the ability to swap LWJGL with Java2D by changing one line.
I am really new to LWJGL, so upon implementing off-screen rendering with FBOs I noticed they weren’t working when I had 0, 0 being the top left corner of the screen as in Java2D.

EDIT: basically I can’t get this to work: https://gist.github.com/pwnedary/8012530

Here it is working and drawing a blue square over the firefox logo:

but here it isn’t:

I enter ortho with this:


		glMatrixMode(GL_PROJECTION);
		glLoadIdentity();
		glOrtho(0, width, height, 0, 1, -1); // 0,0 : top-left
		// glOrtho(0, width, 0, height, 1, -1); // 0,0 : bottom-left
		glMatrixMode(GL_MODELVIEW);

		glEnable(GL_TEXTURE_2D);
		glShadeModel(GL_SMOOTH);
		glDisable(GL_DEPTH_TEST);
		glDisable(GL_LIGHTING);
		glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
		glClearDepth(1);
		glEnable(GL_BLEND);
		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
		glViewport(0, 0, width, height);

and construct FBO:


		if (!GLContext.getCapabilities().GL_EXT_framebuffer_object) throw new Error("FBOs not supported");

		// Initialize frame buffer
		IntBuffer buffer = BufferUtils.createIntBuffer(1); // ByteBuffer.allocateDirect(1*4).order(ByteOrder.nativeOrder()).asIntBuffer(); // allocate a 1 int byte buffer
		EXTFramebufferObject.glGenFramebuffersEXT(buffer); // generate
		frameBufferID = buffer.get(0);

		image.bind();

		// Attach a texture
		bind();
		EXTFramebufferObject.glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, image.target, image.getTextureID(), 0);

		check(); // Check (from LWJGL's tutorial on FBOs)

		image.unbind();
		unbind();

and FBO.bind:


		EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, frameBufferID);
		GL11.glPushAttrib(GL_VIEWPORT_BIT);
		GL11.glViewport(0, 0, image.getWidth(), image.getHeight());

Thanks in advance. I’m really desperate for posting this as I have had this problem for weeks.

Your glOrtho call is setting the origin in the top left. You had it right in the commented out call.

Yes I know and that is the problem, as I want the coordinate system to be the same as in normal Java2D/AWT.

To sum up, it’s this I can’t get to work: https://gist.github.com/pwnedary/8012530.