This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

One question of the PVRshell in the graphic SDK on OMAP

Intellectual 925 points

Replies: 3

Views: 1439

I am using the PVRshell inside the graphic SDK. The OpenGL ES is what I need for 3D visualization.  I installed Ubuntu on my PC (through VMware player) and use minicom to communicate with OMAP console.  I started from the Training course. After I built the training course and the program is running well on the OMAP. However, I use the keyboard to make screenshot by pushing the button "S". I found that the content in the screenshot is shifting horizontally. Just like the images I attached. Looks to me the screen buffer has been modified. Did anyone of you have the similar results? Is this a bug of the PVR shell?

Here is the system configuration

  • OMAP35x_Graphics_SDK_3_00_00_09
  • The training course I built is training course -5 05_BasicTnL
  • The OMAP system I am using is OMAP 3530

Thank you

renaissance

 

3 Replies

  • What is the reference you are comparing against, and what is the platform  ?

     

     


     

    Note: Post the output of below Script, while posting queries related to SGX drivers:

    https://gforge.ti.com/gf/download/docmanfileversion/203/3715/gfx_check.sh

    Also read the below page,

    http://processors.wiki.ti.com/index.php/SGXDbg

    For User Interface queries, submit below details for faster response,

    https://gforge.ti.com/gf/download/docmanfileversion/220/3798/UI_graphics_reqs_sheet_v1.xls

     

  • In reply to Prabindh Sundareson:

    In this training course example, the triangle is rotating constantly. I attached the source code here. I just pushed the "S" button on the keyboard and several screen shots are made. In these screenshots, the central axials of the triangles are supposed at the same horizontal location. However, you can see the content of the images are shifting and that is why the cental axials are not at the fixed location as we expected.

    The OMAP system I am using is OMAP 3530

    /******************************************************************************

     @File         OGLES2BasicTnL.cpp

     @Title        Shows basic transformations and lighting

     @Copyright    Copyright (C) 2000 - 2008 by Imagination Technologies Limited.

     @Platform     Independant

     @Description  Shows basic transformations and lighting

    ******************************************************************************/
    #include <math.h>
    #include <stdio.h>

    #include <EGL/egl.h>
    #include <GLES2/gl2.h>

    #include "PVRShell.h"

    /******************************************************************************
     Defines
    ******************************************************************************/

    // Index to bind the attributes to vertex shaders
    #define VERTEX_ARRAY 0
    #define TEXCOORD_ARRAY 1
    #define NORMAL_ARRAY 2

    // Size of the texture we create
    #define TEX_SIZE  128

    /*!****************************************************************************
     Class implementing the PVRShell functions.
    ******************************************************************************/
    class OGLESBasicTnL : public PVRShell
    {
     // The vertex and fragment shader OpenGL handles
     GLuint m_uiVertexShader, m_uiFragShader;

     // The program object containing the 2 shader objects
     GLuint m_uiProgramObject;

     // Texture handle
     GLuint m_uiTexture;

     // Angle to rotate the triangle
     float m_fAngle;
    public:
     virtual bool InitApplication();
     virtual bool InitView();
     virtual bool ReleaseView();
     virtual bool QuitApplication();
     virtual bool RenderScene();
    };


    /*!****************************************************************************
     @Function  InitApplication
     @Return  bool  true if no error occured
     @Description Code in InitApplication() will be called by PVRShell once per
        run, before the rendering context is created.
        Used to initialize variables that are not dependant on it
        (e.g. external modules, loading meshes, etc.)
        If the rendering context is lost, InitApplication() will
        not be called again.
    ******************************************************************************/
    bool OGLESBasicTnL::InitApplication()
    {
     m_fAngle = 0;
     return true;
    }

    /*!****************************************************************************
     @Function  QuitApplication
     @Return  bool  true if no error occured
     @Description Code in QuitApplication() will be called by PVRShell once per
        run, just before exiting the program.
        If the rendering context is lost, QuitApplication() will
        not be called.
    ******************************************************************************/
    bool OGLESBasicTnL::QuitApplication()
    {
        return true;
    }

    /*!****************************************************************************
     @Function  InitView
     @Return  bool  true if no error occured
     @Description Code in InitView() will be called by PVRShell upon
        initialization or after a change in the rendering context.
        Used to initialize variables that are dependant on the rendering
        context (e.g. textures, vertex buffers, etc.)
    ******************************************************************************/
    bool OGLESBasicTnL::InitView()
    {
     // Fragment and vertex shaders code
     char* pszFragShader = "\
      uniform sampler2D sampler2d;\
      varying mediump float varDot;\
      varying mediump vec2 varCoord;\
      void main (void)\
      {\
          gl_FragColor = texture2D(sampler2d,varCoord) * varDot;\
      }";

     char* pszVertShader = "\
      attribute highp vec4 myVertex;\
      attribute mediump vec3 myNormal;\
      attribute mediump vec4 myUV;\
      uniform mediump mat4 myPMVMatrix;\
      uniform mediump mat3 myModelViewIT;\
      uniform mediump vec3 myLightDirection;\
      varying mediump float varDot;\
      varying mediump vec2 varCoord;\
      void main(void)\
      {\
       gl_Position = myPMVMatrix * myVertex;\
       varCoord = myUV.st;\
       mediump vec3 transNormal = myModelViewIT * myNormal;\
       varDot = max( dot(transNormal, myLightDirection), 0.0 );\
      }";

     // Create the fragment shader object
     m_uiFragShader = glCreateShader(GL_FRAGMENT_SHADER);

     // Load the source code into it
     glShaderSource(m_uiFragShader, 1, (const char**)&pszFragShader, NULL);

     // Compile the source code
     glCompileShader(m_uiFragShader);

     // Check if compilation succeeded
     GLint bShaderCompiled;
        glGetShaderiv(m_uiFragShader, GL_COMPILE_STATUS, &bShaderCompiled);
     if (!bShaderCompiled)
     {
      // An error happened, first retrieve the length of the log message
      int i32InfoLogLength, i32CharsWritten;
      glGetShaderiv(m_uiFragShader, GL_INFO_LOG_LENGTH, &i32InfoLogLength);

      // Allocate enough space for the message and retrieve it
      char* pszInfoLog = new char[i32InfoLogLength];
            glGetShaderInfoLog(m_uiFragShader, i32InfoLogLength, &i32CharsWritten, pszInfoLog);

      /*
       Displays the message in a dialog box when the application quits
       using the shell PVRShellSet function with first parameter prefExitMessage.
      */
      char* pszMsg = new char[i32InfoLogLength+256];
      sprintf(pszMsg, "Failed to compile fragment shader: %s", pszInfoLog);
      PVRShellSet(prefExitMessage, pszMsg);
      delete [] pszMsg;
      delete [] pszInfoLog;
      return false;
     }

     // Loads the vertex shader in the same way
     m_uiVertexShader = glCreateShader(GL_VERTEX_SHADER);
     glShaderSource(m_uiVertexShader, 1, (const char**)&pszVertShader, NULL);
     glCompileShader(m_uiVertexShader);
        glGetShaderiv(m_uiVertexShader, GL_COMPILE_STATUS, &bShaderCompiled);
     if (!bShaderCompiled)
     {
      int i32InfoLogLength, i32CharsWritten;
      glGetShaderiv(m_uiVertexShader, GL_INFO_LOG_LENGTH, &i32InfoLogLength);
      char* pszInfoLog = new char[i32InfoLogLength];
            glGetShaderInfoLog(m_uiVertexShader, i32InfoLogLength, &i32CharsWritten, pszInfoLog);
      char* pszMsg = new char[i32InfoLogLength+256];
      sprintf(pszMsg, "Failed to compile vertex shader: %s", pszInfoLog);
      PVRShellSet(prefExitMessage, pszMsg);
      delete [] pszMsg;
      delete [] pszInfoLog;
      return false;
     }

     // Create the shader program
        m_uiProgramObject = glCreateProgram();

     // Attach the fragment and vertex shaders to it
        glAttachShader(m_uiProgramObject, m_uiFragShader);
        glAttachShader(m_uiProgramObject, m_uiVertexShader);

     // Bind the custom vertex attribute "myVertex" to location VERTEX_ARRAY
        glBindAttribLocation(m_uiProgramObject, VERTEX_ARRAY, "myVertex");
     // Bind the custom vertex attribute "myUV" to location TEXCOORD_ARRAY
        glBindAttribLocation(m_uiProgramObject, TEXCOORD_ARRAY, "myUV");


     // Link the program
        glLinkProgram(m_uiProgramObject);

     // Check if linking succeeded in the same way we checked for compilation success
        GLint bLinked;
        glGetProgramiv(m_uiProgramObject, GL_LINK_STATUS, &bLinked);
     if (!bLinked)
     {
      int i32InfoLogLength, i32CharsWritten;
      glGetProgramiv(m_uiProgramObject, GL_INFO_LOG_LENGTH, &i32InfoLogLength);
      char* pszInfoLog = new char[i32InfoLogLength];
      glGetProgramInfoLog(m_uiProgramObject, i32InfoLogLength, &i32CharsWritten, pszInfoLog);
      char* pszMsg = new char[i32InfoLogLength+256];
      sprintf(pszMsg, "Failed to link program: %s", pszInfoLog);
      PVRShellSet(prefExitMessage, pszMsg);
      delete [] pszMsg;
      delete [] pszInfoLog;
      return false;
     }

     // Actually use the created program
     glUseProgram(m_uiProgramObject);

     // Sets the sampler2D variable to the first texture unit
     glUniform1i(glGetUniformLocation(m_uiProgramObject, "sampler2d"), 0);


     // Sets the clear color
     glClearColor(0.6f, 0.8f, 1.0f, 1.0f);

     /*
      Creates the texture.
      Please refer to the training course "Texturing" for a detailed explanation.
     */
     glGenTextures(1, &m_uiTexture);
     glBindTexture(GL_TEXTURE_2D, m_uiTexture);
     GLuint* pTexData = new GLuint[TEX_SIZE*TEX_SIZE];
     for (int i=0; i<TEX_SIZE; i++)
     for (int j=0; j<TEX_SIZE; j++)
     {
      GLuint col = (255L<<24) + ((255L-j*2)<<16) + ((255L-i)<<8) + (255L-i*2);
      if ( ((i*j)/8) % 2 ) col = (GLuint) (255L<<24) + (255L<<16) + (0L<<8) + (255L);
      pTexData[j*TEX_SIZE+i] = col;
     }
     glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, TEX_SIZE, TEX_SIZE, 0, GL_RGBA, GL_UNSIGNED_BYTE, pTexData);
     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
     delete [] pTexData;

     return true;
    }

    /*!****************************************************************************
     @Function  ReleaseView
     @Return  bool  true if no error occured
     @Description Code in ReleaseView() will be called by PVRShell when the
        application quits or before a change in the rendering context.
    ******************************************************************************/
    bool OGLESBasicTnL::ReleaseView()
    {
     // Frees the texture
     glDeleteTextures(1, &m_uiTexture);

     // Frees the OpenGL handles for the program and the 2 shaders
     glDeleteProgram(m_uiProgramObject);
     glDeleteShader(m_uiVertexShader);
     glDeleteShader(m_uiFragShader);
     return true;
    }

    /*!****************************************************************************
     @Function  RenderScene
     @Return  bool  true if no error occured
     @Description Main rendering loop function of the program. The shell will
        call this function every frame.
        eglSwapBuffers() will be performed by PVRShell automatically.
        PVRShell will also manage important OS events.
        Will also manage relevent OS events. The user has access to
        these events through an abstraction layer provided by PVRShell.
    ******************************************************************************/
    bool OGLESBasicTnL::RenderScene()
    {
     float aModelViewIT[] =
     {
      cos(m_fAngle), 0, sin(m_fAngle),
      0,    1, 0,
      -sin(m_fAngle), 0, cos(m_fAngle)
     };

     // Clears the color and depth buffer
     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

     /*
      Bind the projection model view matrix (PMVMatrix) to the
      corresponding uniform variable in the shader.
      This matrix is used in the vertex shader to transform the vertices.
     */
     float aPMVMatrix[] =
     {
      cos(m_fAngle), 0, sin(m_fAngle), 0,
      0,    1, 0,    0,
      -sin(m_fAngle), 0, cos(m_fAngle), 0,
      0,    0, 0,    1
     };
     int i32Location = glGetUniformLocation(m_uiProgramObject, "myPMVMatrix");
     glUniformMatrix4fv( i32Location, 1, GL_FALSE, aPMVMatrix);

     /*
      Bind the Model View Inverse Transpose matrix to the shader.
      This matrix is used in the vertex shader to transform the normals.
     */
     i32Location = glGetUniformLocation(m_uiProgramObject, "myModelViewIT");
     glUniformMatrix3fv( i32Location, 1, GL_FALSE, aModelViewIT);

     // Bind the Light Direction vector to the shader
     i32Location = glGetUniformLocation(m_uiProgramObject, "myLightDirection");
     glUniform3f( i32Location, 0, 0, 1);

     // Increments the angle of the view
     m_fAngle += .02f;

     /*
      Draw a triangle.
      Please refer to the training course IntroducingPVRShell for a detailed explanation.
     */

     // Pass the vertex data
     GLfloat afVertices[] = {-0.4f,-0.4f,0.0f, 0.4f,-0.4f,0.0f, 0.0f,0.4f,0.0f};
     glEnableVertexAttribArray(VERTEX_ARRAY);
     glVertexAttribPointer(VERTEX_ARRAY, 3, GL_FLOAT, GL_FALSE, 0, afVertices);

     // Pass the texture coordinates data
     GLfloat afTexCoord[] = {0.0f,0.0f, 1.0f,0.0f, 0.5f,1.0f};
     glEnableVertexAttribArray(TEXCOORD_ARRAY);
     glVertexAttribPointer(TEXCOORD_ARRAY, 2, GL_FLOAT, GL_FALSE, 0, afTexCoord);

     // Pass the normals data
     GLfloat afNormals[] = {0.0f,0.0f,1.0f, 0.0f,0.0f,1.0f, 0.0f,0.0f,1.0f};
     glEnableVertexAttribArray(NORMAL_ARRAY);
     glVertexAttribPointer(NORMAL_ARRAY, 3, GL_FLOAT, GL_FALSE, 0, afNormals);

     // Draws a non-indexed triangle array
     glDrawArrays(GL_TRIANGLES, 0, 3);

     return true;
    }

    /*!****************************************************************************
     @Function  NewDemo
     @Return  PVRShell*  The demo supplied by the user
     @Description This function must be implemented by the user of the shell.
        The user should return its PVRShell object defining the
        behaviour of the application.
    ******************************************************************************/
    PVRShell* NewDemo()
    {
     return new OGLESBasicTnL();
    }

    /******************************************************************************
     End of file (OGLESBasicTnL.cpp)
    ******************************************************************************/

  • In reply to Renaissance:

    Can anyone give me help on this issue?

    Thanks

     

    Renaissance

This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.