Ortho View Scrolling/Panning

Dear all,

can I kindly ask for a guidance on how to implement efficient 2D scrolling/panning mechanism in OpenGL ES 2.0? The panning should be as effective as possible.

Will the proposed solution work well with paralax scrolling as well?

To give you information about how I implement orthographic view, here is a regular 2D Render method of one of my game objects:

bool CObjectMyShip::Render( float fInterpolationParam )

	glBindBuffer(GL_ARRAY_BUFFER, ApplicationEngine.ResourceManager.vVBOs[OBID_MyRocket001].nVertexBufferID);
	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ApplicationEngine.ResourceManager.vVBOs[OBID_MyRocket001].nElementBufferID);

	GLint offset = (nFrameNumber * 4) * GameViewEngine.PlayerGameView.DisplayManager.nStride;
	glVertexAttribPointer(GameViewEngine.PlayerGameView.DisplayManager.nPosition, 4, GL_FLOAT, GL_FALSE, GameViewEngine.PlayerGameView.DisplayManager.nStride, (const void*)offset);
	offset += (sizeof(float) * (GameViewEngine.PlayerGameView.DisplayManager.VERTEX_POS_SIZE));
	glVertexAttribPointer(GameViewEngine.PlayerGameView.DisplayManager.nUV, 2, GL_FLOAT, GL_FALSE, GameViewEngine.PlayerGameView.DisplayManager.nStride, (const GLvoid*)offset);

	glm::mat4 matOrtho2D = glm::ortho<float>(-320.0f, 320.0f, -480.0f, 480.0f);
	glUniformMatrix4fv(GameViewEngine.PlayerGameView.DisplayManager.nOrthoProjectionID, 1, 0, glm::value_ptr(matOrtho2D));
	//glUniformMatrix4fv(GameViewEngine.PlayerGameView.DisplayManager.nOrthoProjectionID, 1, 0, matOrthogonal.Pointer());

	vec3 vViewPosition = vec3(0.0f, 0.0f, 0.0f);
	vViewPosition.x = vPosition.x + (float(fCurrentSpeedRight - fCurrentSpeedLeft ) * fInterpolationParam);
	vViewPosition.y = vPosition.y + (float(fCurrentSpeedUp - fCurrentSpeedDown) * fInterpolationParam);
	vViewPosition.z = 1;

	glUniform3fv(GameViewEngine.PlayerGameView.DisplayManager.nTranslationID, 1, vViewPosition.Pointer());


	return true;

Here is my simple vertex shader:

uniform mat4 uOrthoProjection;
uniform vec3 Translation;

attribute vec4 Position;
attribute vec2 TextureCoord;

varying vec2 TextureCoordOut;

void main()
    gl_Position = uOrthoProjection * (Position + vec4(Translation, 0));
    TextureCoordOut = TextureCoord;

Thank you.

Not to let this question become forgotten, does anybody anything to say on this topic?

i’d just suggest learning the basics of opengl … before worrying about shaders etc

Hi dukey,

sometimes things look more difficult than they really are.

I applied LookAt() matrix with model matrix, and futher multiplied it with projection matrix to receive ModeViewProjection Matrix.

This ModelViewProjection matrix was moved to the shader as uniform variable and every vertex was multiplied by it.

Things work for me as expected now. I thought, there was something special with Ortho projection, as it was different kind of projection. However, i realized, that because view projection is applied to model projection, it is independent from both ortho and perspective projections.