]> git.sesse.net Git - movit/commitdiff
Kill the hard-coded texture enums (yay).
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Tue, 2 Oct 2012 17:34:11 +0000 (19:34 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Tue, 2 Oct 2012 17:34:11 +0000 (19:34 +0200)
effect_chain.cpp
effect_chain.h
main.cpp
texture_enum.h [deleted file]
widgets.cpp

index d45c2fc4f86ba5c76bad0aa0da52129f05f25b3d..a6ff90ea5a7df7ad8cfda34dcd68894c47792cf6 100644 (file)
@@ -16,7 +16,6 @@
 #include "saturation_effect.h"
 #include "mirror_effect.h"
 #include "vignette_effect.h"
 #include "saturation_effect.h"
 #include "mirror_effect.h"
 #include "vignette_effect.h"
-#include "texture_enum.h"
 
 EffectChain::EffectChain(unsigned width, unsigned height)
        : width(width), height(height), use_srgb_texture_format(false), finalized(false) {}
 
 EffectChain::EffectChain(unsigned width, unsigned height)
        : width(width), height(height), use_srgb_texture_format(false), finalized(false) {}
@@ -220,7 +219,11 @@ void EffectChain::finalize()
        memset(mapped_pbo, 0, width * height * bytes_per_pixel);
        glUnmapBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB);
        
        memset(mapped_pbo, 0, width * height * bytes_per_pixel);
        glUnmapBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB);
        
-       glBindTexture(GL_TEXTURE_2D, SOURCE_IMAGE);
+       glGenTextures(1, &source_image_num);
+       check_error();
+       glBindTexture(GL_TEXTURE_2D, source_image_num);
+       check_error();
+       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
        check_error();
        glTexImage2D(GL_TEXTURE_2D, 0, internal_format, width, height, 0, format, GL_UNSIGNED_BYTE, BUFFER_OFFSET(0));
        check_error();
        check_error();
        glTexImage2D(GL_TEXTURE_2D, 0, internal_format, width, height, 0, format, GL_UNSIGNED_BYTE, BUFFER_OFFSET(0));
        check_error();
@@ -245,7 +248,7 @@ void EffectChain::render_to_screen(unsigned char *src)
        // Re-upload the texture from the PBO.
        glActiveTexture(GL_TEXTURE0);
        check_error();
        // Re-upload the texture from the PBO.
        glActiveTexture(GL_TEXTURE0);
        check_error();
-       glBindTexture(GL_TEXTURE_2D, SOURCE_IMAGE);
+       glBindTexture(GL_TEXTURE_2D, source_image_num);
        check_error();
        glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, format, GL_UNSIGNED_BYTE, BUFFER_OFFSET(0));
        check_error();
        check_error();
        glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, format, GL_UNSIGNED_BYTE, BUFFER_OFFSET(0));
        check_error();
index 3fa62ee3e074c3402843d46f0124ed3599e87ed0..5b8ddbca45295f54a2bc4db4b132b1eeaa1efbb4 100644 (file)
@@ -53,6 +53,7 @@ private:
        ImageFormat input_format, output_format;
        std::vector<Effect *> effects;
 
        ImageFormat input_format, output_format;
        std::vector<Effect *> effects;
 
+       GLuint source_image_num;
        bool use_srgb_texture_format;
 
        GLint glsl_program_num;
        bool use_srgb_texture_format;
 
        GLint glsl_program_num;
index 2790bf8b0455a30c88086a40b538b02a3634d1c3..1386a0f1def99395e9296d0ef81fa1cac29329bd 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -25,7 +25,6 @@
 #include "effect_chain.h"
 #include "util.h"
 #include "widgets.h"
 #include "effect_chain.h"
 #include "util.h"
 #include "widgets.h"
-#include "texture_enum.h"
 
 unsigned char result[WIDTH * HEIGHT * 4];
 
 
 unsigned char result[WIDTH * HEIGHT * 4];
 
@@ -36,7 +35,7 @@ float saturation = 1.0f;
 
 float radius = 0.3f;
 float inner_radius = 0.3f;
 
 float radius = 0.3f;
 float inner_radius = 0.3f;
-
+       
 void update_hsv(Effect *lift_gamma_gain_effect, Effect *saturation_effect)
 {
        RGBTriplet lift(0.0f, 0.0f, 0.0f);
 void update_hsv(Effect *lift_gamma_gain_effect, Effect *saturation_effect)
 {
        RGBTriplet lift(0.0f, 0.0f, 0.0f);
@@ -157,11 +156,6 @@ int main(int argc, char **argv)
        glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
        glPixelStorei(GL_PACK_ALIGNMENT, 1);
 
        glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
        glPixelStorei(GL_PACK_ALIGNMENT, 1);
 
-       glBindTexture(GL_TEXTURE_2D, SOURCE_IMAGE);
-       check_error();
-       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
-       check_error();
-
        unsigned img_w, img_h;
        unsigned char *src_img = load_image("blg_wheels_woman_1.jpg", &img_w, &img_h);
 
        unsigned img_w, img_h;
        unsigned char *src_img = load_image("blg_wheels_woman_1.jpg", &img_w, &img_h);
 
diff --git a/texture_enum.h b/texture_enum.h
deleted file mode 100644 (file)
index e1e956f..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-#ifndef _TEXTURE_ENUM_H
-#define _TEXTURE_ENUM_H 1
-
-enum textures {
-       SOURCE_IMAGE = 1,
-       SRGB_LUT = 2,
-       SRGB_REVERSE_LUT = 3,
-       HSV_WHEEL = 4,
-};
-
-#endif // !defined(_TEXTURE_ENUM_H)
-
index a17039118174d7d1f3d138009e54878abcad4f03..09d878ed4fa065ce1fb112b9d405d16335c34d3d 100644 (file)
@@ -6,10 +6,11 @@
 
 #include "widgets.h"
 #include "util.h"
 
 #include "widgets.h"
 #include "util.h"
-#include "texture_enum.h"
 
 #define HSV_WHEEL_SIZE 128
 
 
 #define HSV_WHEEL_SIZE 128
 
+GLuint hsv_wheel_num;
+
 void draw_hsv_wheel(float y, float rad, float theta, float value)
 {
        glUseProgram(0);
 void draw_hsv_wheel(float y, float rad, float theta, float value)
 {
        glUseProgram(0);
@@ -18,7 +19,7 @@ void draw_hsv_wheel(float y, float rad, float theta, float value)
        check_error();
        glEnable(GL_TEXTURE_2D);
        check_error();
        check_error();
        glEnable(GL_TEXTURE_2D);
        check_error();
-       glBindTexture(GL_TEXTURE_2D, HSV_WHEEL);
+       glBindTexture(GL_TEXTURE_2D, hsv_wheel_num);
        check_error();
        glActiveTexture(GL_TEXTURE1);
        check_error();
        check_error();
        glActiveTexture(GL_TEXTURE1);
        check_error();
@@ -110,6 +111,8 @@ void draw_saturation_bar(float y, float saturation)
 
 void make_hsv_wheel_texture()
 {
 
 void make_hsv_wheel_texture()
 {
+       glGenTextures(1, &hsv_wheel_num);
+
        static unsigned char hsv_pix[HSV_WHEEL_SIZE * HSV_WHEEL_SIZE * 4];
        for (int y = 0; y < HSV_WHEEL_SIZE; ++y) {
                for (int x = 0; x < HSV_WHEEL_SIZE; ++x) {
        static unsigned char hsv_pix[HSV_WHEEL_SIZE * HSV_WHEEL_SIZE * 4];
        for (int y = 0; y < HSV_WHEEL_SIZE; ++y) {
                for (int x = 0; x < HSV_WHEEL_SIZE; ++x) {
@@ -133,7 +136,7 @@ void make_hsv_wheel_texture()
                printf("\n");
        }
 
                printf("\n");
        }
 
-       glBindTexture(GL_TEXTURE_2D, HSV_WHEEL);
+       glBindTexture(GL_TEXTURE_2D, hsv_wheel_num);
        check_error();
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
        check_error();
        check_error();
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
        check_error();