Mercurial > fife-parpg
diff engine/core/video/opengl/glimage.cpp @ 425:ad7969d9460b
A client can now specify a global color key to be used with all images. The default color key is (255,0,255) in RGB format. Also the client can enable/disable the color key feature by using the setColorKeyEnabled function in the EngineSettings class. By default the color key feature is disabled. fixes[t:451]
author | vtchill@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Sat, 20 Feb 2010 19:11:01 +0000 |
parents | 10e0687a4cec |
children | ad1f09d954f9 |
line wrap: on
line diff
--- a/engine/core/video/opengl/glimage.cpp Fri Feb 12 22:00:58 2010 +0000 +++ b/engine/core/video/opengl/glimage.cpp Sat Feb 20 19:11:01 2010 +0000 @@ -62,6 +62,7 @@ m_last_col_width = 0; m_last_row_height = 0; m_chunk_size = RenderBackend::instance()->getChunkingSize(); + m_colorkey = RenderBackend::instance()->getColorKey(); } void GLImage::cleanup() { @@ -231,15 +232,19 @@ for (unsigned int x = 0; x < data_chunk_width; ++x) { unsigned int pos = (y + j*m_chunk_size)*pitch + (x + i*m_chunk_size) * 4; - // FIXME - // The following code might not be endianness correct + uint8_t r = data[pos + 3]; + uint8_t g = data[pos + 2]; + uint8_t b = data[pos + 1]; + uint8_t a = data[pos + 0]; - uint8_t r = data[pos + 0]; - uint8_t g = data[pos + 1]; - uint8_t b = data[pos + 2]; - uint8_t a = data[pos + 3]; + if (RenderBackend::instance()->isColorKeyEnabled()) { + // only set alpha to zero if colorkey feature is enabled + if (r == m_colorkey.r && g == m_colorkey.g && b == m_colorkey.b) { + a = 0; + } + } - oglbuffer[(y*chunk_width) + x] = (r << 24) | (g << 16) | (b << 8) | a; + oglbuffer[(y*chunk_width) + x] = r | (g << 8) | (b << 16) | (a<<24); } }