This is my first time using a graphics library and not just making command-line programs, and I'm having a bit of difficulty trying to use an image as a sprite. First of all, I made this picture with GIMP, and then I saved it as a XWindow Pixmap. Then, when I was looking into using that file as a sprite, I found that (from here: http://www.kerguelen...utorial-4.html) "Reading pixmaps from files and writing them to files is not possible with standard X libraries. For that, you need the Xpm library, which is installed by default on many systems." So I got stuck...
So then, I looked into the XImage structure (http://tronche.com/gui/x/xlib/utilities/XCreateImage.html) - I got that working... somewhat, but when I put the image on the screen, the color is all messed up. (I tried this saving my image as both a .h file or a pixmap file with GIMP). At first I thought it's because my image was fairly complex, so I tried using a basic 16x16 simple triangle with a few different colors, but again, the color was all messed up with using XPutImage. (By 'color all messed up', I mean that all of the pixels were the wrong color, and that the image didn't really appear well in the window).
I'm having a hard time finding resources about this online, and I was wondering if anyone could provide me a snippet that shows me how to take an image and place it on the screen (with proper color), and explain how it works.
I've attached the original image I was trying to get up on the screen (for testing purposes... wasn't going to use this as a sprite).
On a different note, I had another question. For the assignment I'm working on, we're working on this type of tower defense game. So I was thinking that when the using clicks on one of their towers, that it would show them it's radius in this somewhat transparent color... but I have no idea how to apply transparency with Xlib. (The same goes for the enemies life bar). Could somewhat tell me which functions I have to look at in order to accomplish this?
This post has been edited by LivingNightmare: 13 January 2011 - 08:37 AM