[Hdrflow-svn] SF.net SVN: hdrflow: [298] trunk/lib/openlibraries
Status: Pre-Alpha
Brought to you by:
glslang
|
From: <gl...@us...> - 2007-09-12 16:34:12
|
Revision: 298
http://hdrflow.svn.sourceforge.net/hdrflow/?rev=298&view=rev
Author: glslang
Date: 2007-09-12 09:34:07 -0700 (Wed, 12 Sep 2007)
Log Message:
-----------
+ changes to allow cleaner client code. some gl state calculation was left to the client with the need to replicate the same tests
Modified Paths:
--------------
trunk/lib/openlibraries/src/openmedialib/plugins/oil/Makefile.am
trunk/lib/openlibraries/src/openmedialib/plugins/oil/oil_plugin.cpp
trunk/lib/openlibraries/src/openpluginlib/pl/GL_utility.cpp
trunk/lib/openlibraries/src/openpluginlib/pl/GL_utility.hpp
trunk/lib/openlibraries/src/umbrella_framework/openlibraries.hpp
trunk/lib/openlibraries/test/openimagelib/GL/_2D/_2D.cpp
trunk/lib/openlibraries/test/openimagelib/GL/_2D_crop/_2D_crop.cpp
trunk/lib/openlibraries/test/openimagelib/GL/_2D_exr/_2D_exr.cpp
trunk/lib/openlibraries/test/openimagelib/GL/_2D_scale/_2D_scale.cpp
Modified: trunk/lib/openlibraries/src/openmedialib/plugins/oil/Makefile.am
===================================================================
--- trunk/lib/openlibraries/src/openmedialib/plugins/oil/Makefile.am 2007-09-06 22:34:31 UTC (rev 297)
+++ trunk/lib/openlibraries/src/openmedialib/plugins/oil/Makefile.am 2007-09-12 16:34:07 UTC (rev 298)
@@ -11,12 +11,13 @@
oil_plugin.cpp
libopenmedialib_oil_la_CXXFLAGS = \
- $(OLIB_CXXFLAGS) \
+ $(OLIB_CXXFLAGS) \
$(BOOST_INCLUDE_PATH) \
-DML_PLUGIN_EXPORTS
libopenmedialib_oil_la_LIBADD = \
$(BOOST_FILESYSTEM_LIBS) \
+ $(top_builddir)/src/openpluginlib/pl/libopenpluginlib_pl.la \
$(top_builddir)/src/openmedialib/ml/libopenmedialib_ml.la \
$(top_builddir)/src/openimagelib/il/libopenimagelib_il.la
Modified: trunk/lib/openlibraries/src/openmedialib/plugins/oil/oil_plugin.cpp
===================================================================
--- trunk/lib/openlibraries/src/openmedialib/plugins/oil/oil_plugin.cpp 2007-09-06 22:34:31 UTC (rev 297)
+++ trunk/lib/openlibraries/src/openmedialib/plugins/oil/oil_plugin.cpp 2007-09-12 16:34:07 UTC (rev 298)
@@ -202,7 +202,7 @@
pl::string full = path_ + "/" + files_[ 0 ];
il_query_traits query( pl::to_wstring( full ), L"input" );
discovery plugins( query );
- if ( plugins.size( ) != 0 )
+ if ( !plugins.empty( ) )
{
discovery::const_iterator it = plugins.begin( );
plug_ = boost::shared_dynamic_cast<il::openimagelib_plugin>( it->create_plugin( "" ) );
Modified: trunk/lib/openlibraries/src/openpluginlib/pl/GL_utility.cpp
===================================================================
--- trunk/lib/openlibraries/src/openpluginlib/pl/GL_utility.cpp 2007-09-06 22:34:31 UTC (rev 297)
+++ trunk/lib/openlibraries/src/openpluginlib/pl/GL_utility.cpp 2007-09-12 16:34:07 UTC (rev 298)
@@ -9,85 +9,163 @@
namespace olib { namespace openpluginlib {
-std::pair<int, GLenum> pf_to_gl_format( const wstring& pf )
+bool pf_to_gl_format( const wstring& pf, GLint& internal_format, GLenum& format, GLenum& type )
{
if( pf == L"dxt1" )
{
- return std::make_pair( -1, GL_COMPRESSED_RGB_S3TC_DXT1_EXT );
+ internal_format = -1;
+ format = GL_COMPRESSED_RGB_S3TC_DXT1_EXT;
+ type = GL_UNSIGNED_BYTE;
+
+ return true;
}
else if( pf == L"dxt3" )
{
- return std::make_pair( -1, GL_COMPRESSED_RGBA_S3TC_DXT3_EXT );
+ internal_format = -1;
+ format = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT;
+ type = GL_UNSIGNED_BYTE;
+
+ return true;
}
else if( pf == L"dxt5" )
{
- return std::make_pair( -1, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT );
+ internal_format = -1;
+ format = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
+ type = GL_UNSIGNED_BYTE;
+
+ return true;
}
else if( pf == L"b8g8r8a8" )
{
- return std::make_pair( 4, GL_BGRA_EXT );
+ internal_format = GL_RGBA;
+ format = GL_BGRA_EXT;
+ type = GL_UNSIGNED_BYTE;
+
+ return true;
}
else if( pf == L"a8b8g8r8" )
{
- return std::make_pair( 4, GL_ABGR_EXT );
+ internal_format = GL_RGBA;
+ format = GL_ABGR_EXT;
+ type = GL_UNSIGNED_BYTE;
+
+ return true;
}
else if( pf == L"b8g8r8" )
{
- return std::make_pair( 3, GL_BGR_EXT );
+ internal_format = GL_RGB;
+ format = GL_BGR_EXT;
+ type = GL_UNSIGNED_BYTE;
+
+ return true;
}
else if( pf == L"r8g8b8" )
{
- return std::make_pair( 3, GL_RGB );
+ internal_format = GL_RGB;
+ format = GL_RGB;
+ type = GL_UNSIGNED_BYTE;
+
+ return true;
}
else if( pf == L"r8g8b8a8" )
{
- return std::make_pair( 4, GL_RGBA );
+ internal_format = GL_RGBA;
+ format = GL_RGBA;
+ type = GL_UNSIGNED_BYTE;
+
+ return true;
}
else if( pf == L"l8" )
{
- return std::make_pair( 1, GL_LUMINANCE );
+ internal_format = GL_LUMINANCE;
+ format = GL_LUMINANCE;
+ type = GL_UNSIGNED_BYTE;
+
+ return true;
}
else if( pf == L"l8a8" )
{
- return std::make_pair( 2, GL_LUMINANCE_ALPHA );
+ internal_format = GL_LUMINANCE_ALPHA;
+ format = GL_LUMINANCE_ALPHA;
+ type = GL_UNSIGNED_BYTE;
+
+ return true;
}
else if( pf == L"r10g10b10" )
{
- return std::make_pair( GL_RGB10, GL_RGB );
+ internal_format = GL_RGB10;
+ format = GL_RGB;
+ type = GL_UNSIGNED_SHORT;
+
+ return true;
}
else if( pf == L"r12g12b12" )
{
- return std::make_pair( GL_RGB12, GL_RGB );
+ internal_format = GL_RGB12;
+ format = GL_RGB;
+ type = GL_UNSIGNED_SHORT;
+
+ return true;
}
else if( pf == L"r12g12b12a12" )
{
- return std::make_pair( GL_RGBA12, GL_RGBA );
+ internal_format = GL_RGBA12;
+ format = GL_RGBA;
+ type = GL_UNSIGNED_SHORT;
+
+ return true;
}
else if( pf == L"r16g16b16" )
{
- return std::make_pair( GL_RGB16, GL_RGB );
+ internal_format = GL_RGB16;
+ format = GL_RGB;
+ type = GL_UNSIGNED_SHORT;
+
+ return true;
}
else if( pf == L"r16g16b16a16" )
{
- return std::make_pair( GL_RGBA16, GL_RGBA );
+ internal_format = GL_RGBA16;
+ format = GL_RGBA;
+ type = GL_UNSIGNED_SHORT;
+
+ return true;
}
else if( pf == L"yuv422" )
{
if( GLEW_APPLE_ycbcr_422 )
- return std::make_pair( 3, GL_YCBCR_422_APPLE );
+ {
+ internal_format = GL_RGB;
+ format = GL_YCBCR_422_APPLE;
+ type = GL_UNSIGNED_SHORT_8_8_APPLE;
+
+ return true;
+ }
}
else if( pf == L"r32g32b32f" )
{
if( GLEW_ARB_texture_float )
- return std::make_pair( GL_RGB32F_ARB, GL_RGB );
+ {
+ internal_format = GL_RGB32F_ARB;
+ format = GL_RGB;
+ type = GL_FLOAT;
+
+ return true;
+ }
}
else if( pf == L"r32g32b32a32f" )
{
if( GLEW_ARB_texture_float )
- return std::make_pair( GL_RGBA32F_ARB, GL_RGBA );
+ {
+ internal_format = GL_RGBA32F_ARB;
+ format = GL_RGBA;
+ type = GL_FLOAT;
+
+ return true;
+ }
}
- return std::make_pair( 0, 0 );
+ return false;
}
bool is_compressed_format( const wstring& pf )
Modified: trunk/lib/openlibraries/src/openpluginlib/pl/GL_utility.hpp
===================================================================
--- trunk/lib/openlibraries/src/openpluginlib/pl/GL_utility.hpp 2007-09-06 22:34:31 UTC (rev 297)
+++ trunk/lib/openlibraries/src/openpluginlib/pl/GL_utility.hpp 2007-09-12 16:34:07 UTC (rev 298)
@@ -8,8 +8,6 @@
#ifndef GL_UTILITY_INC_
#define GL_UTILITY_INC_
-#include <utility>
-
#include <GL/glew.h>
#include <openpluginlib/pl/config.hpp>
@@ -17,10 +15,10 @@
namespace olib { namespace openpluginlib {
-OPENPLUGINLIB_DECLSPEC std::pair<int, GLenum> pf_to_gl_format( const wstring& pf );
-OPENPLUGINLIB_DECLSPEC bool is_compressed_format( const wstring& pf );
-OPENPLUGINLIB_DECLSPEC bool is_yuv_format( const wstring& pf );
-OPENPLUGINLIB_DECLSPEC bool texture_target( size_t width, size_t height, GLenum& target, float& tex_w, float& tex_h, bool force_2_0_targets = false );
+OPENPLUGINLIB_DECLSPEC bool pf_to_gl_format( const wstring& pf, GLint& internal_format, GLenum& external_format, GLenum& type );
+OPENPLUGINLIB_DECLSPEC bool is_compressed_format( const wstring& pf );
+OPENPLUGINLIB_DECLSPEC bool is_yuv_format( const wstring& pf );
+OPENPLUGINLIB_DECLSPEC bool texture_target( size_t width, size_t height, GLenum& target, float& tex_w, float& tex_h, bool force_2_0_targets = false );
} }
Modified: trunk/lib/openlibraries/src/umbrella_framework/openlibraries.hpp
===================================================================
--- trunk/lib/openlibraries/src/umbrella_framework/openlibraries.hpp 2007-09-06 22:34:31 UTC (rev 297)
+++ trunk/lib/openlibraries/src/umbrella_framework/openlibraries.hpp 2007-09-12 16:34:07 UTC (rev 298)
@@ -20,6 +20,7 @@
#include <openpluginlib/pl/openpluginlib.hpp>
#include <openpluginlib/pl/utf8_utils.hpp>
+#include <openpluginlib/pl/GL_utility.hpp>
#include <openimagelib/il/il.hpp>
#include <openimagelib/il/openimagelib_plugin.hpp>
#include <openmedialib/ml/ml.hpp>
Modified: trunk/lib/openlibraries/test/openimagelib/GL/_2D/_2D.cpp
===================================================================
--- trunk/lib/openlibraries/test/openimagelib/GL/_2D/_2D.cpp 2007-09-06 22:34:31 UTC (rev 297)
+++ trunk/lib/openlibraries/test/openimagelib/GL/_2D/_2D.cpp 2007-09-12 16:34:07 UTC (rev 298)
@@ -81,20 +81,21 @@
image = il::conform( image, il::cropped | il::flipped | il::flopped );
image = il::convert( image, L"r8g8b8" );
if( !image ) return 0;
+
+ GLint internal_format;
+ GLenum format, type;
+ pl::pf_to_gl_format( image->pf( ), internal_format, format, type );
- GLuint id;
+ glActiveTexture( GL_TEXTURE0 );
- std::pair<int, GLenum> pf = pl::pf_to_gl_format( image->pf( ) );
-
- glActiveTexture( GL_TEXTURE0 );
-
+ GLuint id;
glGenTextures( 1, &id );
glBindTexture( GL_TEXTURE_2D, id );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
- glTexImage2D( GL_TEXTURE_2D, 0, pf.first, image->width( ), image->height( ), 0, pf.second, GL_UNSIGNED_BYTE, image->data( ) );
+ glTexImage2D( GL_TEXTURE_2D, 0, internal_format, image->width( ), image->height( ), 0, format, type, image->data( ) );
return id;
}
Modified: trunk/lib/openlibraries/test/openimagelib/GL/_2D_crop/_2D_crop.cpp
===================================================================
--- trunk/lib/openlibraries/test/openimagelib/GL/_2D_crop/_2D_crop.cpp 2007-09-06 22:34:31 UTC (rev 297)
+++ trunk/lib/openlibraries/test/openimagelib/GL/_2D_crop/_2D_crop.cpp 2007-09-12 16:34:07 UTC (rev 298)
@@ -85,19 +85,20 @@
orig_w = image->width( );
orig_h = image->height( );
- GLuint id;
+ GLint internal_format;
+ GLenum format, type;
+ opl::pf_to_gl_format( image->pf( ), internal_format, format, type );
- std::pair<int, GLenum> pf = opl::pf_to_gl_format( image->pf( ).c_str( ) );
+ glActiveTexture( GL_TEXTURE0 );
- glActiveTexture( GL_TEXTURE0 );
-
+ GLuint id;
glGenTextures( 1, &id );
glBindTexture( GL_TEXTURE_2D, id );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
- glTexImage2D( GL_TEXTURE_2D, 0, pf.first, image->width( ), image->height( ), 0, pf.second, GL_UNSIGNED_BYTE, image->data( ) );
+ glTexImage2D( GL_TEXTURE_2D, 0, internal_format, image->width( ), image->height( ), 0, format, type, image->data( ) );
glEnable( GL_TEXTURE_2D );
@@ -113,10 +114,12 @@
orig->crop( 0, 0, static_cast<int>( crop_w ), static_cast<int>( crop_h ), false );
il::image_type_ptr new_im = il::conform( orig, il::cropped | il::flipped | il::flopped );
- std::pair<int, GLenum> pf = opl::pf_to_gl_format( new_im->pf( ).c_str( ) );
+ GLint internal_format;
+ GLenum format, type;
+ opl::pf_to_gl_format( new_im->pf( ), internal_format, format, type );
glBindTexture( GL_TEXTURE_2D, texid_jpg );
- glTexImage2D( GL_TEXTURE_2D, 0, pf.first, new_im->width( ), new_im->height( ), 0, pf.second, GL_UNSIGNED_BYTE, new_im->data( ) );
+ glTexImage2D( GL_TEXTURE_2D, 0, internal_format, new_im->width( ), new_im->height( ), 0, format, type, new_im->data( ) );
glPushMatrix( );
Modified: trunk/lib/openlibraries/test/openimagelib/GL/_2D_exr/_2D_exr.cpp
===================================================================
--- trunk/lib/openlibraries/test/openimagelib/GL/_2D_exr/_2D_exr.cpp 2007-09-06 22:34:31 UTC (rev 297)
+++ trunk/lib/openlibraries/test/openimagelib/GL/_2D_exr/_2D_exr.cpp 2007-09-12 16:34:07 UTC (rev 298)
@@ -79,21 +79,22 @@
image = il::tm_linear( image );
- GLuint id;
+ GLint internal_format;
+ GLenum format, type;
+ opl::pf_to_gl_format( image->pf( ), internal_format, format, type );
- std::pair<int, GLenum> pf = opl::pf_to_gl_format( image->pf( ) );
-
glActiveTexture( GL_TEXTURE0 );
glPixelStorei( GL_UNPACK_ALIGNMENT, 4 );
-
+
+ GLuint id;
glGenTextures( 1, &id );
glBindTexture( GL_TEXTURE_RECTANGLE_EXT, id );
glTexParameteri( GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
glTexParameteri( GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
glTexParameteri( GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
glTexParameteri( GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
- glTexImage2D( GL_TEXTURE_RECTANGLE_EXT, 0, pf.first, image->width( ), image->height( ), 0, pf.second, GL_UNSIGNED_BYTE, image->data( ) );
+ glTexImage2D( GL_TEXTURE_RECTANGLE_EXT, 0, internal_format, image->width( ), image->height( ), 0, format, type, image->data( ) );
tex_width = image->width( );
tex_height = image->height( );
Modified: trunk/lib/openlibraries/test/openimagelib/GL/_2D_scale/_2D_scale.cpp
===================================================================
--- trunk/lib/openlibraries/test/openimagelib/GL/_2D_scale/_2D_scale.cpp 2007-09-06 22:34:31 UTC (rev 297)
+++ trunk/lib/openlibraries/test/openimagelib/GL/_2D_scale/_2D_scale.cpp 2007-09-12 16:34:07 UTC (rev 298)
@@ -81,21 +81,22 @@
il::image_type_ptr new_im = il::rescale( image, 134, 100, 1, il::BILINEAR_SAMPLING );
- GLuint id;
+ GLint internal_format;
+ GLenum format, type;
+ opl::pf_to_gl_format( new_im->pf( ), internal_format, format, type );
- std::pair<int, GLenum> gl_pf = opl::pf_to_gl_format( new_im->pf( ) );
-
opl::texture_target( new_im->width( ), new_im->height( ), target, tex_w, tex_h );
glActiveTexture( GL_TEXTURE0 );
-
+
+ GLuint id;
glGenTextures( 1, &id );
glBindTexture( target, id );
glTexParameteri( target, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
glTexParameteri( target, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
glTexParameteri( target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
glTexParameteri( target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
- glTexImage2D( target, 0, gl_pf.first, new_im->width( ), new_im->height( ), 0, gl_pf.second, GL_UNSIGNED_BYTE, new_im->data( ) );
+ glTexImage2D( target, 0, internal_format, new_im->width( ), new_im->height( ), 0, format, type, new_im->data( ) );
return id;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|