ThreaderSlash
ThreaderSlash

Reputation: 1313

Android OpenGL: GLbyte LoadShader conversion

I have an issue about type compatibility - check this example:

 GLbyte vShaderStr[] =
  "attribute vec4 vPosition;    \n"
  "void main()                  \n"
  "{                            \n"
  "   gl_Position = vPosition;  \n"
  "}                            \n";

 vertexShader = LoadShader ( GL_VERTEX_SHADER, vShaderStr );

The LoadShader belongs the esUtil.h http://code.google.com/p/angleproject/source/browse/trunk/samples/gles2_book/Common/esUtil.h and the code is the original from the same book OpenGL ES 2.0 Programming Guide.

Which give the following message:

error: vertexShader = LoadShader(GL_VERTEX_SHADER, vShaderStr);
       Multiple markers at this line
   - initializing argument 2 of 'GLuint LoadShader(GLenum, const char*)'
   - invalid conversion from 'GLbyte*' to 'const char*'

Someone can shed some light... how to solve this issue on 'GLbyte*' to 'const char*'.

If I simply try to not use GLbyte, and declare instead:

const char* vShaderStr[] ={...};

The error changes for:

cannot convert 'const char**' to 'const char*' for... 
   ...argument '2' to 'GLuint LoadShader(GLenum, const char*)'

OpenGL ES 2.0 is supposed to run in mobile, and so I am trying to compile and run the code samples for Android Native C++.

Somebody knows if is the code provided in this book plenty of bugs? Or am I doing something totally wrong? How to solve this conversion problem that is a constant throughout the book?

All comments are highly welcome.

Upvotes: 0

Views: 689

Answers (1)

Tom Whittock
Tom Whittock

Reputation: 4230

const char* vShaderStr[] is an array of pointers. Use const char vShaderStr[] instead

Upvotes: 2

Related Questions