Commit 486719da authored by Jan Möbius's avatar Jan Möbius

Removed philips stereo from core (moved to postprocessor plugin)



git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@12305 383ad7c9-94d9-4d36-a494-682f7c89f535
parent c8b168e2
......@@ -45,6 +45,7 @@
#define POSTPROCESSORINTERFACE_HH
#include <ACG/GL/GLState.hh>
#include <QAction>
/** \file PostProcessorInterface.hh
*
......@@ -80,6 +81,16 @@ class PostProcessorInterface {
*/
virtual QString postProcessorName() = 0;
/** \brief Return options menu
*
* If you want an options Menu or menu entry, you can return your action here.
* It will be shown on top of the post processors list in the options menu.
*
*
* @return Action for a menu or menu entry
*/
virtual QAction* optionsAction() { return 0; };
};
/** \page PostProcessorInterfacePage Post Processor Interface
......
......@@ -1937,6 +1937,14 @@ void Core::loadPlugin(QString filename, bool silent, QString& _licenseErrors, QO
// Retrieve and store PostProcessor information
if ( postProcessorInfo != 0) {
postProcessorInfo->plugin = postProcessorPlugin;
if ( checkSlot( plugin , "optionsAction()" ) ) {
//Get an action for the post processor options
postProcessorInfo->optionsAction = postProcessorPlugin->optionsAction();
} else {
postProcessorInfo->optionsAction = 0;
}
}
} else {
......
......@@ -176,7 +176,8 @@ unsigned int RenderManager::activeId(unsigned int _id) {
PostProcessorInfo::PostProcessorInfo(PostProcessorInterface* _plugin, QString _name) :
plugin(_plugin),
name(_name)
name(_name),
optionsAction(0)
{
}
......
......@@ -179,6 +179,9 @@ class PostProcessorInfo{
/// Name of the plugin ( requested from the plugin on load)
QString name;
/// Possible action to add an options action or menu to the system.
QAction* optionsAction;
};
......
......@@ -888,20 +888,6 @@ bool initializeSettings() {
if ( ! settings_->contains("Core/Stereo/EyeDistance") )
settings_->setValue("Core/Stereo/EyeDistance",0.07);
// Philips stereo display settings
if ( ! settings_->contains("Core/Stereo/Philips/Content") )
settings_->setValue("Core/Stereo/Philips/Content",3);
if ( ! settings_->contains("Core/Stereo/Philips/Factor") )
settings_->setValue("Core/Stereo/Philips/Factor",64);
if ( ! settings_->contains("Core/Stereo/Philips/Offset") )
settings_->setValue("Core/Stereo/Philips/Offset",128);
if ( ! settings_->contains("Core/Stereo/Philips/Select") )
settings_->setValue("Core/Stereo/Philips/Select",0);
return true;
......
......@@ -415,8 +415,7 @@ QString helpDirStr();
enum StereoMode {
OpenGL,
AnaglyphRedCyan,
AnaglyphCustom,
Philips
AnaglyphCustom
};
/// Store opengl stereo support setting
......
......@@ -261,6 +261,18 @@ void CoreWidget::updatePopupMenuCoordsysNode(QMenu* _menu , const int /*_part*/
QActionGroup* groupPostProcessor = new QActionGroup( this );
groupPostProcessor->setExclusive( true );
// Get the options action for the currently active
for ( unsigned int i = 0 ; i < postProcessorManager().available() ; ++i) {
if ( postProcessorManager().activeId(PluginFunctions::activeExaminer() ) == i )
if( postProcessorManager()[i]->optionsAction != 0 ) {
postProcessorMenu->addAction(postProcessorManager()[i]->optionsAction);
postProcessorMenu->addSeparator();
}
}
// Now add the processor chooser
for ( unsigned int i = 0 ; i < postProcessorManager().available() ; ++i) {
// Add a new Action with the postprocessors name
......
......@@ -590,23 +590,12 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
this, SLOT(slotApplyStereoSettings()));
connect(stereoSettingsWidget_->stereoCustomAnaglyph, SIGNAL(clicked()),
this, SLOT(slotApplyStereoSettings()));
connect(stereoSettingsWidget_->stereoPhilips, SIGNAL(clicked()),
this, SLOT(slotApplyStereoSettings()));
connect(stereoSettingsWidget_->focalDistance, SIGNAL(sliderReleased()),
this, SLOT(slotApplyStereoSettings()));
connect(stereoSettingsWidget_->eyeDistance, SIGNAL(editingFinished()),
this, SLOT(slotApplyStereoSettings()));
connect(stereoSettingsWidget_->headerContentType, SIGNAL(currentIndexChanged(int)),
this, SLOT(slotApplyStereoSettings(int)));
connect(stereoSettingsWidget_->headerFactor, SIGNAL(sliderReleased()),
this, SLOT(slotApplyStereoSettings()));
connect(stereoSettingsWidget_->headerOffsetCC, SIGNAL(sliderReleased()),
this, SLOT(slotApplyStereoSettings()));
connect(stereoSettingsWidget_->headerSelect, SIGNAL(currentIndexChanged(int)),
this, SLOT(slotApplyStereoSettings(int)));
// Close button
connect(stereoSettingsWidget_->closeButton, SIGNAL(clicked()),
stereoSettingsWidget_, SLOT(hide()));
......
......@@ -423,36 +423,10 @@ void CoreWidget::stereoButtonContextMenu(const QPoint& _pos) {
// Set values
stereoSettingsWidget_->stereoAnaglyph->setChecked(OpenFlipper::Options::stereoMode() == OpenFlipper::Options::AnaglyphRedCyan);
stereoSettingsWidget_->stereoCustomAnaglyph->setChecked(OpenFlipper::Options::stereoMode() == OpenFlipper::Options::AnaglyphCustom);
stereoSettingsWidget_->stereoPhilips->setChecked(OpenFlipper::Options::stereoMode() == OpenFlipper::Options::Philips);
stereoSettingsWidget_->eyeDistance->setValue( OpenFlipperSettings().value("Core/Stereo/EyeDistance").toDouble() );
stereoSettingsWidget_->focalDistance->setValue( OpenFlipperSettings().value("Core/Stereo/FocalDistance").toDouble() * 1000);
// Philips stereo mode part
// Block signals such that slotApplyStereoSettings
// won't be called when setting the initial values here...
stereoSettingsWidget_->headerContentType->blockSignals(true);
stereoSettingsWidget_->headerSelect->blockSignals(true);
stereoSettingsWidget_->headerContentType->setCurrentIndex(OpenFlipperSettings().value("Core/Stereo/Philips/Content").toInt());
stereoSettingsWidget_->headerFactor->setValue(OpenFlipperSettings().value("Core/Stereo/Philips/Factor").toInt());
stereoSettingsWidget_->headerOffsetCC->setValue(OpenFlipperSettings().value("Core/Stereo/Philips/Offset").toInt());
stereoSettingsWidget_->factorCounter->setNum(OpenFlipperSettings().value("Core/Stereo/Philips/Factor").toInt());
stereoSettingsWidget_->offsetCounter->setNum(OpenFlipperSettings().value("Core/Stereo/Philips/Offset").toInt());
stereoSettingsWidget_->headerSelect->setCurrentIndex(OpenFlipperSettings().value("Core/Stereo/Philips/Select").toInt());
// Unblock signals
stereoSettingsWidget_->headerContentType->blockSignals(false);
stereoSettingsWidget_->headerSelect->blockSignals(false);
// Show right stacked widget
if (stereoSettingsWidget_->stereoPhilips->isChecked()) {
stereoSettingsWidget_->stackedWidget->setCurrentIndex(1);
} else {
stereoSettingsWidget_->stackedWidget->setCurrentIndex(0);
}
// Move widget to the position of the cursor
stereoSettingsWidget_->move(stereoButton_->mapToGlobal(_pos) - QPoint((int)(stereoSettingsWidget_->width()/2), 0));
// Show widget
......@@ -470,9 +444,6 @@ void CoreWidget::slotApplyStereoSettings(int /*_tmpParam*/) {
} else if (stereoSettingsWidget_->stereoAnaglyph->isChecked()) {
OpenFlipper::Options::stereoMode(OpenFlipper::Options::AnaglyphRedCyan);
stereoSettingsWidget_->stackedWidget->setCurrentIndex(0);
} else if (stereoSettingsWidget_->stereoPhilips->isChecked()) {
OpenFlipper::Options::stereoMode(OpenFlipper::Options::Philips);
stereoSettingsWidget_->stackedWidget->setCurrentIndex(1);
} else {
OpenFlipper::Options::stereoMode(OpenFlipper::Options::OpenGL);
stereoSettingsWidget_->stackedWidget->setCurrentIndex(0);
......@@ -482,16 +453,6 @@ void CoreWidget::slotApplyStereoSettings(int /*_tmpParam*/) {
OpenFlipperSettings().setValue("Core/Stereo/EyeDistance",stereoSettingsWidget_->eyeDistance->value());
OpenFlipperSettings().setValue("Core/Stereo/FocalDistance",double(stereoSettingsWidget_->focalDistance->value()/1000.0));
// Update labels that display the current values
stereoSettingsWidget_->factorCounter->setNum(stereoSettingsWidget_->headerFactor->value());
stereoSettingsWidget_->offsetCounter->setNum(stereoSettingsWidget_->headerOffsetCC->value());
// Set option entries
OpenFlipperSettings().setValue("Core/Stereo/Philips/Content",stereoSettingsWidget_->headerContentType->currentIndex());
OpenFlipperSettings().setValue("Core/Stereo/Philips/Factor",stereoSettingsWidget_->headerFactor->value());
OpenFlipperSettings().setValue("Core/Stereo/Philips/Offset",stereoSettingsWidget_->headerOffsetCC->value());
OpenFlipperSettings().setValue("Core/Stereo/Philips/Select",stereoSettingsWidget_->headerSelect->currentIndex());
// Update all views
for (unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i) {
examiner_widgets_[i]->updateGL();
......
......@@ -147,12 +147,6 @@ glViewer::glViewer( QGraphicsScene* _scene,
glWidget_(_glWidget),
cursorPainter_(0),
cursorPositionValid_(false),
pProgram_(0),
philipsStereoInitialized_(false),
colorTextureBufferWidth_(0),
colorTextureBufferHeight_(0),
depthStencilTextureBufferWidth_(0),
depthStencilTextureBufferHeight_(0),
pickCache_(0),
updatePickCache_(true),
pickCacheSupported_(true),
......@@ -588,16 +582,6 @@ void glViewer::drawScene()
// draw mono or stereo
makeCurrent();
/* std::cerr << "Draw Scene" << std::endl;
std::cerr << "Available renderers: " << renderManager().available() << std::endl;
std::cerr << "Active renderer: " << renderManager().active()->name.toStdString() << std::endl;
std::cerr << "Available postprocessors: " << postProcessorManager().available() << std::endl;
std::cerr << "Active postprocessor: " << postProcessorManager().active()->name.toStdString() << std::endl;
*/
// Check if we use build in default renderers
if ( renderManager().activeId( properties_.viewerId() ) == 0 ) {
if (stereo_) drawScene_stereo();
......@@ -797,16 +781,8 @@ glViewer::drawScene_stereo()
// if somthing went wrong, fallback to normal anaglyph
if (customAnaglyphSupported_)
return;
} else if (OpenFlipper::Options::stereoMode () == OpenFlipper::Options::Philips )
{
drawScenePhilipsStereo ();
return;
}
drawScene_anaglyphStereo ();
}
......
......@@ -665,42 +665,9 @@ private:
GLuint agProgram_;
bool customAnaglyphSupported_;
GLSL::PtrProgram pProgram_;
bool philipsStereoInitialized_;
/** @} */
//===========================================================================
/** @name Buffers
* @{ */
//===========================================================================
private:
/// Updates the Color Texture Buffer to the current size and initializes it if necessary
void updateColorTextureBuffer();
/// Updates the DepthStencil Texture Buffer to the current size and initializes it if necessary
void updateDepthStencilTextureBuffer();
/// color texture buffer
ACG::Texture2D pColorTexture_;
/// depthStencil texture buffer
ACG::Texture2D pDepthStencilTexture_;
/// Current width of the color texture buffer
int colorTextureBufferWidth_;
/// Current height of the color texture buffer
int colorTextureBufferHeight_;
/// Current width of the depthStencil texture buffer
int depthStencilTextureBufferWidth_;
/// Current height of the depthStencil texture buffer
int depthStencilTextureBufferHeight_;
//===========================================================================
/** @name Key handling
* @{ */
......
......@@ -65,8 +65,6 @@
#include <ACG/ShaderUtils/gldebug.h>
#include "crc32.hh"
//== NAMESPACES ===============================================================
......@@ -158,391 +156,6 @@ glViewer::drawScene_glStereo()
}
void glViewer::drawScenePhilipsStereo() {
updateScenePhilipsStereo();
if (!philipsStereoInitialized_)
return;
int vp_l, vp_b, vp_w, vp_h;
glstate_->get_viewport(vp_l, vp_b, vp_w, vp_h);
// ======================================================================================================
// Disable textures
// ======================================================================================================
pDepthStencilTexture_.disable();
pColorTexture_.disable();
// ======================================================================================================
// Render the scene
// ======================================================================================================
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
drawScene_mono();
// ======================================================================================================
// Copy Scene to Textures
// ======================================================================================================
pColorTexture_.enable();
pColorTexture_.bind();
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, vp_l, vp_b, vp_w, vp_h);
pColorTexture_.disable();
pDepthStencilTexture_.enable();
pDepthStencilTexture_.bind();
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, vp_l, vp_b, vp_w, vp_h);
pDepthStencilTexture_.disable();
// Turn on shader program
pProgram_->use();
// ======================================================================================================
// Bind textures to different texture units and tell shader where to find them
// ======================================================================================================
glActiveTextureARB(GL_TEXTURE0_ARB);
pColorTexture_.enable();
pColorTexture_.bind();
glActiveTextureARB(GL_TEXTURE1_ARB);
pDepthStencilTexture_.enable();
pDepthStencilTexture_.bind();
pProgram_->setUniform("ColorTexture", 0);
pProgram_->setUniform("DepthStencil", 1);
// ======================================================================================================
// Render plain textured
// ======================================================================================================
glDisable(GL_LIGHTING);
glDisable(GL_COLOR_MATERIAL);
glDisable(GL_DEPTH_TEST);
// ======================================================================================================
// Setup orthogonal projection
// ======================================================================================================
glstate_->push_projection_matrix();
glstate_->push_modelview_matrix();
glstate_->reset_projection();
glstate_->reset_modelview();
glstate_->ortho(0, vp_w, 0, vp_h, 0, 1);
// ======================================================================================================
// Bind textures to different texture units and tell shader where to find them
// ======================================================================================================
glColor3f(1.0, 1.0, 1.0);
// ======================================================================================================
// Clear buffers
// ======================================================================================================
glClearColor(.0, .0, .0, 0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// ======================================================================================================
// Render a simple quad (rest is done by shader)
// ======================================================================================================
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 1.0f);
glVertex2i(0, vp_h);
glTexCoord2f(1.0f, 1.0f);
glVertex2i(vp_w, vp_h);
glTexCoord2f(1.0f, 0.0f);
glVertex2i(vp_w, 0);
glTexCoord2f(0.0f, 0.0f);
glVertex2i(0, 0);
glEnd();
pProgram_->disable();
glBindTexture(GL_TEXTURE_2D, 0);
// ======================================================================================================
// Cleanup (color and depth textures)
// ======================================================================================================
pDepthStencilTexture_.del();
pColorTexture_.del();
// ======================================================================================================
// Compute the header required for the display
// ======================================================================================================
uchar *header = new uchar[6];
// Header ID
// Basic identifier used by the display to verify the header
header[0] = 241; // Header_ID1 = 11110001
// Header content type
// This entry controls the displays internal rendering based on the input data specified here.
// There is no info about how this changes the rendering
// Possible values:
// 0 No Depth
// 1 Signage
// 2 Movie
// 3 Game
// 4 CGI
// 5 Still
header[1] = OpenFlipperSettings().value("Core/Stereo/Philips/Content").toInt(); // Hdr_Content_type (Game) = 00000011 (Gaming Mode)
// Header Factor
// Each 3D Display has a 'Display recommended depth value', which corresponds to an
// acceptable maximum depth factor value for that specific type of display. This value strongly
// depends on the lens design. The factor field in the header contains the percentage to be
// used from the display recommended depth value. The value of 64 corresponds with the 100%
// of the display recommended depth value. It is allowed to use values higher than 64. The factor
// works on a linear scale and is multiplied with the factor controlled by the user in the Display
// Control Tool.
// Value range: 0-255 (default 64)
header[2] = OpenFlipperSettings().value("Core/Stereo/Philips/Factor").toInt(); // Hdr_Factor
// Header Offset CC
// Values in the Depth map equal to the header-offset value will be located on the plane of the
// display. All values in the disparity map with a higher value will de displayed in front of the
// display.
// Offset_CC is the offset controlled by the Content Creator. In the system there is also an
// Offset_user present, which is controlled by the user using the Display Control Tool.
// Value Range: 0-255 (default 128)
header[3] = OpenFlipperSettings().value("Core/Stereo/Philips/Offset").toInt(); // Hdr_Offset_CC
// Header select
// When all select signals are low the rendering settings are set to optimal settings for the content
// type denoted by Hdr_content_type. By making select signals high the settings for Factor and
// Offset_cc can be controlled individually by the header.
// Possible Values:
// 0 Use Displays defaults and automatic optimizations
// 1 Use Header provided factor
// 2 Use Header provided offset
// 3 Use both factor and offset
header[4] = OpenFlipperSettings().value("Core/Stereo/Philips/Select").toInt(); // Hdr_Factor_select(1) + Hdr_Offset_select(1) + reserved(6)
// Unused Header entry (leave at 0 !)
header[5] = 0; // Reserved
// Header checksum.
// The 4-byte EDC field H(6) − H(9) contains an Error Detection Code computed over the first 6
// header bytes. This EDC uses the standard CRC-32 polynomial as defined in IEEE 802.3 and ITU-T
// V.42. The initial value and final XOR value are both 0.
// unsigned long has 32bit = 4Byte
unsigned long checksum = CalcCRC32(&header[0], 6);
// Store the complete header in a bit vector
std::vector<uchar> bitVector;
// For all bytes of the header
for (int i = 0; i < 6; i++) {
// For each bit of a headers byte
for (int j = 7; j >= 0; --j) {
// Red and Green component have to be 0
bitVector.push_back(0);
bitVector.push_back(0);
// If bit is set, the full component will be set to one otherwise zero
// And the order of the bits has to be reversed!
if (header[i] & (1 << j)) {
bitVector.push_back(255);
} else {
bitVector.push_back(0);
}
// Only every second pixel is used for the header
// Skip every odd one by filling in 0 for RGB
bitVector.push_back(0);
bitVector.push_back(0);
bitVector.push_back(0);
}
}
// Append checksum to header.
// Reversed bit order!
for (int i = 31; i >= 0; i--) {
// Red and Green component have to be 0
bitVector.push_back(0);
bitVector.push_back(0);
if (checksum & (1 << i))
bitVector.push_back(255);
else
bitVector.push_back(0);
// Only every second pixel is used for the header
// Skip every odd one by filling in 0 for RGB
bitVector.push_back(0);
bitVector.push_back(0);
bitVector.push_back(0);
}
// Select the top left of the renderbuffer and
// write complete header into these bits
glRasterPos2i(0, glHeight() - 1);
glDrawPixels(bitVector.size() / 3, 1, GL_RGB, GL_UNSIGNED_BYTE, &bitVector[0]);
// ======================================================================================================
// Reset projection and modelview
// ======================================================================================================
glstate_->pop_projection_matrix();
glstate_->pop_modelview_matrix();
}
//-----------------------------------------------------------------------------
void
glViewer::updateColorTextureBuffer() {
if ( !ACG::checkExtensionSupported("GL_ARB_texture_rectangle") ) {
std::cerr << "GL_ARB_texture_rectangle not supported! " << std::endl;
return;
}
int vp_l, vp_b, vp_w, vp_h;
glstate_->get_viewport (vp_l, vp_b, vp_w, vp_h);
// Does color texture exist?
if (!pColorTexture_.is_valid()) {
// ======================================================================================================
// creating a color texture
// ======================================================================================================
pColorTexture_.enable();
pColorTexture_.bind();
GLenum texTarget = GL_TEXTURE_2D;
GLenum texInternalFormat = GL_RGBA;
GLenum texFormat = GL_RGBA;
GLenum texType = GL_UNSIGNED_BYTE;
GLenum texFilterMode = GL_NEAREST;
glTexImage2D(texTarget, 0, texInternalFormat, vp_w, vp_h, 0, texFormat, texType, NULL);
glTexParameterf(texTarget, GL_TEXTURE_MIN_FILTER, texFilterMode);
glTexParameterf(texTarget, GL_TEXTURE_MAG_FILTER, texFilterMode);
glTexParameterf(texTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameterf(texTarget, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(texTarget, GL_TEXTURE_COMPARE_FUNC_ARB, GL_LEQUAL);
if(!pColorTexture_.is_valid()) {
philipsStereoInitialized_ = false;
}
}
// Resize target textures
if (glstate_->viewport_width() != colorTextureBufferWidth_ || glstate_->viewport_height() != colorTextureBufferHeight_) {
// Color texture
pColorTexture_.bind();
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGB, glstate_->viewport_width(), glstate_->viewport_height(), 0,
GL_RGB, GL_UNSIGNED_BYTE, 0);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 0);
colorTextureBufferWidth_ = glstate_->viewport_width();
colorTextureBufferHeight_ = glstate_->viewport_height();
}
}
//-----------------------------------------------------------------------------
void
glViewer::updateDepthStencilTextureBuffer() {
if ( !ACG::checkExtensionSupported("GL_ARB_texture_rectangle") ) {
std::cerr << "GL_ARB_texture_rectangle not supported! " << std::endl;
return;
}
int vp_l, vp_b, vp_w, vp_h;
glstate_->get_viewport (vp_l, vp_b, vp_w, vp_h);