Jump to content
  • Advertisement
Sign in to follow this  
WithoutRemorse

Problem With Creating Polygon Class

This topic is 4855 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

Having fiddled around with my program for a while adding all sorts of new functionality, it seems to me more and more that I need a polygon class that can manage polygon information for multiple uses beyond simple rendering; collision detection, frustum culling, position/orientation manipulation, etc. As a base to begin this segment of my project I'm using the code from NeHe article 7 (http://nehe.gamedev.net/data/articles/article.asp?article=07), however I've been running into some difficult problems. First, under the Draw() method I get error error C2440: 'initializing' : cannot convert from 'struct FACE' to 'struct FACE *' FACE* ptrFace = m_pFaces[0]; m_pFaces is defined in our polygon's public class: FACE* m_pFaces; The only solution I could find to compile was to eliminate the '[0]' from m_pFaces. Second, I get error C2664: 'glVertex3fv' : cannot convert parameter 1 from 'struct VERTEX *' to 'const float *' glVertex3fv(&m_pVertices[ptrIndex++->nVertex]); I absolutely cannot figure this one out. Can anyone help me with this, or give alternate suggestions for creating a polygon class?

Share this post


Link to post
Share on other sites
Advertisement
im not sure what your doing with your polygon class, but the first error:


//First, under the Draw() method I get error error C2440:
//'initializing' : cannot convert from 'struct FACE' to 'struct FACE *'
FACE* ptrFace = m_pFaces[0];

//m_pFaces is defined in our polygon's public class:
FACE* m_pFaces;




You aren't initializing m_pFaces as an array of FACE objects like:
FACE* m_pFaces = new FACE[100];

Then you should be able to set your other pointer to index 0.

I'm not sure what else your trying to do.

Share this post


Link to post
Share on other sites
Quote:
Second, I get error C2664: 'glVertex3fv' : cannot convert parameter 1 from 'struct VERTEX *' to 'const float *'

glVertex3fv(&m_pVertices[ptrIndex++->nVertex]);


Can you please show your VERTEX struct? My best bet is that you should change this to

glVertex3fv(&m_pVertices[ptrIndex++->nVertex][0]);

-or-

glVertex3fv(&m_pVertices[ptrIndex++->nVertex].x);

The first assumes you have done this:
typedef VERTEX float[3];

the second: this

struct VERTEX
{
   float x;
   float y;
   float z;
};

If it's something else, please share it so we can try to help you further.

Share this post


Link to post
Share on other sites
Thanks, jyk and ms291052. I don't know why I didn't think of making

FACE* ptrFace = m_pFaces[0];

into:

FACE* ptrFace = &m_pFaces[0];

And yes ms, VERTEX is defined in the second way you described. Although I'm making it into:

glVertex3fv(&m_pVertices[ptrIndex++->nVertex].x),
glVertex3fv(&m_pVertices[ptrIndex++->nVertex].y),
glVertex3fv(&m_pVertices[ptrIndex++->nVertex].z);

to bind to a 3D point instead of just somewhere along the x axis. Although looking back on the code these solutions seem obvious now I couldn't figure it out at the time. Thanks again.

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!