Sign in to follow this  

md2 loading

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

I am reading a tutorial on md2 loading and all the structores for the md2 look like this:
typedef struct MD2_TEXTCOORD_TYP
{
     short u,v;
}MD2_TEXTCOORD, *MD2_TEXTCOORD_PTR;


and the tutorials also says that the data types must be identical to this. However I was wondering if I could do it like this:
struct MD2_TEXTCOORD
{
    short u,v;   //texture coodinate
};


and when I need a pointer I just declare that type as a pointer. I.E instead of this: foo(MD2_TEXTCOORD_PTR); I could do this: foo(MD2_TEXTCOORD *md2);

Share this post


Link to post
Share on other sites
Quote:
Original post by Ainokea
Quote:
Original post by nts

that should be fine, they are equivalent

thanks. rating up up for you.


Wow all it took was 7 words, :D

Thanks, now i hope i wasn't horribly wrong somehow :D

Share this post


Link to post
Share on other sites
their equivalent assuming your programming in c++. if your in c, the typedef helps you. You see, when you declare a struct in c, it looks like this

//DEFINITION
struct MyStruct
{
int Content1;
int Content2;
};

int main()
{
struct MyStruct WhateverImGonnaCallThisVar; //the actual DECLARATION

WhateverImGonnaCallThisVar.Content1 = 0;

return 0;
}

******************************

with c++, the struct is optional, however, the typedef version, eliminates the need for the struct in the declaration (in both c and c++) but if your programming in c++, dont do the typedef

EDIT: to clarify, no matter what you do (in c or c++), you need the struct keyword before the definition of the class

hope that helps
-Dan

Share this post


Link to post
Share on other sites

This topic is 4818 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this