I took this part out..It really wasn't constructive at all.
Texture Colors Not exact as Texture
mhagain -- I don't appreciate you pointing out the flaws in my code. Please refrain from posting suggestions relating to other people's posts.^^ Fixed that for you.
V-man -- Can you please explain the modern alternative for producing mipmaps?
Yann L -- Can you please explain what part of that code evokes undefined behaviour, and why it's at risk of leaking memory?
When someone else comes along and says, "You know, that way is deprecated; we use bricks and mortar now," he or she has given an answer that may be more suitable to the original person seeking advice.
In the pursuit of knowledge one must never be stuck in his or her own ways, and admit one's shortcomings with a smile as new things or ways are learned.
I would not be offended if someone suggested a better way than my own. Why were you?
One of the reasons I post here so often is because I can also learn when I give less-than-the-best advice and someone comes along and corrects it. I think I am pretty useful and help often, but I also say stupid things at times and make poor suggestions.
Your reaction to having been corrected is off-the-wall.
Also, Yann L showed you exactly where the error is.
You [or whomever] used new [] but not delete []. You [or whomever] used plain delete.
Instead of looking with an open mind and saying, "Oh I see, I made a mistake. Thank you for finding that because the quality of my software has increased because of it," you just screamed how correct the code is based on it working "on every computer", which is something you didn't even test, and stomped off with flawed code.
L. Spiro
Actually L. Spiro. YOU told us exactly where this particular error is. The other person re-wrote the same mistake and said it was wrong without the correction that you presented. Maybe to you it was obvious that [] should have been added, but not to everyone. I do not get upset because I was corrected, I wasn't corrected, I was instead heckled for attempting to help. If I were building a house as you say and someone came by and critisized me for doing it wrong, then turned around and walked away without any clearly stated "help", I would have no respect for this person's opinion. If those people had put things nicely, and had given some useful advice I would have followed it. If that is how the "experts" around here behave then it is clear that the "experts" need to be told how to behave properly. It rubs me the wrong way when no-it-alls use what they "know" to make themselves feel superior. Simply put, I overreacted, but what I reacted to was most certainly something to react to. And by the way, I've tested that code extensively on many different computers with very different hardware and it works beautifully. I re-compile sometimes half-a-dozen times every few minutes. I have also used this code to load 240 pictures at 1024x1024 all at the same time, if there really were memory leaks and corruption it would have been very obvious, these computers would crash. Maybe the Dev-Cpp compiler fixes errors like these automatically, I will however take you advice on this matter and make the appropriate correction:delete[]. I am aware that Nvidia has posted a document called "fast texture transfers" and in this document it is pointed out that BGR should be used but in most cases even they say that it has little or no performance increase. The response I received was snarky and overblown. I escalated things and I'm sorry.
I have done quite a bit of benchmarking of texture uploads using different format and type parameters, and GL_BGRA is actually the one to use. ;)
Not even mentioning that the code above invokes undefined behaviour and could possibly lead to memory leaks or even severe heap corruption.[/quote]
The code posted was bad. For instance why make a new array instead of just swapping the r,g,b values in the original array?
Send your pointless little snippet to the people who built freeImage and tell them that their software isn't written properly.[/quote]
Just because someone gave away free code doesn't mean it is good. It really was bad code, and was a memory leak.
The problem was already solved anyway and then you posted a ton of code and more work than the standard solution of GL_BGR. You can also google things like gluBuild2DMipMaps and find out why he is saying not to use it.
http://www.opengl.org/wiki/Common_Mistakes#GL_TEXTURE_MAG_FILTER
and also
http://www.opengl.org/wiki/Common_Mistakes#Automatic_mipmap_generation