Text archives Help
- From: sparker@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [MANTA] r1014 - in trunk: . Engine/Control Engine/Display Image Model/Groups Model/Materials StandAlone UserInterface
- Date: Wed, 26 Apr 2006 22:10:23 -0600 (MDT)
Author: sparker
Date: Wed Apr 26 22:10:13 2006
New Revision: 1014
Added:
trunk/Image/SimpleImageBase.cc
trunk/Image/SimpleImageBase.h
Modified:
trunk/CMakeLists.txt
trunk/Engine/Control/RTRT_register.cc
trunk/Engine/Display/FileDisplay.cc
trunk/Engine/Display/GLXImageDisplay.cc
trunk/Engine/Display/OpenGLDisplay.cc
trunk/Engine/Display/OpenGLDisplay.h
trunk/Image/CMakeLists.txt
trunk/Image/Pixel.h
trunk/Image/SimpleImage.h
trunk/Image/SimpleImage_templates.cc
trunk/Image/TGAFile.cc
trunk/Model/Groups/CMakeLists.txt
trunk/Model/Materials/Phong.cc
trunk/StandAlone/manta.cc
trunk/UserInterface/CMakeLists.txt
Log:
Add new image types argb8 (now the default) and bgra8
Make OpenGLDisplay use textures to upload final image. This enable
a fast path on macs, and may help on others. I have tried to make this
portable and respect the availability of extensions but I will need
ome help making sure it works everywhere.
On a macbook pro and a resolution of 1312x800 and imagetraverser null,
this gets 114 fps vs. 80 for the glDrawPixels version. For
pixelsampler null, this gets 75 fps vs. 56 fps. The fast path also
uses less CPU time with the draw.
More work should be done to pad out the width of images to a multiple of 32 to
ensure we don't fall off of the fast path for those cases. We should also do
performance comparisons for other image types and come up with logic to
ensure that we use the fastest where possible.
Modified: trunk/CMakeLists.txt
==============================================================================
--- trunk/CMakeLists.txt (original)
+++ trunk/CMakeLists.txt Wed Apr 26 22:10:13 2006
@@ -162,7 +162,8 @@
######################################################################
# Check for Mac OS
IF (APPLE)
- FIRST_TIME_SET(CMAKE_CXX_FLAGS_RELEASE "-DSCI_ASSERTION_LEVEL=0 -O3 -g
-fgcse-sm -funroll-loops -fstrict-aliasing -fsched-interblock
-falign-loops=16 -falign-jumps=16 -falign-functions=16
-falign-jumps-max-skip=15 -falign-loops-max-skip=15 -ffast-math
-freorder-blocks -mpowerpc-gpopt -force_cpusubtype_ALL -mtune=G5 -mcpu=G5
-mpowerpc64 -faltivec -mabi=altivec -mpowerpc-gfxopt -malign-natural" STRING
"Optimized Flags")
+ #FIRST_TIME_SET(CMAKE_CXX_FLAGS_RELEASE "-DSCI_ASSERTION_LEVEL=0 -O3 -g
-fgcse-sm -funroll-loops -fstrict-aliasing -fsched-interblock
-falign-loops=16 -falign-jumps=16 -falign-functions=16
-falign-jumps-max-skip=15 -falign-loops-max-skip=15 -ffast-math
-freorder-blocks -mpowerpc-gpopt -force_cpusubtype_ALL -mtune=G5 -mcpu=G5
-mpowerpc64 -faltivec -mabi=altivec -mpowerpc-gfxopt -malign-natural" STRING
"Optimized Flags")
+ FIRST_TIME_SET(CMAKE_CXX_FLAGS_RELEASE "-DSCI_ASSERTION_LEVEL=0 -O3 -g
-fgcse-sm -funroll-loops -fstrict-aliasing -fsched-interblock -ffast-math
-freorder-blocks -march=prescott -mtune=prescott -msse -msse2 -msse3
-mfpmath=sse -malign-double" STRING "Optimized Flags")
ENDIF (APPLE)
##################################################################
Modified: trunk/Engine/Control/RTRT_register.cc
==============================================================================
--- trunk/Engine/Control/RTRT_register.cc (original)
+++ trunk/Engine/Control/RTRT_register.cc Wed Apr 26 22:10:13 2006
@@ -62,6 +62,8 @@
engine->registerComponent("null", &NullImage::create);
engine->registerComponent("rgba8", &SimpleImage<RGBA8Pixel>::create);
engine->registerComponent("rgb8", &SimpleImage<RGB8Pixel>::create);
+ engine->registerComponent("abgr8", &SimpleImage<ABGR8Pixel>::create);
+ engine->registerComponent("argb8", &SimpleImage<ARGB8Pixel>::create);
engine->registerComponent("rgbafloat",
&SimpleImage<RGBAfloatPixel>::create);
engine->registerComponent("rgbfloat",
Modified: trunk/Engine/Display/FileDisplay.cc
==============================================================================
--- trunk/Engine/Display/FileDisplay.cc (original)
+++ trunk/Engine/Display/FileDisplay.cc Wed Apr 26 22:10:13 2006
@@ -27,9 +27,6 @@
DEALINGS IN THE SOFTWARE.
*/
-#include <fstream>
-#include <sstream>
-#include <iomanip>
#include <Engine/Display/FileDisplay.h>
#include <Core/Exceptions/IllegalArgument.h>
#include <Core/Exceptions/InternalError.h>
@@ -41,6 +38,10 @@
#include <Image/NRRDFile.h>
#include <Interface/Context.h>
#include <SCIRun/Core/Thread/Time.h>
+#include <iostream>
+#include <fstream>
+#include <sstream>
+#include <iomanip>
using namespace Manta;
using namespace std;
Modified: trunk/Engine/Display/GLXImageDisplay.cc
==============================================================================
--- trunk/Engine/Display/GLXImageDisplay.cc (original)
+++ trunk/Engine/Display/GLXImageDisplay.cc Wed Apr 26 22:10:13 2006
@@ -139,121 +139,149 @@
void GLXImageDisplay::displayImage( const DisplayContext &context, const
Image* image ) {
- // Check to see if this processor should display the image.
- if (context.proc == 0) {
+ // Check to see if this processor should display the image.
+ if (context.proc == 0) {
- // Determine the image resolution.
- int xres, yres;
- bool stereo;
+ // Determine the image resolution.
+ int xres, yres;
+ bool stereo;
- image->getResolution( stereo, xres, yres );
+ image->getResolution( stereo, xres, yres );
- // This code is from OpenGLImageDisplay.
- glViewport(0, 0, xres, yres);
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- gluOrtho2D(0, xres, 0, yres);
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
- glTranslatef(0.375, 0.375, 0.0);
+ // This code is from OpenGLImageDisplay.
+ glViewport(0, 0, xres, yres);
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ gluOrtho2D(0, xres, 0, yres);
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+ glTranslatef(0.375, 0.375, 0.0);
- if(typeid(*image) == typeid(SimpleImage<RGBA8Pixel>)){
- const SimpleImage<RGBA8Pixel>* si =
dynamic_cast<const SimpleImage<RGBA8Pixel>*>(image);
- if(stereo){
- glDrawBuffer(GL_BACK_LEFT);
- glRasterPos2i(0,0);
- glDrawPixels(xres, yres, GL_RGBA,
GL_UNSIGNED_BYTE, si->getRaw(0));
- glDrawBuffer(GL_BACK_RIGHT);
- glRasterPos2i(0,0);
- glDrawPixels(xres, yres, GL_RGBA,
GL_UNSIGNED_BYTE, si->getRaw(1));
- } else {
- glDrawBuffer(GL_BACK);
- glRasterPos2i(0,0);
- glDrawPixels(xres, yres, GL_RGBA,
GL_UNSIGNED_BYTE, si->getRaw(0));
- }
- } else if(typeid(*image) == typeid(SimpleImage<RGB8Pixel>)){
- const SimpleImage<RGB8Pixel>* si = dynamic_cast<const
SimpleImage<RGB8Pixel>*>(image);
- if(stereo){
- glDrawBuffer(GL_BACK_LEFT);
- glRasterPos2i(0,0);
- glDrawPixels(xres, yres, GL_RGB,
GL_UNSIGNED_BYTE, si->getRaw(0));
- glDrawBuffer(GL_BACK_RIGHT);
- glRasterPos2i(0,0);
- glDrawPixels(xres, yres, GL_RGB,
GL_UNSIGNED_BYTE, si->getRaw(1));
- } else {
- glDrawBuffer(GL_BACK);
- glRasterPos2i(0,0);
- glDrawPixels(xres, yres, GL_RGB,
GL_UNSIGNED_BYTE, si->getRaw(0));
- }
- } else if(typeid(*image) ==
typeid(SimpleImage<RGBAfloatPixel>)){
- const SimpleImage<RGBAfloatPixel>* si =
dynamic_cast<const SimpleImage<RGBAfloatPixel>*>(image);
-
-
///////////////////////////////////////////////////////////////////////////
- // Assuming this is a performance image: normalize
the image values.
- int total_size = xres * yres;
- RGBAfloatPixel *pixel = si->getRaw(0);
-
- float max_p, min_p;
- max_p = min_p = pixel[0].r;
-
- // Determine min and max.
- for (int i=1;i<total_size;++i) {
- if (pixel[i].r > max_p) max_p = pixel[i].r;
- else if (pixel[i].r < min_p) min_p =
pixel[i].r;
- }
-
- // Determine scale and bias.
- float scale = 1 / (max_p - min_p);
-
- for (int i=0;i<total_size;++i) {
- float v = (pixel[i].r - min_p) * scale;
- pixel[i].r = pixel[i].g = pixel[i].b =
pixel[i].a = v;
- }
-
-
///////////////////////////////////////////////////////////////////////////
-
-
-
- if(stereo){
- glDrawBuffer(GL_BACK_LEFT);
- glRasterPos2i(0,0);
- glDrawPixels(xres, yres, GL_RGBA, GL_FLOAT,
si->getRaw(0));
- glDrawBuffer(GL_BACK_RIGHT);
- glRasterPos2i(0,0);
- glDrawPixels(xres, yres, GL_RGBA, GL_FLOAT,
si->getRaw(1));
- } else {
- glDrawBuffer(GL_BACK);
- glRasterPos2i(0,0);
- glDrawPixels(xres, yres, GL_RGBA , GL_FLOAT,
si->getRaw(0));
- }
- } else if(typeid(*image) ==
typeid(SimpleImage<RGBfloatPixel>)){
- const SimpleImage<RGBfloatPixel>* si =
dynamic_cast<const SimpleImage<RGBfloatPixel>*>(image);
- if(stereo){
- glDrawBuffer(GL_BACK_LEFT);
- glRasterPos2i(0,0);
- glDrawPixels(xres, yres, GL_RGB, GL_FLOAT,
si->getRaw(0));
- glDrawBuffer(GL_BACK_RIGHT);
- glRasterPos2i(0,0);
- glDrawPixels(xres, yres, GL_RGB, GL_FLOAT,
si->getRaw(1));
- } else {
- glDrawBuffer(GL_BACK);
- glRasterPos2i(0,0);
- glDrawPixels(xres, yres, GL_RGB, GL_FLOAT,
si->getRaw(0));
- }
- }
-
+ if(typeid(*image) == typeid(SimpleImage<RGBA8Pixel>)){
+ const SimpleImage<RGBA8Pixel>* si = dynamic_cast<const
SimpleImage<RGBA8Pixel>*>(image);
+ if(stereo){
+ glDrawBuffer(GL_BACK_LEFT);
+ glRasterPos2i(0,0);
+ glDrawPixels(xres, yres, GL_RGBA, GL_UNSIGNED_BYTE,
si->getRawPixels(0));
+ glDrawBuffer(GL_BACK_RIGHT);
+ glRasterPos2i(0,0);
+ glDrawPixels(xres, yres, GL_RGBA, GL_UNSIGNED_BYTE,
si->getRawPixels(1));
+ } else {
+ glDrawBuffer(GL_BACK);
+ glRasterPos2i(0,0);
+ glDrawPixels(xres, yres, GL_RGBA, GL_UNSIGNED_BYTE,
si->getRawPixels(0));
+ }
+ } else if(typeid(*image) == typeid(SimpleImage<ABGR8Pixel>)){
+ const SimpleImage<ABGR8Pixel>* si = dynamic_cast<const
SimpleImage<ABGR8Pixel>*>(image);
+ if(stereo){
+ glDrawBuffer(GL_BACK_LEFT);
+ glRasterPos2i(0,0);
+ glDrawPixels(xres, yres, GL_ABGR_EXT, GL_UNSIGNED_BYTE,
si->getRawPixels(0));
+ glDrawBuffer(GL_BACK_RIGHT);
+ glRasterPos2i(0,0);
+ glDrawPixels(xres, yres, GL_ABGR_EXT, GL_UNSIGNED_BYTE,
si->getRawPixels(1));
+ } else {
+ glDrawBuffer(GL_BACK);
+ glRasterPos2i(0,0);
+ glDrawPixels(xres, yres, GL_ABGR_EXT, GL_UNSIGNED_BYTE,
si->getRawPixels(0));
+ }
+ } else if(typeid(*image) == typeid(SimpleImage<ARGB8Pixel>)){
+ const SimpleImage<ARGB8Pixel>* si = dynamic_cast<const
SimpleImage<ARGB8Pixel>*>(image);
+ if(stereo){
+ glDrawBuffer(GL_BACK_LEFT);
+ glRasterPos2i(0,0);
+ glDrawPixels(xres, yres, GL_ABGR_EXT, GL_UNSIGNED_INT_8_8_8_8_REV,
si->getRawPixels(0));
+ glDrawBuffer(GL_BACK_RIGHT);
+ glRasterPos2i(0,0);
+ glDrawPixels(xres, yres, GL_ABGR_EXT, GL_UNSIGNED_INT_8_8_8_8_REV,
si->getRawPixels(1));
+ } else {
+ glDrawBuffer(GL_BACK);
+ glRasterPos2i(0,0);
+ glDrawPixels(xres, yres, GL_ABGR_EXT, GL_UNSIGNED_INT_8_8_8_8_REV,
si->getRawPixels(0));
+ }
+ } else if(typeid(*image) == typeid(SimpleImage<RGB8Pixel>)){
+ const SimpleImage<RGB8Pixel>* si = dynamic_cast<const
SimpleImage<RGB8Pixel>*>(image);
+ if(stereo){
+ glDrawBuffer(GL_BACK_LEFT);
+ glRasterPos2i(0,0);
+ glDrawPixels(xres, yres, GL_RGB, GL_UNSIGNED_BYTE,
si->getRawPixels(0));
+ glDrawBuffer(GL_BACK_RIGHT);
+ glRasterPos2i(0,0);
+ glDrawPixels(xres, yres, GL_RGB, GL_UNSIGNED_BYTE,
si->getRawPixels(1));
+ } else {
+ glDrawBuffer(GL_BACK);
+ glRasterPos2i(0,0);
+ glDrawPixels(xres, yres, GL_RGB, GL_UNSIGNED_BYTE,
si->getRawPixels(0));
+ }
+ } else if(typeid(*image) == typeid(SimpleImage<RGBAfloatPixel>)){
+ const SimpleImage<RGBAfloatPixel>* si = dynamic_cast<const
SimpleImage<RGBAfloatPixel>*>(image);
+
+
///////////////////////////////////////////////////////////////////////////
+ // Assuming this is a performance image: normalize the image values.
+ int total_size = xres * yres;
+ RGBAfloatPixel *pixel = si->getRawPixels(0);
+
+ float max_p, min_p;
+ max_p = min_p = pixel[0].r;
+
+ // Determine min and max.
+ for (int i=1;i<total_size;++i) {
+ if (pixel[i].r > max_p) max_p = pixel[i].r;
+ else if (pixel[i].r < min_p) min_p = pixel[i].r;
+ }
+
+ // Determine scale and bias.
+ float scale = 1 / (max_p - min_p);
+
+ for (int i=0;i<total_size;++i) {
+ float v = (pixel[i].r - min_p) * scale;
+ pixel[i].r = pixel[i].g = pixel[i].b = pixel[i].a = v;
+ }
+
+
///////////////////////////////////////////////////////////////////////////
+
+
+
+ if(stereo){
+ glDrawBuffer(GL_BACK_LEFT);
+ glRasterPos2i(0,0);
+ glDrawPixels(xres, yres, GL_RGBA, GL_FLOAT, si->getRawPixels(0));
+ glDrawBuffer(GL_BACK_RIGHT);
+ glRasterPos2i(0,0);
+ glDrawPixels(xres, yres, GL_RGBA, GL_FLOAT, si->getRawPixels(1));
+ } else {
+ glDrawBuffer(GL_BACK);
+ glRasterPos2i(0,0);
+ glDrawPixels(xres, yres, GL_RGBA , GL_FLOAT, si->getRawPixels(0));
+ }
+ } else if(typeid(*image) == typeid(SimpleImage<RGBfloatPixel>)){
+ const SimpleImage<RGBfloatPixel>* si = dynamic_cast<const
SimpleImage<RGBfloatPixel>*>(image);
+ if(stereo){
+ glDrawBuffer(GL_BACK_LEFT);
+ glRasterPos2i(0,0);
+ glDrawPixels(xres, yres, GL_RGB, GL_FLOAT, si->getRawPixels(0));
+ glDrawBuffer(GL_BACK_RIGHT);
+ glRasterPos2i(0,0);
+ glDrawPixels(xres, yres, GL_RGB, GL_FLOAT, si->getRawPixels(1));
+ } else {
+ glDrawBuffer(GL_BACK);
+ glRasterPos2i(0,0);
+ glDrawPixels(xres, yres, GL_RGB, GL_FLOAT, si->getRawPixels(0));
+ }
+ }
+
// Output fps.
// display_frame_rate( 1.0 );
- // Swap buffers.
- glXSwapBuffers( x_display, glx_drawable );
-
- // Check for any gl error.
- GLenum errcode = glGetError();
- if(errcode != GL_NO_ERROR) {
- std::cerr << "GLXImageDisplay: Error code from
OpenGL: " << gluErrorString(errcode) << std::endl;
- }
- }
+ // Swap buffers.
+ glXSwapBuffers( x_display, glx_drawable );
+
+ // Check for any gl error.
+ GLenum errcode = glGetError();
+ if(errcode != GL_NO_ERROR) {
+ std::cerr << "GLXImageDisplay: Error code from OpenGL: " <<
gluErrorString(errcode) << std::endl;
+ }
+ }
}
void GLXImageDisplay::display_frame_rate(double framerate) {
Modified: trunk/Engine/Display/OpenGLDisplay.cc
==============================================================================
--- trunk/Engine/Display/OpenGLDisplay.cc (original)
+++ trunk/Engine/Display/OpenGLDisplay.cc Wed Apr 26 22:10:13 2006
@@ -14,9 +14,54 @@
#include <Core/Exceptions/InternalError.h>
#include <Core/Thread/Time.h>
#include <Core/Util/NotFinished.h>
+#include <GL/glu.h>
#include <X11/Xutil.h>
+#ifdef __APPLE__
+// For some reason, apple has these extensions but doesn't have the proper
+// definitions when it is being used under X11. Define them here.
+#ifndef GL_EXT_texture_rectangle
+#define GL_EXT_texture_rectangle 1
+#define GL_TEXTURE_RECTANGLE_EXT 0x84F5
+#define GL_TEXTURE_BINDING_RECTANGLE_EXT 0x84F6
+#define GL_PROXY_TEXTURE_RECTANGLE_EXT 0x84F7
+#define GL_MAX_RECTANGLE_TEXTURE_SIZE_EXT 0x84F8
+#endif
+#ifndef GL_APPLE_client_storage
+#define GL_APPLE_client_storage 1
+#define GL_UNPACK_CLIENT_STORAGE_APPLE 0x85B2
+#endif
+#ifndef GL_APPLE_texture_range
+#define GL_APPLE_texture_range 1
+#define GL_TEXTURE_RANGE_LENGTH_APPLE 0x85B7
+#define GL_TEXTURE_RANGE_POINTER_APPLE 0x85B8
+#define GL_TEXTURE_STORAGE_HINT_APPLE 0x85BC
+#define GL_TEXTURE_MINIMIZE_STORAGE_APPLE 0x85B6
+#define GL_STORAGE_PRIVATE_APPLE 0x85BD
+#define GL_STORAGE_CACHED_APPLE 0x85BE
+#define GL_STORAGE_SHARED_APPLE 0x85BF
+// Unfortunately, this isn't defined
+#define glTextureRangeAPPLE(x, y, z)
+#endif
+#endif /* __APPLE__ */
+
+// If these extensions are not availble, define these constants to something
so
+// that the code will still compile. It won't get executed due to logic in
+// the setup code
+#ifndef GL_EXT_texture_rectangle
+#define GL_EXT_texture_rectangle 0
+#define GL_TEXTURE_RECTANGLE_EXT 0
+#endif
+#ifndef GL_APPLE_client_storage
+#define GL_APPLE_client_storage 0
+#endif
+#ifndef GL_APPLE_texture_range
+#define GL_APPLE_texture_range 0
+#define GL_TEXTURE_STORAGE_HINT_APPLE 0
+#define GL_STORAGE_SHARED_APPLE 0
+#define glTextureRangeAPPLE(x, y, z)
+#endif
#include <sgi_stl_warnings_off.h>
#include <typeinfo>
@@ -37,6 +82,7 @@
// Open X window
parentWindow = 0;
displayProc = 0;
+ mode = "texture";
int argc = (int)args.size();
for(int i=0;i<argc;i++){
if(args[i] == "-parentWindow"){
@@ -50,6 +96,12 @@
throw new IllegalArgument("OpenGLDisplay -displayProc", i, args);
if(displayProc < 0)
throw new IllegalValue<int>("Display processor should be >= 0",
displayProc);
+ } else if(args[i] == "-mode"){
+ if(!getStringArg(i, args, mode))
+ throw new IllegalArgument("OpenGLDisplay -mode", i, args);
+ if(mode != "image" && mode != "texture")
+ throw new IllegalValue<string>("Illegal dispay mode", mode);
+
} else {
throw IllegalArgument("OpenGLDisplay", i, args);
}
@@ -61,6 +113,13 @@
win = 0;
// If this is zero then the value hasn't been used yet.
last_frame_time = 0;
+ need_texids = true;
+ int x = 0x12345678;
+ char* p = (char*)&x;
+ if(p[0] == 0x12)
+ big_endian = true;
+ else
+ big_endian = false;
}
OpenGLDisplay::~OpenGLDisplay()
@@ -207,11 +266,25 @@
throw InternalError("getGLFont failed!\n", __FILE__, __LINE__);
}
+ // Check for texturing extensions
+ have_texturerectangle = false;
+ if(GL_EXT_texture_rectangle && have_extension("GL_EXT_texture_rectangle")){
+ have_texturerectangle = true;
+ }
+ have_clientstorage = false;
+ if(GL_APPLE_client_storage && have_extension("GL_APPLE_client_storage")){
+ have_clientstorage = true;
+ }
+ have_texturerange = false;
+ if(GL_APPLE_texture_range && have_extension("GL_APPLE_texture_range")){
+ have_texturerange = true;
+ }
+
if(!glXMakeCurrent(dpy, None, NULL)) {
XHelper::Xlock.unlock();
throw InternalError("glXMakeCurrent failed!\n", __FILE__, __LINE__);
}
-
+
XHelper::Xlock.unlock();
}
@@ -237,83 +310,27 @@
throw InternalError("glXMakeCurrent failed!\n", __FILE__, __LINE__);
madeCurrent=true;
}
+
bool stereo;
int xres, yres;
image->getResolution(stereo, xres, yres);
glViewport(0, 0, xres, yres);
+
+ if(mode == "texture" && drawImage_texture(image)){
+ // Drawn by texture...
+ } else if(drawImage_pixels(image)){
+ // Drawn by pixels...
+ } else {
+ throw InternalError("Unknown image type in OpenGLDisplay",
+ __FILE__, __LINE__);
+ }
+ gl_print_error(__FILE__,__LINE__);
+
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0, xres, 0, yres);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
- glTranslatef(0.375, 0.375, 0.0);
- if(typeid(*image) == typeid(SimpleImage<RGBA8Pixel>)){
- const SimpleImage<RGBA8Pixel>* si = dynamic_cast<const
SimpleImage<RGBA8Pixel>*>(image);
- if(stereo){
- glDrawBuffer(GL_BACK_LEFT);
- glRasterPos2i(0,0);
- glDrawPixels(xres, yres, GL_RGBA, GL_UNSIGNED_BYTE, si->getRaw(0));
- glDrawBuffer(GL_BACK_RIGHT);
- glRasterPos2i(0,0); gl_print_error(__FILE__,__LINE__);
- glDrawPixels(xres, yres, GL_RGBA, GL_UNSIGNED_BYTE, si->getRaw(1));
-
- } else {
- glDrawBuffer(GL_BACK);
- glRasterPos2i(0,0);
- glDrawPixels(xres, yres, GL_RGBA, GL_UNSIGNED_BYTE, si->getRaw(0));
- }
- } else if(typeid(*image) == typeid(SimpleImage<RGB8Pixel>)){
- const SimpleImage<RGB8Pixel>* si = dynamic_cast<const
SimpleImage<RGB8Pixel>*>(image);
- if(stereo){
-
- glDrawBuffer(GL_BACK_LEFT);
- glRasterPos2i(0,0);
- glDrawPixels(xres, yres, GL_RGB, GL_UNSIGNED_BYTE, si->getRaw(0));
- glDrawBuffer(GL_BACK_RIGHT);
- glRasterPos2i(0,0);
- glDrawPixels(xres, yres, GL_RGB, GL_UNSIGNED_BYTE, si->getRaw(1));
-
- gl_print_error(__FILE__,__LINE__);
- } else {
- glDrawBuffer(GL_BACK);
- glRasterPos2i(0,0);
- glDrawPixels(xres, yres, GL_RGB, GL_UNSIGNED_BYTE, si->getRaw(0));
-
- gl_print_error(__FILE__,__LINE__);
- }
- } else if(typeid(*image) == typeid(SimpleImage<RGBAfloatPixel>)){
- const SimpleImage<RGBAfloatPixel>* si = dynamic_cast<const
SimpleImage<RGBAfloatPixel>*>(image);
- if(stereo){
- glDrawBuffer(GL_BACK_LEFT);
- glRasterPos2i(0,0);
- glDrawPixels(xres, yres, GL_RGBA, GL_FLOAT, si->getRaw(0));
- glDrawBuffer(GL_BACK_RIGHT);
- glRasterPos2i(0,0);
- glDrawPixels(xres, yres, GL_RGBA, GL_FLOAT, si->getRaw(1));
- } else {
- glDrawBuffer(GL_BACK);
- glRasterPos2i(0,0);
- glDrawPixels(xres, yres, GL_RGBA , GL_FLOAT, si->getRaw(0));
- }
- } else if(typeid(*image) == typeid(SimpleImage<RGBfloatPixel>)){
- const SimpleImage<RGBfloatPixel>* si = dynamic_cast<const
SimpleImage<RGBfloatPixel>*>(image);
- if(stereo){
- glDrawBuffer(GL_BACK_LEFT);
- glRasterPos2i(0,0);
- glDrawPixels(xres, yres, GL_RGB, GL_FLOAT, si->getRaw(0));
- glDrawBuffer(GL_BACK_RIGHT);
- glRasterPos2i(0,0);
- glDrawPixels(xres, yres, GL_RGB, GL_FLOAT, si->getRaw(1));
- } else {
- glDrawBuffer(GL_BACK);
- glRasterPos2i(0,0);
- glDrawPixels(xres, yres, GL_RGB, GL_FLOAT, si->getRaw(0));
- }
- } else {
- throw InternalError("Unknown image type in OpenGLDisplay",
- __FILE__, __LINE__);
- }
-
display_frame_rate(1.0/(currentTime-last_frame_time));
last_frame_time = currentTime;
@@ -327,7 +344,161 @@
}
}
-void OpenGLDisplay::display_frame_rate(double framerate) {
+bool OpenGLDisplay::drawImage_pixels(const Image* image)
+{
+ const SimpleImageBase* si = dynamic_cast<const SimpleImageBase*>(image);
+ if(!si)
+ return false;
+ bool stereo;
+ int xres, yres;
+ image->getResolution(stereo, xres, yres);
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ gluOrtho2D(0, xres, 0, yres);
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+ glTranslatef(0.375, 0.375, 0.0);
+ GLenum format;
+ GLenum type;
+ if(typeid(*image) == typeid(SimpleImage<RGBA8Pixel>)){
+ format = GL_RGBA;
+ type = GL_UNSIGNED_BYTE;
+ } else if(typeid(*image) == typeid(SimpleImage<RGB8Pixel>)){
+ format = GL_RGB;
+ type = GL_UNSIGNED_BYTE;
+ } else if(typeid(*image) == typeid(SimpleImage<ABGR8Pixel>)){
+ format = GL_ABGR_EXT;
+ type = GL_UNSIGNED_BYTE;
+ } else if(typeid(*image) == typeid(SimpleImage<ARGB8Pixel>)){
+ format = GL_BGRA;
+ type = big_endian?GL_UNSIGNED_INT_8_8_8_8_REV : GL_UNSIGNED_INT_8_8_8_8;
+ } else if(typeid(*image) == typeid(SimpleImage<RGBAfloatPixel>)){
+ format = GL_RGBA;
+ type = GL_FLOAT;
+ } else if(typeid(*image) == typeid(SimpleImage<RGBfloatPixel>)){
+ format = GL_RGB;
+ type = GL_FLOAT;
+ } else {
+ return false;
+ }
+ if(stereo){
+ glDrawBuffer(GL_BACK_LEFT);
+ glRasterPos2i(0,0);
+ glDrawPixels(xres, yres, format, type, si->getRawData(0));
+ glDrawBuffer(GL_BACK_RIGHT);
+ glRasterPos2i(0,0);
+ glDrawPixels(xres, yres, format, type, si->getRawData(1));
+ } else {
+ glDrawBuffer(GL_BACK);
+ glRasterPos2i(0,0);
+ glDrawPixels(xres, yres, format, type, si->getRawData(0));
+ }
+ return true;
+}
+
+bool OpenGLDisplay::drawImage_texture(const Image* image)
+{
+ if(!have_texturerectangle)
+ return false;
+ const SimpleImageBase* si = dynamic_cast<const SimpleImageBase*>(image);
+ if(!si)
+ return false;
+
+ bool stereo;
+ int xres, yres;
+ image->getResolution(stereo, xres, yres);
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ gluOrtho2D(0, 1, 0, 1);
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+
+ glDisable(GL_TEXTURE_2D);
+ glEnable(GL_TEXTURE_RECTANGLE_EXT);
+
+ if(need_texids){
+ // Free old textures if necessary...
+ glGenTextures(2, texids);
+ need_texids = false;
+ }
+
+ glBindTexture(GL_TEXTURE_RECTANGLE_EXT, texids[0]);
+ glTextureRangeAPPLE(GL_TEXTURE_RECTANGLE_EXT, xres*yres*4, data);
+ if(have_clientstorage)
+ glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE);
+ glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
+
+ if(have_texturerange)
+ glTexParameteri(GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_STORAGE_HINT_APPLE,
+ GL_STORAGE_SHARED_APPLE);
+ 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);
+ glTexParameteri (GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_MAG_FILTER,
GL_NEAREST);
+ glTexParameteri (GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_MIN_FILTER,
GL_NEAREST);
+ glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+
+ GLenum format;
+ GLenum type;
+ if(typeid(*image) == typeid(SimpleImage<RGBA8Pixel>)){
+ format = GL_RGBA;
+ type = big_endian? GL_UNSIGNED_INT_8_8_8_8 : GL_UNSIGNED_INT_8_8_8_8_REV;
+ } else if(typeid(*image) == typeid(SimpleImage<RGB8Pixel>)){
+ format = GL_RGB;
+ type = GL_UNSIGNED_BYTE;
+ } else if(typeid(*image) == typeid(SimpleImage<ABGR8Pixel>)){
+ format = GL_RGBA;
+ type = big_endian? GL_UNSIGNED_INT_8_8_8_8_REV : GL_UNSIGNED_INT_8_8_8_8;
+ } else if(typeid(*image) == typeid(SimpleImage<ARGB8Pixel>)){
+ format = GL_BGRA;
+ type = big_endian? GL_UNSIGNED_INT_8_8_8_8_REV : GL_UNSIGNED_INT_8_8_8_8;
+ } else {
+ return false;
+ }
+
+ // Load textures
+ glTexImage2D(GL_TEXTURE_RECTANGLE_EXT, 0, GL_RGB,
+ xres, yres, 0, format, type,
+ si->getRawData(0));
+ if(stereo){
+ glBindTexture(GL_TEXTURE_RECTANGLE_EXT, texids[0]);
+ glTexImage2D(GL_TEXTURE_RECTANGLE_EXT, 0, GL_RGB,
+ xres, yres, 0, format, type,
+ si->getRawData(0));
+ glBindTexture(GL_TEXTURE_RECTANGLE_EXT, texids[0]);
+ }
+
+ glDrawBuffer(stereo? GL_BACK_LEFT : GL_BACK);
+ glBegin(GL_QUADS);
+ glTexCoord2f(0, 0);
+ glVertex2f(0, 0);
+ glTexCoord2f(xres, 0);
+ glVertex2f(1, 0);
+ glTexCoord2f(xres, yres);
+ glVertex2f(1, 1);
+ glTexCoord2f(0, yres);
+ glVertex2f(0, 1);
+ glEnd();
+ if(stereo){
+ glDrawBuffer(GL_BACK_RIGHT);
+ glBindTexture(GL_TEXTURE_RECTANGLE_EXT, texids[1]);
+ glBegin(GL_QUADS);
+ glTexCoord2f(0, 0);
+ glVertex2f(0, 0);
+ glTexCoord2f(xres, 0);
+ glVertex2f(1, 0);
+ glTexCoord2f(xres, yres);
+ glVertex2f(1, 1);
+ glTexCoord2f(0, yres);
+ glVertex2f(0, 1);
+ glEnd();
+ }
+ glDisable(GL_TEXTURE_RECTANGLE_EXT);
+ return true;
+}
+
+void OpenGLDisplay::display_frame_rate(double framerate)
+{
// Display textual information on the screen:
char buf[200];
if (framerate > 1)
@@ -343,4 +514,30 @@
glRecti(8,3-fontInfo->descent-2,12+width,fontInfo->ascent+3);
glDisable(GL_BLEND);
XHelper::printString(fontbase, 10, 3, buf, RGBColor(1,1,1));
+}
+
+void OpenGLDisplay::gl_print_error(const char *file, int line)
+{
+ GLenum errcode = glGetError();
+ if(errcode != GL_NO_ERROR)
+ std::cerr << "OpenGLDisplay: "
+ << file << ":"
+ << line << " error: "
+ << gluErrorString(errcode) << std::endl;
+}
+
+bool OpenGLDisplay::have_extension(const char* name)
+{
+ char* extensions = (char*)glGetString(GL_EXTENSIONS);
+ if(!extensions)
+ return false;
+
+ istringstream in(extensions);
+ while(in){
+ string exname;
+ in >> exname;
+ if(in && exname == name)
+ return true;
+ }
+ return false;
}
Modified: trunk/Engine/Display/OpenGLDisplay.h
==============================================================================
--- trunk/Engine/Display/OpenGLDisplay.h (original)
+++ trunk/Engine/Display/OpenGLDisplay.h Wed Apr 26 22:10:13 2006
@@ -5,7 +5,6 @@
#include <Interface/ImageDisplay.h>
#include <X11/Xlib.h>
#include <GL/glx.h>
-#include <GL/glu.h>
#include <sgi_stl_warnings_off.h>
#include <string>
#include <iostream>
@@ -40,6 +39,14 @@
GLuint fontbase;
int displayProc;
+ string mode;
+ bool need_texids;
+ GLuint texids[2];
+
+ bool have_texturerectangle;
+ bool have_clientstorage;
+ bool have_texturerange;
+ bool big_endian;
// This is when the last frame started displaying. Use it to
// compute the framerate.
@@ -48,15 +55,11 @@
// Used to display the frame rate on the screen
void display_frame_rate(double framerate);
- inline void gl_print_error(const char *file, int line) {
-
- GLenum errcode = glGetError();
- if(errcode != GL_NO_ERROR)
- std::cerr << "OpenGLDisplay: "
- << file << ":"
- << line << " error: "
- << gluErrorString(errcode) << std::endl;
- }
+ void gl_print_error(const char *file, int line);
+ bool drawImage_texture(const Image* image);
+ bool drawImage_pixels(const Image* image);
+
+ bool have_extension(const char* name);
};
}
Modified: trunk/Image/CMakeLists.txt
==============================================================================
--- trunk/Image/CMakeLists.txt (original)
+++ trunk/Image/CMakeLists.txt Wed Apr 26 22:10:13 2006
@@ -29,6 +29,8 @@
NullImage.cc
NullImage.h
Pixel.h
+ SimpleImageBase.h
+ SimpleImageBase.cc
SimpleImage.h
SimpleImage_templates.cc
TGAFile.h
Modified: trunk/Image/Pixel.h
==============================================================================
--- trunk/Image/Pixel.h (original)
+++ trunk/Image/Pixel.h Wed Apr 26 22:10:13 2006
@@ -44,7 +44,95 @@
}
inline void convertToRGBColor(RGBColor& c, const RGBA8Pixel& p) {
- ColorComponent norm = (ColorComponent)1/255;
+ ColorComponent norm = (ColorComponent)1/(ColorComponent)255;
+ c.setR(p.r*norm);
+ c.setG(p.g*norm);
+ c.setB(p.b*norm);
+ }
+
+ class ABGR8Pixel {
+ public:
+ unsigned char a;
+ unsigned char b;
+ unsigned char g;
+ unsigned char r;
+ };
+
+ inline void convertToPixel(ABGR8Pixel& p, const RGBColor& c) {
+ float r = c.r();
+ r = r<0.f?0.f:r;
+ r = r>1.f?1.f:r;
+ p.r = (unsigned char)(r*255.f);
+ float g = c.g();
+ g = g<0.f?0.f:g;
+ g = g>1.f?1.f:g;
+ p.g = (unsigned char)(g*255.f);
+ float b = c.b();
+ b = b<0.f?0.f:b;
+ b = b>1.f?1.f:b;
+ p.b = (unsigned char)(b*255.f);
+#if SLOWER_VERSION
+ float r = c.r() < 0.f?0.f: c.r() > 1.f? 1.f : c.r();
+ float g = c.g() < 0.f?0.f: c.g() > 1.f? 1.f : c.g();
+ float b = c.b() < 0.f?0.f: c.b() > 1.f? 1.f : c.b();
+ p.r = (unsigned char)(r*255.f);
+ p.g = (unsigned char)(g*255.f);
+ p.b = (unsigned char)(b*255.f);
+#endif
+#if SLOWER_VERSION
+ p.r = c.r() < 0?0: c.r() >= 1? 255:(int)c.r()*255.;
+ p.g = c.g() < 0?0: c.g() >= 1? 255:(int)c.g()*255.;
+ p.b = c.b() < 0?0: c.b() >= 1? 255:(int)c.b()*255.;
+#endif
+ p.a = 255;
+ }
+
+ inline void convertToRGBColor(RGBColor& c, const ABGR8Pixel& p) {
+ ColorComponent norm = (ColorComponent)1/(ColorComponent)255;
+ c.setR(p.r*norm);
+ c.setG(p.g*norm);
+ c.setB(p.b*norm);
+ }
+
+ class ARGB8Pixel {
+ public:
+ unsigned char a;
+ unsigned char r;
+ unsigned char g;
+ unsigned char b;
+ };
+
+ inline void convertToPixel(ARGB8Pixel& p, const RGBColor& c) {
+ p.a = 255;
+ float r = c.r();
+ r = r<0.f?0.f:r;
+ r = r>1.f?1.f:r;
+ p.r = (unsigned char)(r*255.f);
+ float g = c.g();
+ g = g<0.f?0.f:g;
+ g = g>1.f?1.f:g;
+ p.g = (unsigned char)(g*255.f);
+ float b = c.b();
+ b = b<0.f?0.f:b;
+ b = b>1.f?1.f:b;
+ p.b = (unsigned char)(b*255.f);
+#if SLOWER_VERSION
+ float r = c.r() < 0.f?0.f: c.r() > 1.f? 1.f : c.r();
+ float g = c.g() < 0.f?0.f: c.g() > 1.f? 1.f : c.g();
+ float b = c.b() < 0.f?0.f: c.b() > 1.f? 1.f : c.b();
+ p.r = (unsigned char)(r*255.f);
+ p.g = (unsigned char)(g*255.f);
+ p.b = (unsigned char)(b*255.f);
+#endif
+#if SLOWER_VERSION
+ p.r = c.r() < 0?0: c.r() >= 1? 255:(int)c.r()*255.;
+ p.g = c.g() < 0?0: c.g() >= 1? 255:(int)c.g()*255.;
+ p.b = c.b() < 0?0: c.b() >= 1? 255:(int)c.b()*255.;
+#endif
+ }
+
+ inline void convertToRGBColor(RGBColor& c, const ARGB8Pixel& p) {
+ ColorComponent norm = (ColorComponent)1/(ColorComponent)255;
c.setR(p.r*norm);
c.setG(p.g*norm);
c.setB(p.b*norm);
Modified: trunk/Image/SimpleImage.h
==============================================================================
--- trunk/Image/SimpleImage.h (original)
+++ trunk/Image/SimpleImage.h Wed Apr 26 22:10:13 2006
@@ -29,44 +29,43 @@
#ifndef Manta_SimpleImage_h
#define Manta_SimpleImage_h
-#include <Interface/Image.h>
+#include <Image/SimpleImageBase.h>
#include <Core/Color/Color.h>
#include <Interface/Parameters.h>
#include <Core/Exceptions/IllegalValue.h>
-#include <Core/Util/NotFinished.h>
#include <sgi_stl_warnings_off.h>
#include <string>
#include <vector>
#include <sgi_stl_warnings_on.h>
namespace Manta {
- template<class Pixel> class SimpleImage : public Image {
+ template<class Pixel> class SimpleImage : public SimpleImageBase {
public:
SimpleImage(bool stereo, int xres, int yres);
virtual ~SimpleImage();
- virtual void set(const Fragment&);
- virtual void get(Fragment&) const;
- virtual bool isValid() const;
- virtual void setValid(bool to);
- virtual void getResolution(bool& stereo, int& xres, int& yres) const;
static Image* create(const std::vector<std::string>& args, bool stereo,
int xres, int yres);
+ void set(const Fragment& fragment);
+ void get(Fragment& fragment) const;
- Pixel* getRaw(int which_eye) const;
+ Pixel* getRawPixels(int which_eye) const;
+ void* getRawData(int which_eye) const;
private:
SimpleImage(const Image&);
SimpleImage& operator=(const SimpleImage&);
- bool valid;
- bool stereo;
- int xres, yres;
-
char* data;
Pixel** eyeStart[2];
};
template<class Pixel>
+ SimpleImage<Pixel>::~SimpleImage()
+ {
+ delete[] data;
+ }
+
+ template<class Pixel>
Image* SimpleImage<Pixel>::create(const std::vector<std::string>& args,
bool stereo, int xres, int yres)
{
@@ -78,7 +77,7 @@
template<class Pixel>
SimpleImage<Pixel>::SimpleImage(bool stereo, int xres, int yres)
- : stereo(stereo), xres(xres), yres(yres)
+ : SimpleImageBase(stereo, xres, yres)
{
valid = false;
int numEyes = stereo?2:1;
@@ -103,38 +102,10 @@
}
template<class Pixel>
- SimpleImage<Pixel>::~SimpleImage()
- {
- delete[] data;
- }
-
- template<class Pixel>
- void SimpleImage<Pixel>::getResolution(bool& out_stereo,
- int& out_xres, int& out_yres) const
- {
- out_stereo = stereo;
- out_xres = xres;
- out_yres = yres;
- }
-
- template<class Pixel>
- bool SimpleImage<Pixel>::isValid() const
- {
- return valid;
- }
-
- template<class Pixel>
- void SimpleImage<Pixel>::setValid(bool to)
- {
- valid = to;
- }
-
- template<class Pixel>
void SimpleImage<Pixel>::set(const Fragment& fragment)
{
- //cout << "inside set image" << endl;
- if(fragment.getFlags() & (Fragment::ConsecutiveX|Fragment::ConstantEye)
- == (Fragment::ConsecutiveX|Fragment::ConstantEye)){
+ if(fragment.getFlags() & (Fragment::ConsecutiveX|Fragment::ConstantEye)
==
+ (Fragment::ConsecutiveX|Fragment::ConstantEye)){
int nf = fragment.getSize();
Pixel* pix =
eyeStart[fragment.get(0).which_eye][fragment.get(0).y]+fragment.get(0).x;
for(int i=0;i<nf;i++)
@@ -142,9 +113,8 @@
} else {
for(int i=0;i<fragment.getSize();i++){
const Fragment::Element& f = fragment.get(i);
- //cout << "setting " << f.x << ", " << f.y << endl;
if(f.x<xres && f.x>=0 && f.y<yres && f.y>=0)
- convertToPixel(eyeStart[f.which_eye][f.y][f.x], f.color.convertRGB());
+ convertToPixel(eyeStart[f.which_eye][f.y][f.x],
f.color.convertRGB());
}
}
}
@@ -174,7 +144,13 @@
}
template<class Pixel>
- Pixel* SimpleImage<Pixel>::getRaw(int which_eye) const
+ Pixel* SimpleImage<Pixel>::getRawPixels(int which_eye) const
+ {
+ return eyeStart[which_eye][0];
+ }
+
+ template<class Pixel>
+ void* SimpleImage<Pixel>::getRawData(int which_eye) const
{
return eyeStart[which_eye][0];
}
Added: trunk/Image/SimpleImageBase.cc
==============================================================================
--- (empty file)
+++ trunk/Image/SimpleImageBase.cc Wed Apr 26 22:10:13 2006
@@ -0,0 +1,58 @@
+/*
+ For more information, please see:
http://software.sci.utah.edu
+
+ The MIT License
+
+ Copyright (c) 2005
+ Scientific Computing and Imaging Institue, University of Utah
+
+ License for the specific language governing rights and limitations under
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+*/
+
+#include <Image/SimpleImageBase.h>
+
+using namespace Manta;
+
+SimpleImageBase::SimpleImageBase(bool stereo, int xres, int yres)
+ : stereo(stereo), xres(xres), yres(yres)
+{
+}
+
+SimpleImageBase::~SimpleImageBase()
+{
+}
+
+void SimpleImageBase::getResolution(bool& out_stereo,
+ int& out_xres, int& out_yres) const
+{
+ out_stereo = stereo;
+ out_xres = xres;
+ out_yres = yres;
+}
+
+bool SimpleImageBase::isValid() const
+{
+ return valid;
+}
+
+void SimpleImageBase::setValid(bool to)
+{
+ valid = to;
+}
Added: trunk/Image/SimpleImageBase.h
==============================================================================
--- (empty file)
+++ trunk/Image/SimpleImageBase.h Wed Apr 26 22:10:13 2006
@@ -0,0 +1,56 @@
+/*
+ For more information, please see:
http://software.sci.utah.edu
+
+ The MIT License
+
+ Copyright (c) 2005
+ Scientific Computing and Imaging Institue, University of Utah
+
+ License for the specific language governing rights and limitations under
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+*/
+
+#ifndef Manta_SimpleImageBase_h
+#define Manta_SimpleImageBase_h
+
+#include <Interface/Image.h>
+
+namespace Manta {
+ class SimpleImageBase : public Image {
+ public:
+ SimpleImageBase(bool stereo, int xres, int yres);
+ virtual ~SimpleImageBase();
+ virtual bool isValid() const;
+ virtual void setValid(bool to);
+ virtual void getResolution(bool& stereo, int& xres, int& yres) const;
+ virtual void* getRawData(int which_eye) const = 0;
+
+ protected:
+ bool valid;
+ bool stereo;
+ int xres, yres;
+
+ private:
+ SimpleImageBase(const Image&);
+ SimpleImageBase& operator=(const SimpleImageBase&);
+
+ };
+}
+
+#endif
Modified: trunk/Image/SimpleImage_templates.cc
==============================================================================
--- trunk/Image/SimpleImage_templates.cc (original)
+++ trunk/Image/SimpleImage_templates.cc Wed Apr 26 22:10:13 2006
@@ -5,6 +5,8 @@
template class SimpleImage<RGB8Pixel>;
template class SimpleImage<RGBA8Pixel>;
+template class SimpleImage<ABGR8Pixel>;
+template class SimpleImage<ARGB8Pixel>;
template class SimpleImage<RGBfloatPixel>;
template class SimpleImage<RGBAfloatPixel>;
Modified: trunk/Image/TGAFile.cc
==============================================================================
--- trunk/Image/TGAFile.cc (original)
+++ trunk/Image/TGAFile.cc Wed Apr 26 22:10:13 2006
@@ -89,7 +89,7 @@
out.put( 32 ); // Pixel depth: 32bpp
out.put( 8 ); // Image descriptor: 8 bits of alpha,
bottom-left origin
const SimpleImage< RGBA8Pixel > *si = dynamic_cast< const SimpleImage<
RGBA8Pixel > * >( image );
- RGBA8Pixel const *buffer = si->getRaw( eye );
+ RGBA8Pixel const *buffer = si->getRawPixels( eye );
for ( int y = 0; y < yres; ++y )
for ( int x = 0; x < xres; ++x ) {
out.put( buffer->b );
@@ -102,7 +102,7 @@
out.put( 24 ); // Pixel depth: 24bpp
out.put( 0 ); // Image descriptor: 0 bits of alpha,
bottom-left origin
const SimpleImage< RGB8Pixel > *si = dynamic_cast< const SimpleImage<
RGB8Pixel > * >( image );
- RGB8Pixel const *buffer = si->getRaw( eye );
+ RGB8Pixel const *buffer = si->getRawPixels( eye );
for ( int y = 0; y < yres; ++y )
for ( int x = 0; x < xres; ++x ) {
out.put( buffer->b );
@@ -114,7 +114,7 @@
out.put( 32 ); // Pixel depth: 32bpp
out.put( 8 ); // Image descriptor: 8 bits of alpha,
bottom-left origin
const SimpleImage< RGBAfloatPixel > *si = dynamic_cast< const
SimpleImage< RGBAfloatPixel > * >( image );
- RGBAfloatPixel const *buffer = si->getRaw( eye );
+ RGBAfloatPixel const *buffer = si->getRawPixels( eye );
for ( int y = 0; y < yres; ++y )
for ( int x = 0; x < xres; ++x ) {
float b = buffer->b;
@@ -139,7 +139,7 @@
out.put( 24 ); // Pixel depth: 24bpp
out.put( 0 ); // Image descriptor: 0 bits of alpha,
bottom-left origin
const SimpleImage< RGBfloatPixel > *si = dynamic_cast< const
SimpleImage< RGBfloatPixel > * >( image );
- RGBfloatPixel const *buffer = si->getRaw( eye );
+ RGBfloatPixel const *buffer = si->getRawPixels( eye );
for ( int y = 0; y < yres; ++y )
for ( int x = 0; x < xres; ++x ) {
float b = buffer->b;
@@ -205,7 +205,7 @@
in.ignore( id_length );
if ( pixel_depth == 24 && ( image_descriptor & 15 ) == 0 ) {
SimpleImage< RGB8Pixel > *si = new SimpleImage< RGB8Pixel >( false,
width, height );
- RGB8Pixel *buffer = const_cast< RGB8Pixel * >( si->getRaw( 0 ) );
+ RGB8Pixel *buffer = const_cast< RGB8Pixel * >( si->getRawPixels( 0 ) );
for ( int y = 0; y < height; ++y )
for ( int x = 0; x < width; ++x ) {
RGB8Pixel *offset = ( buffer +
@@ -218,7 +218,7 @@
return si;
} else if ( pixel_depth == 32 && ( image_descriptor & 15 ) == 8 ) {
SimpleImage< RGBA8Pixel > *si = new SimpleImage< RGBA8Pixel >( false,
width, height );
- RGBA8Pixel *buffer = const_cast< RGBA8Pixel * >( si->getRaw( 0 ) );
+ RGBA8Pixel *buffer = const_cast< RGBA8Pixel * >( si->getRawPixels( 0 )
);
for ( int y = 0; y < height; ++y )
for ( int x = 0; x < width; ++x ) {
RGBA8Pixel *offset = ( buffer +
Modified: trunk/Model/Groups/CMakeLists.txt
==============================================================================
--- trunk/Model/Groups/CMakeLists.txt (original)
+++ trunk/Model/Groups/CMakeLists.txt Wed Apr 26 22:10:13 2006
@@ -20,7 +20,7 @@
Groups/KDTree.h
Groups/KDTreeLoader.cc
Groups/KDTreeLoader.h
- Groups/KDTreeLoaderIW.cc
+ #Groups/KDTreeLoaderIW.cc
Groups/KDTreeLoaderIW.h
Groups/KDTree2.cc
Groups/KDTree2.h
Modified: trunk/Model/Materials/Phong.cc
==============================================================================
--- trunk/Model/Materials/Phong.cc (original)
+++ trunk/Model/Materials/Phong.cc Wed Apr 26 22:10:13 2006
@@ -46,7 +46,7 @@
Phong::Phong(const Color& diffuse, const Color& specular,
int specpow, ColorComponent refl)
- : specpow(specpow)
+ : specpow(specpow/2)
{
diffusetex = new Constant<Color>(diffuse);
speculartex = new Constant<Color>(specular);
@@ -58,7 +58,7 @@
const Texture<Color>* speculartex,
int specpow, const Texture<ColorComponent>* refltex)
: diffusetex(diffusetex), speculartex(speculartex), refltex(refltex),
- specpow(specpow)
+ specpow(specpow/2)
{
do_refl=true;
if (refltex) {
@@ -139,8 +139,8 @@
Vector H = shadowdir-dir;
ColorComponent cos_alpha = Dot(H, normal);
if(cos_alpha > 0){
- Color::ComponentType length = H.length();
- Color::ComponentType scale = ipow(cos_alpha/length, specpow);
+ Color::ComponentType length = H.length2();
+ Color::ComponentType scale = ipow(cos_alpha*cos_alpha/length,
specpow);
for(int k=0;k<Color::NumComponents;k++)
specularLight[k][to] += light[k] * scale;
}
Modified: trunk/StandAlone/manta.cc
==============================================================================
--- trunk/StandAlone/manta.cc (original)
+++ trunk/StandAlone/manta.cc Wed Apr 26 22:10:13 2006
@@ -190,7 +190,7 @@
rtrt->changeNumWorkers(1);
// Default options.
- if(!rtrt->selectImageType("rgba8"))
+ if(!rtrt->selectImageType("argb8"))
throw InternalError("default image not found", __FILE__, __LINE__);
if(!rtrt->selectShadowAlgorithm("hard"))
Modified: trunk/UserInterface/CMakeLists.txt
==============================================================================
--- trunk/UserInterface/CMakeLists.txt (original)
+++ trunk/UserInterface/CMakeLists.txt Wed Apr 26 22:10:13 2006
@@ -13,6 +13,6 @@
XWindowUI.cc
)
-TARGET_LINK_LIBRARIES(Manta_UserInterface Manta_Interface
+TARGET_LINK_LIBRARIES(Manta_UserInterface Manta_Interface Manta_Engine
Manta_Core_XUtils Manta_Core)
TARGET_LINK_LIBRARIES(Manta_UserInterface ${OPENGL_LIBRARIES}
${X11_LIBRARIES})
- [MANTA] r1014 - in trunk: . Engine/Control Engine/Display Image Model/Groups Model/Materials StandAlone UserInterface, sparker, 04/26/2006
Archive powered by MHonArc 2.6.16.