Archived

This topic is now archived and is closed to further replies.

unitilized objet?????????

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

in this http://cone3d.gamedev.net/cgi-bin/index.pl?page=tutorials/gfxsdl/tut3 tutorial he passes SDL_Rect sometimes initialized and some others with uninitialized members. WHY????????? like this:
{
  SDL_Rect dest;
  dest.x = x;
  dest.y = y;
  SDL_Rect dest2;
  dest2.x = x2;
  dest2.y = y2;
  dest2.w = w;
  dest2.h = h;
  SDL_BlitSurface(img, &dest2, screen, &dest);
}
and then this
{
  SDL_Rect dest;
  dest.x = mX; dest.y = mY;
  SDL_BlitSurface(mSpriteBase->mAnim[mFrame].image, NULL, mScreen, &dest);
}
( ok NULL is valid ) and in so many other examples why he doesn''t ALWAYS initialize the members of SDL_Rect object?? thanks

Share this post


Link to post
Share on other sites
Did you consider maybe reading the documentation for the SDL_BlitSurface() function? I''ll quote the relevant part:

Only the position is used in the dstrect (the width and height are ignored).

Share this post


Link to post
Share on other sites
Ok, SDLProgrammer, I hate to say this, though given your other many posts, I just have one thing to say. Please take it with a grain of salt.

RTFM

It's often as though the moment you hit a problem, no matter how minor, you turn to the boards for help. We're here to give you assistance, but the documentation and tutorials out there are often more than enough to answer the questions you ask. Do a little bit of ressearch before posting - the forum faq asks of it, in any event.

[edited by - RuneLancer on May 29, 2004 10:11:40 AM]

Share this post


Link to post
Share on other sites
Many thanks for the replly !

RuneLancer, why don''t you believe me? I always see the documentation at the first place. How many times do i have to tell you? I ***did that *and* with this problem***. However, i remember seeing in the codes of the tutorial a snippet of code which the author passed uninitialized the w & h members of the first SDL_Rect argument. Maybe the examples i posted don''t show that, but maybe later when i have time i''ll find the snippet and post it here..

Share this post


Link to post
Share on other sites
Often, when unitialized stuff is passed, it''s because...

1) The part that initalizes it is not shown.
2) A reference to the variable is passed, in which case THAT''S the place where the variable is initialized. The function will return a value through that variable.

Chances are it''s 1 here.

Share this post


Link to post
Share on other sites