Jump to content
  • Advertisement
Sign in to follow this  
Ainokea

md2 loading

This topic is 5013 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
Advertisement
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
My only problem was knowing if I had to use the same name or not. Thanks any ways and rating up for you.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!