This allows clients to programmatically enable/disable Movit usage
as needed on very old platforms.
SDL_SetVideoMode(WIDTH, HEIGHT, 0, SDL_OPENGL);
SDL_WM_SetCaption("OpenGL window", NULL);
SDL_SetVideoMode(WIDTH, HEIGHT, 0, SDL_OPENGL);
SDL_WM_SetCaption("OpenGL window", NULL);
- init_movit(".", MOVIT_DEBUG_ON);
+ CHECK(init_movit(".", MOVIT_DEBUG_ON));
printf("GPU texture subpixel precision: about %.1f bits\n",
log2(1.0f / movit_texel_subpixel_precision));
printf("Wrongly rounded x+0.48 or x+0.52 values: %d/510\n",
printf("GPU texture subpixel precision: about %.1f bits\n",
log2(1.0f / movit_texel_subpixel_precision));
printf("Wrongly rounded x+0.48 or x+0.52 values: %d/510\n",
{
// We fundamentally need FBOs and floating-point textures.
{
// We fundamentally need FBOs and floating-point textures.
- assert(glewIsSupported("GL_ARB_framebuffer_object") != 0);
- assert(glewIsSupported("GL_ARB_texture_float") != 0);
+ if (!glewIsSupported("GL_ARB_framebuffer_object")) return false;
+ if (!glewIsSupported("GL_ARB_texture_float")) return false;
// We assume that we can use non-power-of-two textures without restrictions.
// We assume that we can use non-power-of-two textures without restrictions.
- assert(glewIsSupported("GL_ARB_texture_non_power_of_two") != 0);
+ if (!glewIsSupported("GL_ARB_texture_non_power_of_two")) return false;
// We also need GLSL fragment shaders.
// We also need GLSL fragment shaders.
- assert(glewIsSupported("GL_ARB_fragment_shader") != 0);
- assert(glewIsSupported("GL_ARB_shading_language_100") != 0);
+ if (!glewIsSupported("GL_ARB_fragment_shader")) return false;
+ if (!glewIsSupported("GL_ARB_shading_language_100")) return false;
// FlatInput and YCbCrInput uses PBOs. (They could in theory do without,
// but no modern card would really not provide it.)
// FlatInput and YCbCrInput uses PBOs. (They could in theory do without,
// but no modern card would really not provide it.)
- assert(glewIsSupported("GL_ARB_pixel_buffer_object") != 0);
+ if (!glewIsSupported("GL_ARB_pixel_buffer_object")) return false;
// ResampleEffect uses RG textures to encode a two-component LUT.
// ResampleEffect uses RG textures to encode a two-component LUT.
- assert(glewIsSupported("GL_ARB_texture_rg") != 0);
+ if (!glewIsSupported("GL_ARB_texture_rg")) return false;
// sRGB texture decode would be nice, but are not mandatory
// (GammaExpansionEffect can do the same thing if needed).
// sRGB texture decode would be nice, but are not mandatory
// (GammaExpansionEffect can do the same thing if needed).
// and 1.30 brings with it other things that we don't want to demand
// for now.
movit_shader_rounding_supported = glewIsSupported("GL_EXT_gpu_shader4");
// and 1.30 brings with it other things that we don't want to demand
// for now.
movit_shader_rounding_supported = glewIsSupported("GL_EXT_gpu_shader4");
-void init_movit(const string& data_directory, MovitDebugLevel debug_level)
+bool init_movit(const string& data_directory, MovitDebugLevel debug_level)
{
if (movit_initialized) {
{
if (movit_initialized) {
}
movit_data_directory = new string(data_directory);
movit_debug_level = debug_level;
}
movit_data_directory = new string(data_directory);
movit_debug_level = debug_level;
+ GLenum err = glewInit();
+ if (err != GLEW_OK) {
+ return false;
+ }
// geez
glPixelStorei(GL_PACK_ALIGNMENT, 1);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glDisable(GL_DITHER);
// geez
glPixelStorei(GL_PACK_ALIGNMENT, 1);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glDisable(GL_DITHER);
+ if (!check_extensions()) {
+ return false;
+ }
measure_texel_subpixel_precision();
measure_roundoff_problems();
measure_texel_subpixel_precision();
measure_roundoff_problems();
movit_initialized = true;
movit_initialized = true;
#ifndef _MOVIT_INIT_H
#define _MOVIT_INIT_H
#ifndef _MOVIT_INIT_H
#define _MOVIT_INIT_H
#include <string>
enum MovitDebugLevel {
#include <string>
enum MovitDebugLevel {
// Initialize the library; in particular, will query the GPU for information
// that is needed by various components. For instance, it verifies that
// Initialize the library; in particular, will query the GPU for information
// that is needed by various components. For instance, it verifies that
-// we have all the OpenGL extensions we need.
+// we have all the OpenGL extensions we need. Returns true if initialization
+// succeeded.
//
// The first parameter gives which directory to read .frag files from.
// This is a temporary hack until we add something more solid.
//
// The first parameter gives which directory to read .frag files from.
// This is a temporary hack until we add something more solid.
// generated shaders to the current directory.
//
// If you call init_movit() twice with different parameters,
// generated shaders to the current directory.
//
// If you call init_movit() twice with different parameters,
-// only the first will count.
-void init_movit(const std::string& data_directory, MovitDebugLevel debug_level);
+// only the first will count, and the second will always return true.
+bool init_movit(const std::string& data_directory, MovitDebugLevel debug_level) MUST_CHECK_RESULT;
// GPU features. These are not intended for end-user use.
// GPU features. These are not intended for end-user use.
GLenum framebuffer_format)
: chain(width, height, get_static_pool()), width(width), height(height), finalized(false)
{
GLenum framebuffer_format)
: chain(width, height, get_static_pool()), width(width), height(height), finalized(false)
{
- init_movit(".", MOVIT_DEBUG_OFF);
+ CHECK(init_movit(".", MOVIT_DEBUG_OFF));
if (data != NULL) {
add_input(data, pixel_format, color_space, gamma_curve);
if (data != NULL) {
add_input(data, pixel_format, color_space, gamma_curve);