void
-SGTexture::make_monochrome(GLubyte r, GLubyte g, GLubyte b) {
+SGTexture::make_monochrome(float contrast, GLubyte r, GLubyte g, GLubyte b) {
if (num_colors >= 3)
return;
}
}
+
void
-SGTexture::make_normalmap(float brightness) {
+SGTexture::make_grayscale(float contrast) {
+ if (num_colors >= 3)
+ return;
+
+ GLubyte *map = (GLubyte *)malloc (texture_width * texture_height);
+ for (int y=0; y<texture_height; y++)
+ for (int x=0; x<texture_width; x++)
+ {
+ GLubyte *rgb = get_pixel(x,y);
+ GLubyte avg = (rgb[0] + rgb[1] + rgb[2]) / 3;
+
+ map[x +y*texture_height] = avg;
+ }
+
+ free (texture_data);
+ texture_data = map;
+ num_colors = 1;
+}
+
+
+void
+SGTexture::make_normalmap(float brightness, float contrast) {
+ make_grayscale(contrast);
+
GLubyte *map = (GLubyte *)malloc (texture_width * texture_height * 3);
for (int y=0; y<texture_height; y++)
inline const char *err_str() { return errstr; }
inline void clear_err_str() { errstr = ""; }
- void make_monochrome(GLubyte r=255, GLubyte g=255, GLubyte b=255);
- void make_normalmap(float brightness = 1.0);
+ void make_grayscale(float contrast = 1.0);
+ void make_monochrome(float contrast = 1.0,
+ GLubyte r=255, GLubyte g=255, GLubyte b=255);
+ void make_normalmap(float brightness = 1.0, float contrast = 1.0);
};
#endif