First, you set the blend function to (GL_ONE, GL_ONE), which will just add the blur texture to the framebuffer and make the whole scene overbright. You probalby want to use (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA), but then you have to make sure your blur texture has the correct alpha, by configuring the texture environment to use a constant value for the alpha (instead of the texture's) or use GL_MODULATE with a (1,1,1,0.5) coloured square. Alternatively use a fragment shader Second, you specify a size 3 in the second call to glVertexPointer, but your data are 2d vectors (the first call is right) glOrtho is not neccessarily 2D, its just a camera without perspective distortion (farther objects don't get smaller).
The parameters to glOrtho specify your screen plane size in view coordinates. Thus if your scene covers the world in the unit cube, an ortho of 480x800 is just too large (this is no problem if you draw other objects than in perspective, as your square or UI elements, but when you want to draw your same 3d objects the scales have to match). Another thing is that in ortho the near and far distances still matter, everything that falls out is clipped away.So if your camera is at (0,0,0) and you view along -z with a glOrtho of (0,480,0,800,-1,1), you will only see those objects that intersect the (0,0,-1)-(480,800,1)-box So keep in mind, that glOrtho and glFrustum (or gluPerspective) all define a 3d viewing volume.
In ortho its a box and in frustum its, guess a frustum (capped pyramid). Consult some more introductory texts on transformations and viewing if this was not clear enough.
First, you set the blend function to (GL_ONE, GL_ONE), which will just add the blur texture to the framebuffer and make the whole scene overbright. You probalby want to use (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA), but then you have to make sure your blur texture has the correct alpha, by configuring the texture environment to use a constant value for the alpha (instead of the texture's) or use GL_MODULATE with a (1,1,1,0.5) coloured square. Alternatively use a fragment shader.
Second, you specify a size 3 in the second call to glVertexPointer, but your data are 2d vectors (the first call is right). GlOrtho is not neccessarily 2D, its just a camera without perspective distortion (farther objects don't get smaller). The parameters to glOrtho specify your screen plane size in view coordinates.
Thus if your scene covers the world in the unit cube, an ortho of 480x800 is just too large (this is no problem if you draw other objects than in perspective, as your square or UI elements, but when you want to draw your same 3d objects the scales have to match). Another thing is that in ortho the near and far distances still matter, everything that falls out is clipped away. So if your camera is at (0,0,0) and you view along -z with a glOrtho of (0,480,0,800,-1,1), you will only see those objects that intersect the (0,0,-1)-(480,800,1)-box.So keep in mind, that glOrtho and glFrustum (or gluPerspective) all define a 3d viewing volume.
In ortho its a box and in frustum its, guess a frustum (capped pyramid). Consult some more introductory texts on transformations and viewing if this was not clear enough.
Thanks for your response. It was actually already set to (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA), I think that (GL_ONE, GL_ONE) got pasted in with some other sample code I was trying out last night. I'll get rid of that.
I had set the ortho mode to be 480x800 because that was the size of the screen. As you're explaining it, I should use much smaller coordinates and the texture will still display correctly? Also, I understand Ortho is not 2d, I meant that I'm trying to display something 2d in ortho mode (a square).
My second task is to display 3d objects in ortho mode as well. – einsteinx2 May 8 at 22:42 I'll try changing those coordinates as you suggested, and I'll remove the second glVertexPointer call, but my big problem is getting the texture to render. I can see the box, so that's working, I just can't get the texture to display.
– einsteinx2 May 8 at 22:46 1 @einsteinx2 for your square the chosen ortho is just perfect and it is common to set the ortho to the screen size, when rendering ui-stuff or such things, it just doesn't work for your normal 3d objects (as to the second part of your question). Another appraoch is to use ortho (0,1,0,1) and draw a unit square (so your screen size can be changed and is not written to the square coordinates), but then you have to adjust the translation (which is not in pixels anymore). Just keep in mind.
That your square verts and translation (for the blur) have to match the ortho. – Christian Rau May 8 at 22:49 1 how the texture is applied is specified by the texture coordinates. It uses these coordinates per pixel (which are the values of the vertices interpolated over the triangle) to get the colour from the texture.
I just saw, that your texture coordinates are messed up, they should be {0,0, 1,0, 1,1, 0,1}, to match your vertices, as in OpenGL the screen origin and the texture origin are both in the lower left corner. – Christian Rau May 8 at 23:08 1 I also saw, that your vertex order is wrong. Your triangle strip renders a triangle with the first three verts and a second one with the last three.
With your vertices you get the triangle in the lower right corner and then a triangle in the upper rigth, which is flipped and thus culled away by the backface culling. In this example you could just change the primitive type from GL_TRIANGLE_STRIP to GL_TRIANGLE_FAN. Or you can change the vertex ordering to {0,0, 1,0, 0,1, 1,1} and also for the texCoords, but then your line loop won't work, so the triangle fan is a good solution.
– Christian Rau May 8 at 23:14.
My first problem is that I'm trying to implement a motion blur by taking a screen grab as a texture, then drawing the texture over the next frame with transparency -- or use more frames for more blur. I've got the screen saving as a texture working fine. The issue I'm having is drawing in Ortho mode on top of the screen.
After much head banging, I finally got a basic square drawing, but my lack of OpenGL ES understanding and an easy to follow example are holding me back now. I need to take the texture I saved, and draw it into the square I drew. Nothing I've been doing seems to work.
Also, my second problem, is drawing more complex 3d models into Ortho mode. I can't seem to get any models to draw. I'm using the (slightly customized) min3d framework (http://code.google.com/p/min3d/), and I'm trying to draw Object3d's in Ortho mode just like I draw them in Perspective mode.
As I understand it, they should draw the same, they should just not have depth. Yet I don't seem to see them at all.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.