Results 1 to 4 of 4

Thread: Ortho View Scrolling/Panning

  1. #1
    Junior Member Newbie
    Join Date
    Sep 2010
    Posts
    23

    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:

    Code :
    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());
     
     
    	glDrawElements(	GL_TRIANGLE_STRIP,  4,  GL_UNSIGNED_SHORT,  NULL );
     
     
    	return true;
    }

    Here is my simple vertex shader:
    Code :
     
    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.

  2. #2
    Junior Member Newbie
    Join Date
    Sep 2010
    Posts
    23

    Re: Ortho View Scrolling/Panning

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

  3. #3
    Senior Member Regular Contributor
    Join Date
    Dec 2007
    Posts
    258

    Re: Ortho View Scrolling/Panning

    i'd just suggest learning the basics of opengl .. before worrying about shaders etc

  4. #4
    Junior Member Newbie
    Join Date
    Sep 2010
    Posts
    23

    Re: Ortho View Scrolling/Panning

    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.

Similar Threads

  1. problem orthogonal view glm::ortho
    By Pablo Valoppi in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 01-09-2015, 01:20 PM
  2. Pixel spacing in Ortho view
    By JRGlide in forum OpenGL: Advanced Coding
    Replies: 3
    Last Post: 03-20-2014, 08:31 AM
  3. 3d rotate in 2d ortho view h.u.d., hmmm?
    By RobertEd in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 01-31-2010, 07:36 PM
  4. Looking for a way to "zoom" in ortho view
    By acaron in forum OpenGL: Basic Coding
    Replies: 9
    Last Post: 03-06-2002, 10:25 AM
  5. Aligning a frustum view with an ortho view
    By Siwko in forum OpenGL: Advanced Coding
    Replies: 6
    Last Post: 05-22-2001, 04:52 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean