Problem With Creating Polygon Class

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

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 on other sites
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 on other sites
Also, this:

FACE* ptrFace = m_pFaces[0];

Should probably be:

FACE* ptrFace = &m_pFaces[0];

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;
};

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.

1. 1
Rutin
27
2. 2
3. 3
4. 4
5. 5

• 11
• 11
• 10
• 13
• 20
• Forum Statistics

• Total Topics
632948
• Total Posts
3009399
• Who's Online (See full list)

There are no registered users currently online

×