glEnable(GL_CULL_FACE);
glEnable(GL_DEPTH_TEST);
- //glEnable(GL_LIGHTING);
- glEnable(GL_LIGHT0);
- if(GLEW_ARB_framebuffer_sRGB) {
+ if(opt.srgb && GLEW_ARB_framebuffer_sRGB) {
printf("enabling sRGB framebuffer\n");
glEnable(GL_FRAMEBUFFER_SRGB);
}
#include "meshgen.h"
#include "backdrop.h"
#include "app.h"
+#include "color.h"
static unsigned int sdr_grid;
static Texture *tex_grid;
static Mesh *mesh_skydome;
static unsigned int sdr_skydome;
-static const Vec3 grid_color = Vec3(1.0, 0.07, 1.0);
-static const Vec3 mid_color = Vec3(0.133, 0.006, 0.612);
-static const Vec3 horiz_color = Vec3(0.612, 0.006, 1.0);
-static const Vec3 zenith_color = Vec3(0.029, 0.029, 0.029);
-static const Vec3 fog_color = Vec3(0.01, 0.01, 0.01);
bool init_backdrop()
{
+ Vec3 grid_color = color(1.0, 0.07, 1.0);
+ Vec3 mid_color = color(0.133, 0.006, 0.612);
+ Vec3 horiz_color = color(0.612, 0.006, 1.0);
+ Vec3 zenith_color = color(0.029, 0.029, 0.029);
+ Vec3 fog_color = color(0.01, 0.01, 0.01);
+
if(!(sdr_grid = create_program_load("sdr/grid.v.glsl", "sdr/grid.p.glsl"))) {
return false;
}
--- /dev/null
+#include "color.h"
+#include "opt.h"
+
+Color color(float r, float g, float b)
+{
+ return opt.srgb ? Color(r, g, b) : linear_to_srgb(Color(r, g, b));
+}
+
+Color linear_to_srgb(const Color &c)
+{
+ const float inv_gamma = 1.0f / 2.2f;
+ return Color(pow(c.x, inv_gamma), pow(c.y, inv_gamma), pow(c.z, inv_gamma));
+}
+
+Color srgb_to_linear(const Color &c)
+{
+ const float gamma = 2.2f;
+ return Color(pow(c.x, gamma), pow(c.y, gamma), pow(c.z, gamma));
+}
--- /dev/null
+#ifndef COLOR_H_
+#define COLOR_H_
+
+#include "gmath/gmath.h"
+
+typedef Vec3 Color;
+
+Color color(float r, float g, float b);
+Color linear_to_srgb(const Color &c);
+Color srgb_to_linear(const Color &c);
+
+#endif // COLOR_H_
#include "image.h"
#include "opengl.h"
#include "imago2.h"
+#include "opt.h"
#if defined(GL_ES_VERSION_2_0) || defined(GL_VERSION_3_0)
#define USE_GL_GENERATE_MIPMAP
static int glifmt_from_imgfmt(Image::Format fmt)
{
+ bool use_srgb = GLEW_EXT_texture_sRGB && opt.srgb;
+
switch(fmt) {
case Image::FMT_GREY:
- return GLEW_EXT_texture_sRGB ? GL_SLUMINANCE : GL_LUMINANCE;
+ return use_srgb ? GL_SLUMINANCE : GL_LUMINANCE;
case Image::FMT_GREY_FLOAT:
return GL_LUMINANCE16F;
case Image::FMT_RGB:
- return GLEW_EXT_texture_sRGB ? GL_SRGB : GL_RGB;
+ return use_srgb ? GL_SRGB : GL_RGB;
case Image::FMT_RGB_FLOAT:
return GL_RGB16F;
case Image::FMT_RGBA:
- return GLEW_EXT_texture_sRGB ? GL_SRGB_ALPHA : GL_RGBA;
+ return use_srgb ? GL_SRGB_ALPHA : GL_RGBA;
case Image::FMT_RGBA_FLOAT:
return GL_RGBA16F;