--- /dev/null
+extension EXT_texture_sRGB
result += c
return result;
-def make_tex(fn, filter="LINEAR", anisotropy=0, wrap=None):
+def make_tex(fn, filter="LINEAR", anisotropy=0, wrap=None, srgb=False):
import Image
img = Image.open(fn)
elif fmt=="L":
fmt = "LUMINANCE"
+ if srgb:
+ fmt = "S"+fmt
+
result = "storage %s %d %d;\n"%(fmt, img.size[0], img.size[1])
result += "filter %s;\n"%filter
if "MIPMAP" in filter:
parser.add_argument("-f", "--filter", choices=["NEAREST", "LINEAR", "MIPMAP"], default="LINEAR", help="Filtering mode")
parser.add_argument("-a", "--anisotropy", metavar="NUMBER", help="Maximum anisotropy, 0 = disable")
parser.add_argument("-w", "--wrap", choices=["REPEAT", "CLAMP_TO_EDGE", "MIRRORED_REPEAT"], help="Wrapping mode")
+ parser.add_argument("--srgb", action="store_const", const=True, help="Use sRGB color space")
parser.add_argument("image")
args = parser.parse_args()
if not out_fn:
out_fn = os.path.splitext(args.image)[0]+".tex2d"
out = file(out_fn, "w")
- out.write(make_tex(args.image, filter, args.anisotropy, args.wrap))
+ out.write(make_tex(args.image, filter, args.anisotropy, args.wrap, args.srgb))
fmt = BGR;
else if(conv.get()=="BGRA")
fmt = BGRA;
+ else if(conv.get()=="SRGB")
+ fmt = SRGB;
+ else if(conv.get()=="SRGB_ALPHA")
+ fmt = SRGB_ALPHA;
else if(conv.get()=="LUMINANCE")
fmt = LUMINANCE;
else if(conv.get()=="LUMINANCE_ALPHA")
fmt = LUMINANCE_ALPHA;
+ else if(conv.get()=="SLUMINANCE")
+ fmt = SLUMINANCE;
+ else if(conv.get()=="SLUMINANCE_ALPHA")
+ fmt = SLUMINANCE_ALPHA;
else
throw lexical_error(format("conversion of '%s' to PixelFormat", conv.get()));
}
{
case RGB8:
case RGB16F:
- case RGB32F: return RGB;
+ case RGB32F:
+ case SRGB:
+ case SRGB8: return RGB;
case RGBA8:
case RGBA16F:
- case RGBA32F: return RGBA;
+ case RGBA32F:
+ case SRGB_ALPHA:
+ case SRGB8_ALPHA8: return RGBA;
case LUMINANCE8:
case LUMINANCE16F:
- case LUMINANCE32F: return LUMINANCE;
+ case LUMINANCE32F:
+ case SLUMINANCE:
+ case SLUMINANCE8: return LUMINANCE;
case LUMINANCE_ALPHA8:
case LUMINANCE_ALPHA16F:
- case LUMINANCE_ALPHA32F: return LUMINANCE_ALPHA;
+ case LUMINANCE_ALPHA32F:
+ case SLUMINANCE_ALPHA:
+ case SLUMINANCE8_ALPHA8: return LUMINANCE_ALPHA;
default: return pf;
}
}
case GREEN:
case BLUE:
case LUMINANCE:
+ case SLUMINANCE:
return 1;
case LUMINANCE_ALPHA:
+ case SLUMINANCE_ALPHA:
return 2;
case RGB:
case BGR:
case LUMINANCE_ALPHA32F:
{ static Require _req(ARB_texture_float); }
break;
+ case SRGB:
+ case SRGB8:
+ case SRGB_ALPHA:
+ case SRGB8_ALPHA8:
+ case SLUMINANCE:
+ case SLUMINANCE8:
+ case SLUMINANCE_ALPHA:
+ case SLUMINANCE8_ALPHA8:
+ { static Require _req(EXT_texture_sRGB); }
+ break;
case BGR:
case BGRA:
{ static Require _req(EXT_bgra); }
#include "gl.h"
#include <msp/gl/extensions/arb_texture_float.h>
#include <msp/gl/extensions/ext_bgra.h>
+#include <msp/gl/extensions/ext_texture_srgb.h>
namespace Msp {
namespace GL {
RGBA8 = GL_RGBA8,
RGBA16F = GL_RGBA16F_ARB,
RGBA32F = GL_RGBA32F_ARB,
+ SRGB = GL_SRGB_EXT,
+ SRGB_ALPHA = GL_SRGB_ALPHA_EXT,
+ SRGB8 = GL_SRGB8_EXT,
+ SRGB8_ALPHA8 = GL_SRGB8_ALPHA8_EXT,
BGR = GL_BGR,
BGRA = GL_BGRA,
LUMINANCE = GL_LUMINANCE,
LUMINANCE_ALPHA = GL_LUMINANCE_ALPHA,
LUMINANCE_ALPHA8 = GL_LUMINANCE8_ALPHA8,
LUMINANCE_ALPHA16F = GL_LUMINANCE_ALPHA16F_ARB,
- LUMINANCE_ALPHA32F = GL_LUMINANCE_ALPHA32F_ARB
+ LUMINANCE_ALPHA32F = GL_LUMINANCE_ALPHA32F_ARB,
+ SLUMINANCE = GL_SLUMINANCE_EXT,
+ SLUMINANCE8 = GL_SLUMINANCE8_EXT,
+ SLUMINANCE_ALPHA = GL_SLUMINANCE_ALPHA_EXT,
+ SLUMINANCE8_ALPHA8 = GL_SLUMINANCE8_ALPHA8_EXT
};
void operator>>(const LexicalConverter &, PixelFormat &);