|
From: <cn...@us...> - 2009-06-25 04:08:10
|
Revision: 374
http://hgengine.svn.sourceforge.net/hgengine/?rev=374&view=rev
Author: cnlohr
Date: 2009-06-25 04:08:08 +0000 (Thu, 25 Jun 2009)
Log Message:
-----------
add white (luminance) as well as white_alpha (luminance_alpha)
This makes it possible to use our tighter packed textures and take up 1/2 the texture ram
Modified Paths:
--------------
Mercury2/src/PNGLoader.cpp
Mercury2/src/RawImageData.h
Mercury2/src/Texture.cpp
Modified: Mercury2/src/PNGLoader.cpp
===================================================================
--- Mercury2/src/PNGLoader.cpp 2009-06-25 03:29:06 UTC (rev 373)
+++ Mercury2/src/PNGLoader.cpp 2009-06-25 04:08:08 UTC (rev 374)
@@ -102,17 +102,43 @@
png_free_data(png_ptr, info_ptr, PNG_FREE_ALL, -1);
- if (color_type & PNG_COLOR_MASK_ALPHA)
- image->m_ColorByteType = RGBA;
+ if (color_type & PNG_COLOR_MASK_COLOR )
+ if (color_type & PNG_COLOR_MASK_ALPHA)
+ image->m_ColorByteType = RGBA;
+ else
+ image->m_ColorByteType = RGB;
else
- image->m_ColorByteType = RGB;
+ if (color_type & PNG_COLOR_MASK_ALPHA)
+ image->m_ColorByteType = WHITE_ALPHA;
+ else
+ image->m_ColorByteType = WHITE;
+
// SAFE_DELETE(texture->m_data);
image->m_data = new unsigned char[sizeof(unsigned char) * image->m_height * image->m_width * 4];
switch (image->m_ColorByteType)
{
+ case WHITE:
+ for ( y=0; y < (unsigned)image->m_height; ++y) {
+ png_byte* row = row_pointers[y];
+ for (unsigned long x = 0; x < image->m_width; ++x) {
+ png_byte* ptr = &(row[x]);
+ image->m_data[(x + y * image->m_width)] = ptr[0];
+ }
+ }
+ break;
+ case WHITE_ALPHA:
+ for ( y=0; y < (unsigned)image->m_height; ++y) {
+ png_byte* row = row_pointers[y];
+ for (unsigned long x = 0; x < image->m_width; ++x) {
+ png_byte* ptr = &(row[x*2]);
+ image->m_data[(x + y * image->m_width) * 2] = ptr[0];
+ image->m_data[(x + y * image->m_width) * 2 + 1] = ptr[1];
+ }
+ }
+ break;
case RGBA:
for ( y=0; y < (unsigned)image->m_height; ++y) {
png_byte* row = row_pointers[y];
Modified: Mercury2/src/RawImageData.h
===================================================================
--- Mercury2/src/RawImageData.h 2009-06-25 03:29:06 UTC (rev 373)
+++ Mercury2/src/RawImageData.h 2009-06-25 04:08:08 UTC (rev 374)
@@ -3,6 +3,8 @@
enum ColorByteType
{
+ WHITE,
+ WHITE_ALPHA,
RGB,
RGBA
};
Modified: Mercury2/src/Texture.cpp
===================================================================
--- Mercury2/src/Texture.cpp 2009-06-25 03:29:06 UTC (rev 373)
+++ Mercury2/src/Texture.cpp 2009-06-25 04:08:08 UTC (rev 374)
@@ -52,6 +52,12 @@
switch (m_raw->m_ColorByteType)
{
+ case WHITE:
+ ByteType = GL_LUMINANCE;
+ break;
+ case WHITE_ALPHA:
+ ByteType = GL_LUMINANCE_ALPHA;
+ break;
case RGB:
ByteType = GL_RGB;
break;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|