void imageColorSpace_CB(int id) { OCIO::ConstConfigRcPtr config = OCIO::GetCurrentConfig(); const char * name = config->getColorSpaceNameByIndex(id); if(!name) return; g_inputColorSpace = name; UpdateOCIOGLState(); glutPostRedisplay(); }
void transform_CB(int id) { OCIO::ConstConfigRcPtr config = OCIO::GetCurrentConfig(); const char * transform = config->getView(g_display.c_str(), id); if(!transform) return; g_transformName = transform; UpdateOCIOGLState(); glutPostRedisplay(); }
static void Key(unsigned char key, int /*x*/, int /*y*/) { if(key == 'c' || key == 'C') { g_channelHot[0] = 1; g_channelHot[1] = 1; g_channelHot[2] = 1; g_channelHot[3] = 1; } else if(key == 'r' || key == 'R') { g_channelHot[0] = 1; g_channelHot[1] = 0; g_channelHot[2] = 0; g_channelHot[3] = 0; } else if(key == 'g' || key == 'G') { g_channelHot[0] = 0; g_channelHot[1] = 1; g_channelHot[2] = 0; g_channelHot[3] = 0; } else if(key == 'b' || key == 'B') { g_channelHot[0] = 0; g_channelHot[1] = 0; g_channelHot[2] = 1; g_channelHot[3] = 0; } else if(key == 'a' || key == 'A') { g_channelHot[0] = 0; g_channelHot[1] = 0; g_channelHot[2] = 0; g_channelHot[3] = 1; } else if(key == 'l' || key == 'L') { g_channelHot[0] = 1; g_channelHot[1] = 1; g_channelHot[2] = 1; g_channelHot[3] = 0; } else if(key == 27) { CleanUp(); exit(0); } UpdateOCIOGLState(); glutPostRedisplay(); }
void look_CB(int id) { OCIO::ConstConfigRcPtr config = OCIO::GetCurrentConfig(); const char * look = config->getLookNameByIndex(id); if(!look || !*look) return; g_look = look; UpdateOCIOGLState(); glutPostRedisplay(); }
void displayDevice_CB(int id) { OCIO::ConstConfigRcPtr config = OCIO::GetCurrentConfig(); const char * display = config->getDisplay(id); if(!display) return; g_display = display; const char * csname = config->getDisplayColorSpaceName(g_display.c_str(), g_transformName.c_str()); if(!csname) { g_transformName = config->getDefaultView(g_display.c_str()); } UpdateOCIOGLState(); glutPostRedisplay(); }
static void SpecialKey(int key, int x, int y) { (void) x; (void) y; int mod = glutGetModifiers(); if(key == GLUT_KEY_UP && (mod & GLUT_ACTIVE_CTRL)) { g_exposure_fstop += 0.25f; } else if(key == GLUT_KEY_DOWN && (mod & GLUT_ACTIVE_CTRL)) { g_exposure_fstop -= 0.25f; } else if(key == GLUT_KEY_HOME && (mod & GLUT_ACTIVE_CTRL)) { g_exposure_fstop = 0.0f; g_display_gamma = 1.0f; } else if(key == GLUT_KEY_UP && (mod & GLUT_ACTIVE_ALT)) { g_display_gamma *= 1.1f; } else if(key == GLUT_KEY_DOWN && (mod & GLUT_ACTIVE_ALT)) { g_display_gamma /= 1.1f; } else if(key == GLUT_KEY_HOME && (mod & GLUT_ACTIVE_ALT)) { g_exposure_fstop = 0.0f; g_display_gamma = 1.0f; } UpdateOCIOGLState(); glutPostRedisplay(); }
int main(int, char **) { int argc = 2; const char* argv[] = { "main", "-glDebug" }; glutInit(&argc, const_cast<char**>(&argv[0])); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); glutInitWindowSize(g_winWidth, g_winHeight); glutInitWindowPosition(0, 0); g_win = glutCreateWindow(argv[0]); #ifndef __APPLE__ glewInit(); if (!glewIsSupported("GL_VERSION_2_0")) { std::cout << "OpenGL 2.0 not supported" << std::endl; exit(1); } #endif // Step 1: Initilize the OpenGL engine glPixelStorei(GL_UNPACK_ALIGNMENT, 4); // 4-byte pixel alignment #ifndef __APPLE__ glClampColor(GL_CLAMP_READ_COLOR, GL_FALSE); // glClampColor(GL_CLAMP_VERTEX_COLOR, GL_FALSE); // avoid any kind of clamping glClampColor(GL_CLAMP_FRAGMENT_COLOR, GL_FALSE); // #endif glEnable(GL_TEXTURE_2D); glClearColor(0, 0, 0, 0); // background color glClearStencil(0); // clear stencil buffer // Step 2: Allocate the needed textures AllocateImageTexture(); AllocateDefaultLut3D(); // Step 3: Create the frame buffer and render buffer GLuint fboId; // create a framebuffer object, you need to delete them when program exits. glGenFramebuffers(1, &fboId); glBindFramebuffer(GL_FRAMEBUFFER, fboId); GLuint rboId; // create a renderbuffer object to store depth info glGenRenderbuffers(1, &rboId); glBindRenderbuffer(GL_RENDERBUFFER, rboId); glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA32F_ARB, g_winWidth, g_winHeight); glBindRenderbuffer(GL_RENDERBUFFER, 0); // attach a texture to FBO color attachement point glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D, g_imageTexID, 0); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT2, GL_TEXTURE_3D, g_lut3dTexID, 0); // attach a renderbuffer to depth attachment point glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rboId); glBindFramebuffer(GL_FRAMEBUFFER, 0); // Step 4: Execute all the unit tests unsigned failures = 0; const UnitTests & tests = GetUnitTests(); const size_t numTests = tests.size(); for(size_t idx=0; idx<numTests; ++idx) { OCIOGPUTest* test = tests[idx]; test->setup(); const unsigned curr_failures = failures; // Set the rendering destination to FBO glBindFramebuffer(GL_FRAMEBUFFER, fboId); // Clear buffer glClearColor(0.1f, 0.1f, 0.1f, 0.1f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); std::cerr << "Test [" << test->group() << "] [" << test->name() << "] - "; try { // Update the image texture UpdateImageTexture(); // Update the GPU shader program UpdateOCIOGLState(test->getProcessor()); // Enable the shader program, and its textures glUseProgram(g_program); glUniform1i(glGetUniformLocation(g_program, "tex1"), 1); glUniform1i(glGetUniformLocation(g_program, "tex2"), 2); // Process the image texture into the rendering buffer Reshape(); Redisplay(); // Validate the processed image using the rendering buffer ValidateImageTexture(test->getProcessor(), test->getErrorThreshold()); } catch(OCIO::Exception & ex) { ++failures; std::cerr << "FAILED - " << ex.what() << std::endl; } catch(...) { ++failures; std::cerr << "FAILED - Unexpected error" << std::endl; } if(curr_failures==failures) { std::cerr << "PASSED" << std::endl; } glUseProgram(0); glBindFramebuffer(GL_FRAMEBUFFER, 0); } std::cerr << std::endl << failures << " tests failed" << std::endl << std::endl; }
int main(int argc, char **argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); glutInitWindowSize(512, 512); glutInitWindowPosition (100, 100); g_win = glutCreateWindow(argv[0]); #ifndef __APPLE__ glewInit(); if (!glewIsSupported("GL_VERSION_2_0")) { printf("OpenGL 2.0 not supported\n"); exit(1); } #endif glutReshapeFunc(Reshape); glutKeyboardFunc(Key); glutSpecialFunc(SpecialKey); glutDisplayFunc(Redisplay); const char * filename = 0; if(argc>1) filename = argv[1]; std::cout << USAGE_TEXT << std::endl; // TODO: switch profiles based on shading language // std::cout << "GL_SHADING_LANGUAGE_VERSION: " << glGetString(GL_SHADING_LANGUAGE_VERSION) << std::endl; AllocateLut3D(); InitImageTexture(filename); try { InitOCIO(filename); } catch(OCIO::Exception & e) { std::cerr << e.what() << std::endl; exit(1); } PopulateOCIOMenus(); Reshape(1024, 512); UpdateOCIOGLState(); Redisplay(); /* if (Anim) { glutIdleFunc(Idle); } */ glutMainLoop(); return 0; }