Commit 44d5d903 authored by Jan Möbius's avatar Jan Möbius

Use shader to render for philips displays

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@7480 383ad7c9-94d9-4d36-a494-682f7c89f535
parent fc6bdbf5
......@@ -60,11 +60,14 @@
#include <QGLFramebufferObject>
#include <ACG/ShaderUtils/GLSLShader.hh>
//== NAMESPACES ===============================================================
//== IMPLEMENTATION ==========================================================
#include <qt4/QtCore/qdir.h>
static const char* customAnaglyphProg = {
"!!ARBfp1.0"
......@@ -161,55 +164,135 @@ glViewer::drawScenePhilipsStereo()
buffer->bind();
drawScene_mono();
// buffer->drawTexture(QRectF(0,0,1,1),buffer->texture());
QImage image = buffer->toImage();
image.save("test.jpg");
//
// // buffer->drawTexture(QRectF(0,0,1,1),buffer->texture());
// QImage image = buffer->toImage();
// image.save("test.jpg");
buffer->release();
// glBindTexture(GL_TEXTURE_2D, buffer->texture());
// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
// // glEnable(GL_TEXTURE_2D);
// glEnable(GL_BLEND);
// glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
// glDisable(GL_DEPTH_TEST);
GLSL::PtrVertexShader vertexShader;
GLSL::PtrFragmentShader fragmentShader;
GLSL::PtrProgram program;
QString vshaderFile = OpenFlipper::Options::shaderDirStr() + QDir::separator() + "Philips/Vertex.glsl";
QString fshaderFile = OpenFlipper::Options::shaderDirStr() + QDir::separator() + "Philips/Fragment.glsl";
////
vertexShader = GLSL::loadVertexShader( vshaderFile.toStdString().c_str() );
fragmentShader = GLSL::loadFragmentShader( fshaderFile.toStdString().c_str() );
program = GLSL::PtrProgram(new GLSL::Program());
if ( (vertexShader == 0) ||
(fragmentShader == 0) ||
(program == 0) ) {
std::cerr << "Unable to load shaders for philips display rendering!";
return;
}
program->attach(vertexShader);
program->attach(fragmentShader);
program->link();
program->use();
program->setUniform("Texture",0);
glBindTexture(GL_TEXTURE_2D, buffer->texture());
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDisable(GL_LIGHTING);
glDisable(GL_COLOR_MATERIAL);
glDisable(GL_DEPTH_TEST);
glstate_->push_projection_matrix();
glstate_->push_modelview_matrix();
glstate_->reset_projection();
glstate_->reset_modelview();
glstate_->ortho(0, 10, 0, 10, 0, 1);
glColor3f(1.0,1.0,1.0);
//Draw a scene
glClearColor(.0, .0, .0, 0);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glBegin(GL_POINTS);
glVertex2f( 2.5, 2.5);
glEnd();
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 1.0f); glVertex2f( 0, 10);
glTexCoord2f(1.0f, 1.0f); glVertex2f( 5, 10);
glTexCoord2f(1.0f, 0.0f); glVertex2f( 5, 0);
glTexCoord2f(0.0f, 0.0f); glVertex2f( 0, 0);
glEnd();
program->disable();
glBindTexture(GL_TEXTURE_2D, 0);
delete buffer;
//
// glColor3f(1.0,1.0,1.0);
//
// // draw into the GL widget
// glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// glMatrixMode(GL_PROJECTION);
// // glPushMatrix();
// glstate_->ortho(0,glstate_->viewport_width(),glstate_->viewport_height(),0,0,256);
// // glstate_->viewport(0,0,glstate_->viewport_width(),glstate_->viewport_height());
//
// glLoadIdentity();
// glOrtho(-1, 1, -1, 1, 10, 100);
//
// glstate_->reset_modelview();
//
// glDisable( GL_DEPTH_TEST );
// glDisable( GL_LIGHTING );
//
// glMatrixMode(GL_MODELVIEW);
// // glPushMatrix();
// glLoadIdentity();
// // glViewport(0, 0, glWidth(), glHeight());
//
// // draw into the GL widget
// glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
//
//
// glBegin(GL_POINTS);
// {
// glVertex2i( 55, 15);
//
// glVertex2i( 0, 15);
//
// glVertex2i( 1, 15);
//
// glVertex2i( 2, 15);
//
// glVertex2i( 0, 0 );
// }
// glEnd();
//
// glBegin(GL_QUADS);
// {
//
// glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 15.0f);
// glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 15.0f);
// glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 15.0f);
// glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 15.0f);
// glTexCoord2f(0.0f, 0.0f); glVertex2i( 0, 5);
// glTexCoord2f(1.0f, 0.0f); glVertex2i( 0, 0);
// glTexCoord2f(1.0f, 1.0f); glVertex2i( 5, 0);
// glTexCoord2f(0.0f, 1.0f); glVertex2i( 5, 5);
//
// }
// glEnd();
//
// glDisable(GL_TEXTURE_2D);
//
glstate_->pop_projection_matrix();
glstate_->pop_modelview_matrix();
//
// // glPopMatrix();
// glDisable(GL_TEXTURE_2D);
//
// glMatrixMode(GL_PROJECTION);
// glPopMatrix();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment