Jump to content
  • Advertisement
Sign in to follow this  
giugio

OpenGL Vertex fload and opengl

This topic is 3667 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hy. I have a struct object VERTEX vertex1 ,where VERTEX struct is : struct VERTEX { const GLfloat* val[]; }; and i would to draw without specify x,y and z as property,i simply pass:: glVertex3fv(vertex1); but i catch this error: c:\programmazione\vcopengl\3dprojectgiugio\3dprojectgiugio\polygon.cpp(34) : error C2664: 'glVertex3fv' : cannot convert parameter 1 from 'const GLfloat *(*__w64 )[]' to 'const GLfloat *' How pass VERTEX type as parameter? thanks

Share this post


Link to post
Share on other sites
Advertisement
Are we talking about C or C++?
I think C++....

struct VERTEX
{
operator GLfloat*()
{
return val;
}
const GLfloat* val;
};

Now it should work.
regards...

Share this post


Link to post
Share on other sites
"const GLfloat* val[]" is the same as "const GLfloat** val;". glVertex3fv takes a GLfloat* as a parameter. For your VERTEX type to work, do something like :

struct VERTEX
{
const GLfloat val[];
};

Share this post


Link to post
Share on other sites
thanks , but i catch this error:
Error 3 error C2664: 'glVertex3fv' : cannot convert parameter 1 from 'const GLfloat (*__w64 )[]' to 'const GLfloat *' c:\progetto\graphlib\graphlib\polygon.cpp 35

but this work:

struct VERTEX
{
const GLfloat val;
};

but i dont have 3 parameters , so only one!

Share this post


Link to post
Share on other sites
i have disabilited the compile option for the 64 bit compatibility bu i catch always thi error:
Error 5 error C2664: 'glVertex3fv' : cannot convert parameter 1 from 'const GLfloat (*)[]' to 'const GLfloat *' c:\progetto\graphlib\graphlib\polygon.cpp 31
why?

Share this post


Link to post
Share on other sites
Quote:
Original post by giugio
struct VERTEX
{
const GLfloat val;
};

but i dont have 3 parameters , so only one!
What is wrong with this?
struct VERTEX
{
const GLfloat val[3];
};

Share this post


Link to post
Share on other sites
whith this i catch this error:
Error 4 error C2664: 'glVertex3fv' : cannot convert parameter 1 from 'const GLfloat (*)[3]' to 'const GLfloat *' c:\progetto\graphlib\graphlib\polygon.cpp 31

this is the code:
glVertex3fv(&m_vertexs[0].val);
where m_vertexs is a
VERTEX * m_vertexs;

Share this post


Link to post
Share on other sites
Just pass "m_vertexs[0].val". The array will decay to a pointer to the first element. Passing &array is passing a pointer to an array, which is a different beast entirely (which is what your compiler is warning you about).

Share this post


Link to post
Share on other sites
thanks a lot.
if i understand:
1)&m_vertexs[0].val
2)m_vertexs[0].val

1)is the address of the array 0 of elements
2)is the address of the first element of the array 0 of elements?

thanks

Share this post


Link to post
Share on other sites
Quote:
Original post by giugio
thanks a lot.
if i understand:
1)&m_vertexs[0].val
2)m_vertexs[0].val

1)is the address of the array 0 of elements
2)is the address of the first element of the array 0 of elements?

thanks


THose two statements are going to spit out the same memory address.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!