Few questions (okay, in fact: lots of questions)

Started by
23 comments, last by Marco H 19 years, 4 months ago
They are flipped compared to TGA and BMPm so I think the mistake is to be found at the JPEG loading.
I can not change the loading routines, as they are delivered in a library, but I can try to swap the bytes in order to get the desired look, right?
Advertisement
Well.

Id guess the jpg loading is correct as it is since both TGA and BMP most commonly is saved upside down.

At least Photoshop, Paint Shop Pro, Gimp and Windows Paint all save them upside down.

So most likely your texcoords so far is upside down to "fix" the fact all the TGA's and BMP are loaded upside down.
BMPs are saved upside down? I did not know... but if they are saved in that way, they should be mirrored horizontally and vertically, not only horizontally, or not?
Only horizontally.
Thanks a lot, I did it now :)

But another question - lc_overlord said I should use PNGs as images. Right now I tried to google some infomation or a kind of tutorial about that, bu I had no success.

Do you know where I can find a tutorial or something like that to show how to load PNGs? I do not want to use SDL oder OpenIL, if not neccessary...

Thanks in advance,
Marco
I just got a couple of sites out of google, but I have to warn you that PNG loading doesn't seem so easy to me (at least judging by the lenght of these pages)

http://netghost.narod.ru/gff/graphics/summary/png.htm
http://www.corion.net/cgi-bin/wiki.cgi/display/Format:PNG

Both these links (or any other like these) give you information about how data is stored in a PNG file.
I'm not really sure this is what you're looking for.
I have been looking for some examples, but the links are also good, thanks :)

And I have another question: if I have a structure like that:
struct something{    int static_one;    int * dynamic_one;};

and I allocate it like that:
//...something * anything = new something;anything->dynamic_one = new int[10];//...

After using the structure I do not have any use for it, so I want to delete it. Do I have to delete the "dynamic_one"-array before deleting the whole structure or may it even end in an access violation?

(as always) Thanks in advance,
Marco (the guy who loves this forum)
Quote:Original post by Marco H
After using the structure I do not have any use for it, so I want to delete it. Do I have to delete the "dynamic_one"-array before deleting the whole structure or may it even end in an access violation?

You have to delete "dynamic_one" before deleting "something". It won't cause access violiation but it will be a memory leak. My sugestion would be to use destructor for this.
class something {    int static_one;    int * dynamic_one;    something() {        dynamic_one = NULL;    }    ~something() {        if ( dynamic_one != NULL ) delete[] dynamic_one;    }    // other methods...};
You should never let your fears become the boundaries of your dreams.
Okay, thanks, it is a nice tip :)

In fact I am trying to find a strange in my program. I found out, that it crashes on calls like "num_vertices = new word;" or things like that (only normal allocations). So I think that I have a memory leak somewhere... or what do you think?

One more thing: declarations like "char anyChar[32];" do not have to be deleted, or?
(You see, I am looking intensivly for an error...)
A memory leak is when you allocate some memory using the new operator, and forget to delete it again.

Consider the following code:
char *string = new char[32];


This will require that you also delete:
delete[] string;


the [] is used because it was allocated as an array.

Now, if you just declare the array, like so:
char string[32];

there's no need to delete it, because you haven't actually used the new operator.

This topic is closed to new replies.

Advertisement