comparison 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
comparison
equal deleted inserted replaced
424:e29fbf84cb41 425:ad7969d9460b
60 m_rows = 0; 60 m_rows = 0;
61 m_cols = 0; 61 m_cols = 0;
62 m_last_col_width = 0; 62 m_last_col_width = 0;
63 m_last_row_height = 0; 63 m_last_row_height = 0;
64 m_chunk_size = RenderBackend::instance()->getChunkingSize(); 64 m_chunk_size = RenderBackend::instance()->getChunkingSize();
65 m_colorkey = RenderBackend::instance()->getColorKey();
65 } 66 }
66 67
67 void GLImage::cleanup() { 68 void GLImage::cleanup() {
68 for (unsigned int i = 0; i < m_rows*m_cols; ++i) { 69 for (unsigned int i = 0; i < m_rows*m_cols; ++i) {
69 glDeleteTextures(1, &m_textureids[i]); 70 glDeleteTextures(1, &m_textureids[i]);
229 230
230 for (unsigned int y = 0; y < data_chunk_height; ++y) { 231 for (unsigned int y = 0; y < data_chunk_height; ++y) {
231 for (unsigned int x = 0; x < data_chunk_width; ++x) { 232 for (unsigned int x = 0; x < data_chunk_width; ++x) {
232 unsigned int pos = (y + j*m_chunk_size)*pitch + (x + i*m_chunk_size) * 4; 233 unsigned int pos = (y + j*m_chunk_size)*pitch + (x + i*m_chunk_size) * 4;
233 234
234 // FIXME 235 uint8_t r = data[pos + 3];
235 // The following code might not be endianness correct 236 uint8_t g = data[pos + 2];
236 237 uint8_t b = data[pos + 1];
237 uint8_t r = data[pos + 0]; 238 uint8_t a = data[pos + 0];
238 uint8_t g = data[pos + 1]; 239
239 uint8_t b = data[pos + 2]; 240 if (RenderBackend::instance()->isColorKeyEnabled()) {
240 uint8_t a = data[pos + 3]; 241 // only set alpha to zero if colorkey feature is enabled
241 242 if (r == m_colorkey.r && g == m_colorkey.g && b == m_colorkey.b) {
242 oglbuffer[(y*chunk_width) + x] = (r << 24) | (g << 16) | (b << 8) | a; 243 a = 0;
244 }
245 }
246
247 oglbuffer[(y*chunk_width) + x] = r | (g << 8) | (b << 16) | (a<<24);
243 } 248 }
244 } 249 }
245 250
246 // get texture id from opengl 251 // get texture id from opengl
247 glGenTextures(1, &m_textureids[j*m_cols + i]); 252 glGenTextures(1, &m_textureids[j*m_cols + i]);