PNG inclusions

I really dislike BMP format and I don't know why really. It seems outdated, limited and weak in design. The dice image is from an article at Wikipedia about png formats. As you can see it is transparent where it should be and now I am thinking I will spend some more time and make some better PNG textures for the game with InkScape, Blender and the Gimp. I like the looks of it and it is fun to play with. I suppose I will have to make some help and support it if people actually want to play it.

I think I said I would do some png implementation before I left the game to somebody else to play with. And so here it is. I used libpng and it is reasonably simple to apply. I found an example that used C++ and I am not enthused at all about "new" and "delete[]". I prefer to know what memory I have allocated and keep it in a list so I can debug if I want. I noticed while going through some tutorials on the web that many people have error returns with malloc(x) and I think that you are pretty well done for if you can't allocate memory for process. That is just my opinion. Why warn somebody that the machine is useless?

I also noticed that there is a lot of marginal code wandering about. I know that Ms sells its marginal code as shiny new bits, but other people generate some iffy stuff at times too. One of the issues is "code rot". If the code is not updated for changes in libraries and machines it decays. I found many places where people forgot to consider endedness and integer size. I wonder what is going to happen when we have 128 bit machines as a standard? I use a 64 bit machine and I quite often encounter bit rot in applications. It seems that debian and Linux are keeping up to date, quite well. I would guess that Linux would be implement 128 bit years before Ms, because they have the test framework, and design methodology to certify the function of the code. I suppose that is why Linux shows up so many places, so quickly, it is a designed to be inherently portable.

My brain is suffering from code rot too and I need to get away from programming for a while. I guess we will see how that goes.

/* set the individual row_pointers to point at the correct offsets of image_data*/ for (i = 0; i < height; ++i) {row_pointers[height - 1 - i] = (void *)(image1->data + i * rowbytes);} /* read the png into image_data through row_pointers */ png_read_image(png_ptr, row_pointers); /* Now generate the OpenGL texture object*/ glBindTexture(GL_TEXTURE_2D,texture[textureNum]); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); glTexImage2D(GL_TEXTURE_2D,0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid*) image1->data); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);

I think there is something potentially wrong going on here and it is one of those things that creeps up from behind and bites later. I have a question as to how libpng determines the size of pointers? It could decide from the system itself and it must, so I guess it is okay, as it didn't go wandering off into NULL space. :)

0 comments:

Contributors

Automated Intelligence

Automated Intelligence
Auftrag der unendlichen LOL katzen