Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ C OpenGL
This is an opengl-es 2.0 code which is used to render triangles using the data from text file but the errors I am getting is not of opengl its general c or c++ error so if you can tell me anything about that , it would be great for me
glGenBuffers(surftotal, uiVBO);
{
    for(surfnum=0; surfnum<surftotal; ++surfnum)
    {
            glBindBuffer(GL_ARRAY_BUFFER, uiVBO[surfnum]);
            size_t buf_size = 9*sizeof(GLfloat)*triNum[surfnum];
            GLfloat* const pData = malloc(buf_size);
            for(i=0; i<triNum[surfnum]; ++i) {
                memcpy(pData+i*9,   triArray[surfnum][i].pt1, 3*sizeof(GLfloat));
                memcpy(pData+i*9+3, triArray[surfnum][i].pt2, 3*sizeof(GLfloat));
                memcpy(pData+i*9+6, triArray[surfnum][i].pt3, 3*sizeof(GLfloat));
            }
            glBufferData(GL_ARRAY_BUFFER, buf_size, pData, GL_STATIC_DRAW);
            free(pData);
    }   
    glBindBuffer(GL_ARRAY_BUFFER, 0);
    glEnableVertexAttribArray(VERTEX_ARRAY);
    for(surfnum=0; surfnum<surftotal; ++surfnum)
    {
            glBindBuffer(GL_ARRAY_BUFFER, uiVBO[surfnum]);
            glVertexAttribPointer(VERTEX_ARRAY, 3, GL_FLOAT, GL_FALSE, 0, 0);
            glDrawArrays(GL_TRIANGLES, 0, 3*triNum[surfnum]);
    }
    glBindBuffer(GL_ARRAY_BUFFER, 0);        //clean up, of course      

}   
 
But here it says
 
invalid conversion from 'void*' to 'GLfloat*'
 
Then I changed GLfloat to void again It says :
 
<pre lang="vb">src/Hello.cpp: In function 'int main(int, char**)':
src/Hello.cpp:281: warning: pointer of type 'void *' used in arithmetic
src/Hello.cpp:282: warning: pointer of type 'void *' used in arithmetic
src/Hello.cpp:282: warning: pointer of type 'void *' used in arithmetic
src/Hello.cpp:283: warning: pointer of type 'void *' used in arithmetic
src/Hello.cpp:283: warning: pointer of type 'void *' used in arithmetic
 
and because its warning there was a .exe file , when I try to compile it another
warning :
 
libEGL warning: use software fallback
 
after this a window pop up and goes nothing shown ... please elaborate me . I am not able to understand
also the other way to declare that glmapbufferOES don't work . If you want any other information or the whole code I can paste it.Waiting for reply
 
if you want anyother information please tell me.
hi I have there http://bit.ly/ny5IMa whole of my code can you tell me where is the problem
Posted 5-Jul-11 19:12pm
Edited 6-Jul-11 0:19am
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

It would help substantially if you would indicate which line the compiler has a problem with.
 
I suspect from a quick glance that it's this one:
GLfloat* const pData = malloc(buf_size);
 
In which case, you may want to remember to type-cast the result of the call to malloc. I.e
GLfloat* const pData = (GLfloat*)malloc(buf_size);
  Permalink  
Comments
sudhanshu2511 at 6-Jul-11 1:30am
   
yaah that was right I got it but the other warning
 
libEGL warning: use software fallback
 
is stilll there
enhzflep at 6-Jul-11 1:48am
   
You mention that you're writing openGL ES 2.0 code. Also, that you're using the Native Platform Graphics Interface Layer (libEGL)
 
I suspect from the error message that you've used a function that's (a) not supported by the hardware you're running on and that (b) the library isn't able to emulate the function that's causing the problem.
 
If you haven't already, it wouldn't be the worst thing you could do - to query the openGL hardware on the device running your software to ensure that it is indeed ogl es 2.0 compatible.
 
When I try to run ogl code that uses function not offered by my gpu, I get mixed and varied results. Anything from "Sorry, function XXXX not supported" to single-colored solid filled screen to a crash to a blank window to absolutely nothing.
sudhanshu2511 at 6-Jul-11 5:17am
   
Hi I have added a link where you can view my whole code , can you tell me where is the problem
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

I've looked (briefly) at your(?) code.
 
A couple of things I will point out:
1) Firstly, there's only 3 instance that I can see of error checking. I'm not convinced yet that you've really tried to discover where the problem is.
I don't see a single call to glError[^] anywhere!!
 
2) The data that the program depends on is not given nor explained. Depending on my mood I'll try to fix a program, but rarely, if ever, am I prepared to try to determine what the necessary feed-data is. How do I know that's not part of the screw-up error, after all?
 

 
Have you tried to trim the program back to the simplest program that will display a (fixed-pipeline) shaded quad?
 
Something else that's just occurred to me - what's the result of the attempt to compile and use the shader program? My laptop supports OpenGL 2.1, however it only supports GLSL version 1.2
Perhaps you've used code in your shader that is not supported by the GLSL implementation that you have? I'm certainly nobody to ask on things glsl related..
 
But depending on the setup of the environment and the polygons within it - you could see nothing as a direct consequence of the shaders not being compiled/linked correctly.
 
Looks like time you did some more investigating and less question-asking for a short-time. Don't suppose that this is an example of copy/paste programming is it?
 

Lastly, what's with the crazy-a$$ link you gave above?
The link you provide points to a page at code project. So, what's the go with http://bit.ly/ny5IMa[^]
and not the http://www.codeproject.com/script/Answers/Entry.aspx?aid=221622[^] that it is?
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 6,803
1 Sergey Alexandrovich Kryukov 6,377
2 DamithSL 5,421
3 Manas Bhardwaj 4,841
4 Maciej Los 4,330


Advertise | Privacy | Mobile
Web01 | 2.8.1411023.1 | Last Updated 6 Jul 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100