Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7574631
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T16:28:57+00:00 2026-05-30T16:28:57+00:00

I am having a problem to upgrade a program to shaders in OGLES 2.

  • 0

I am having a problem to upgrade a program to shaders in OGLES 2.

This is the data structure:

namespace packt {
class GraphicsService {
public:
 ...
   struct ESMatrix{ GLfloat m[4][4]; };

    typedef struct
    {  // Handle to a program object
       GLuint programObject;
       // Attribute locations
       GLint  positionLoc;
       // Uniform locations
       GLint  mvpLoc;
       // Vertex data
       GLfloat  *vertices;
       GLuint   *indices;
       int       numIndices;
       // Rotation angle
       GLfloat   angle;
       // MVP matrix
       ESMatrix  mvpMatrix;
    } UserData;
...
  }
}

In android_main the context is set:

packt::GraphicsService lGraphicsService(pApplication,&lTimeService);
packt::Context lContext = { &lGraphicsService, &lTimeService };

But then instead of using glColor4f, which is not part of OGLES 2, now we are trying to replace that command by shaders. Here is how it goes to the setup method:

void GraphicsService::setup() {
    glEnable(GL_TEXTURE_2D);
        GLbyte vShaderStr[] =
           "uniform mat4 u_mvpMatrix;                   \n"
           "attribute vec4 a_position;                  \n"
           "void main()                                 \n"
           "{                                           \n"
           "   gl_Position = u_mvpMatrix * a_position;  \n"
           "}                                           \n";

        GLbyte fShaderStr[] =
           "precision mediump float;                            \n"
           "void main()                                         \n"
           "{                                                   \n"
           "  gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );        \n"
           "}                                                   \n";
        // Load the shaders and get a linked program object

        // replaced :: //glColor4f(1.0f, 1.0f, 1.0f, 1.0f); 
        UserData *userData = mContext->userData;
        userData->programObject = esLoadProgram (vShaderStr, fShaderStr);
    glDisable(GL_DEPTH_TEST);
}

Which gives the following compiler’s message:

error: UserData *userData = mContext->userData;
    - 'void*' is not a pointer-to-object type
error: userData->programObject = esLoadProgram (vShaderStr, fShaderStr);
    - invalid conversion from 'GLbyte*' to 'const char*'
    - initializing argument 1 of 'GLuint esLoadProgram(const char*, const char*)'
    - initializing argument 2 of 'GLuint esLoadProgram(const char*, const char*)'

Any suggestion how to fix it? All comments are highly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T16:28:59+00:00Added an answer on May 30, 2026 at 4:28 pm

    1.

    The context object, pointed to by mContext, contains a “userData” field, which is probably declared to be a void*. You are storing a pointer to your actual UserData object in that field. Conversion from UserData* to void* works implicitly, but to get a UserData* from a void*, you need an explicit cast:

    UserData *userData = reinterpret_cast<UserData*>( mContext->userData );
    

    Note that reinterpret_cast is potentially dangerous; when you use it, make sure that your void* really came from a UserData* in the first place, otherwise Bad Things Will Happen.

    2.

    The error message says it all: esLoadProgram expects arguments of type const char*, and you are passing arguments of type GLbyte*. Declare your vShaderStr and fShaderStr appropriately, as in:

    const char *vShaderStr =
        "uniform ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having problem when running my Windows Forms program. In the program, I have
I'm having problem selecting an element with an id like this <li =0f:Bactidol_Recorder.mp4>. I
Im having a problem where we run an upgrade for our web application. After
This is a really weird problem that I have been having. When I download
Having problem with the middle Div not expanding to the width http://acs.graphicsmayhem.com/images/middiv.jpg Ok, how
We're having problem with a huge number of legacy stored procedures at work. Do
I'm having problem in the following line: rd.PrintOptions.PaperSize = PaperSize.PaperFanfoldStdGerman; it throws an exception
We are having problem with the server migration. We have one application that are
I'm having problem with Rails plugin attachment_fu . On every upload, I get validation
i'm having problem to deal with charset in ruby on rails app, specificially in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.