PDA

View Full Version : SDL OpenGL palletised mode



Crisp_N_Dry
21-07-2005, 08:51 PM
I'm quite a big fan of 640x480x8 bit graphics and would like to start work on an OpenGL version of my current SDL isometric engine. What I'm wondering is if OpenGl supports this or is there some kind of pallete emulation I would have to use. I've yet to learn how OpenGL works so i'd like to know where I stand on this issue before I make a commitment.

Paulius
21-07-2005, 10:03 PM
Not sure if any hardware OpenGL implementation ever supported a paletted window. There?¢_~s an extension for paletted textures, but unlike most others it is supported only on older cards.

cairnswm
22-07-2005, 05:13 AM
Not sure what you mean by palletised but I found getting OpenGL support into SDL very easy. You can do your image manipulation using SDL calls and bind them to OpenGL surfaces. This way you can do anything that SDL can do and just link it to display when needed.

Sly
22-07-2005, 06:50 AM
You may be able to use palletted textures, but you will restricted to a minimum of 16-bit colour for the display.

Crisp_N_Dry
22-07-2005, 08:20 PM
hmm, that's put the mockers on that idea. I wanted 256 color pallette so I could do some pallette swap trickery. Shame that, I guess I'll just have to go with the 16/32bit depth. Cheers for the help guys.

Traveler
22-07-2005, 09:02 PM
Am I correct when I say you want to use a 256 color pallette so you can use the same sprites but with a different color set?

If so, do you have any alternative ideas for this problem?

Paulius
22-07-2005, 10:46 PM
For custom player colors you could make a true color copy of the paletted image for each needed palett, something like day/night lighting can be done by blending a colored polygon on top. There?¢_Ts no way to emulate more complex palette effects, but hey, I know of no game which actually made good use of them.

cairnswm
23-07-2005, 07:44 AM
On my list of 'things I'll do one day' is a method of making units in a game display in multiple colors - the plan is as follows.

Each image is made up of two layers - the first layer is the layer where everything is the same accross all units - skin, boots etc. The second layer is the coloured/personalised layer - uniform etc. All units use the same first layer, and each faction has a customized second layer.

The reason to do it in a second layer is to allow ingame changes to colors. If the second layer is created using a gray scale, its easy per pixed to change the image to red/green or turquoise - just by adjusting each pixed.

Paulius
23-07-2005, 08:15 AM
With a multipass approach like cairnswm suggested you can just modulate texture color with polygon color, but it can only work with single hue, if you want different hues like some parts red and some parts blue then making true color image versions on load is going to be more reasonable then resorting to many passes.

Traveler
23-07-2005, 10:49 AM
Ok,... so when drawing the sprite do you just draw two textures and blend them together or do you create a third texture, say, before the start of the level?
The second option sounds better/faster, but perhaps I'm missing something?

Sly
23-07-2005, 12:52 PM
In Game Programming Gems 4 there is a whole article on different methods of doing team colours. The algorithms they discuss are
- unique textures for each team colour
- tinting model polygons to the appropriate team colour
- texture masking using multitexturing
- texture masking using multiple passes
- advanced pixel shader effects
They describe the advantages and disadvantages of each approach, and provide a sample DirectX implementation of each. If you want more information on a certain approach, I'll spend some time to copy that part of the article over from the book.