Commit ad038f73 authored by Jan Möbius's avatar Jan Möbius
Browse files

Get rid of glew on apple at least in the code, todo remove linking stuff for glew on apple

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@11000 383ad7c9-94d9-4d36-a494-682f7c89f535
parent af6df5c9
......@@ -33,8 +33,9 @@ void
FBO::
init()
{
// Create framebuffer object
if ( !GLEW_EXT_framebuffer_object )
if ( ! checkExtensionSupported("GL_EXT_framebuffer_object") )
{
std::cout << "Framebuffer object not supported! " << std::endl;
exit( 1 );
......
......@@ -57,7 +57,6 @@
#if defined(ARCH_DARWIN)
#include <GL/glew.h>
#include <glut.h>
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
......@@ -255,6 +254,14 @@ inline void glTexCoordPointer(GLint n, GLenum t, GLsizei s, const GLvoid *p)
//-----------------------------------------------------------------------------
/** Check if the extension given by a std::string is supported by the current OpenGL extension
*/
inline bool checkExtensionSupported( std::string _extension ) {
std::string supported((const char*)glGetString(GL_EXTENSIONS));
return (supported.find(_extension) != std::string::npos);
}
/** Nice wrapper that outputs all current OpenGL errors to std::cerr.
If no error is present nothing is printed.
......
......@@ -1136,7 +1136,9 @@ void QtBaseViewer::initializeGL()
{
// we use GLEW to manage extensions
// initialize it first
#ifndef __APPLE__
glewInit();
#endif
// lock update
......@@ -1248,7 +1250,9 @@ void QtBaseViewer::paintGL()
{
// we use GLEW to manage extensions
// initialize it first
#ifndef __APPLE__
glewInit();
#endif
// lock update
lockUpdate();
......
......@@ -99,9 +99,9 @@ MeshNodeT(Mesh& _mesh,
perFaceTextureCoordsAvailable_(false),
textureMap_(0)
{
/// \todo : Handle vbo not supported
if ( ! GLEW_ARB_vertex_buffer_object ) {
if ( ! checkExtensionSupported("GL_ARB_vertex_buffer_object") ) {
std::cerr << "Error! Vertex buffer objects are not supported! The meshNode will not work without them!" << std::endl;
}
......
......@@ -289,13 +289,6 @@ setShader( DrawModes::DrawMode _drawmode ,
std::string _pickVertexShader,
std::string _pickFragmentShader) {
// OpenGl 2.0 is needed for GLSL support
if (!glewIsSupported("GL_VERSION_2_0")) {
std::cerr << "No shader support on this machine. Unable to load shaders!" << std::endl;
return;
}
if ( shaderDir_ == "" ) {
std::cerr << "No shader dir set for shadernode. Unable to load shaders!" << std::endl;
return;
......
......@@ -334,13 +334,13 @@ namespace GLSL {
}
int Program::getAttributeLocation(const char *name) {
int attributeLocation = glGetAttribLocationARB(this->m_programId, name);
int attributeLocation = glGetAttribLocation(this->m_programId, name);
checkGLError2(name);
return attributeLocation;
}
int Program::getUniformLocation(const char *name) {
int attributeLocation = glGetUniformLocationARB(this->m_programId, name);
int attributeLocation = glGetUniformLocation(this->m_programId, name);
checkGLError2(name);
return attributeLocation;
}
......
......@@ -1655,6 +1655,7 @@ bool Core::checkOpenGLCapabilities() {
missing += tr("Your graphics card does not support the GL_ARB_vertex_buffer_object extension!\n");
}
if ( !ok ) {
QString message = tr("Error! \nThe OpenGL capabilities of your current machine/driver are not sufficient!\n\n");
message += tr("The following checks failed:\n\n");
......
......@@ -419,13 +419,14 @@ int main(int argc, char **argv)
// After setting all Options from command line, build the real gui
w->init();
#ifndef __APPLE__
GLenum err = glewInit();
if (GLEW_OK != err)
{
/* Problem: glewInit failed, something is seriously wrong. */
fprintf(stderr, "Error: %s\n", glewGetErrorString(err));
}
#endif
for ( int i = 0 ; i < args.FileCount(); ++i )
w->commandLineOpen(args.File(i), openPolyMeshes);
......
......@@ -464,6 +464,7 @@ void CoreWidget::showAboutWidget( ) {
// =====================================================================================
// glew Information
// =====================================================================================
#ifndef __APPLE__
aboutWidget_->OpenFlipperAbout->append("\n");
aboutWidget_->OpenFlipperAbout->setCurrentFont(boldFont);
aboutWidget_->OpenFlipperAbout->append(tr("GLEW Specific Info:"));
......@@ -471,6 +472,7 @@ void CoreWidget::showAboutWidget( ) {
QString glewVersion = QString((const char *)glewGetString(GLEW_VERSION));
aboutWidget_->OpenFlipperAbout->append(tr("GLEW Version:\t") + glewVersion);
#endif
// =====================================================================================
// Qt information
......
......@@ -1144,10 +1144,10 @@ void glViewer::initializeGL()
// unlock update (we started locked)
properties_.unLockUpdate();
customAnaglyphSupported_ = glewIsSupported("GL_ARB_fragment_program") &&
(glewIsSupported("GL_ARB_texture_rectangle") ||
glewIsSupported("GL_EXT_texture_rectangle") ||
glewIsSupported("GL_NV_texture_rectangle"));
customAnaglyphSupported_ = ACG::checkExtensionSupported("GL_ARB_fragment_program") &&
(ACG::checkExtensionSupported("GL_ARB_texture_rectangle") ||
ACG::checkExtensionSupported("GL_EXT_texture_rectangle") ||
ACG::checkExtensionSupported("GL_NV_texture_rectangle"));
initialized_ = true;
......
......@@ -396,6 +396,11 @@ void glViewer::drawScenePhilipsStereo() {
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);
......@@ -430,10 +435,10 @@ glViewer::updateColorTextureBuffer() {
// Color texture
pColorTexture_.bind();
glTexImage2D(GL_TEXTURE_RECTANGLE_NV, 0, GL_RGB, glstate_->viewport_width(), glstate_->viewport_height(), 0,
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_NV, 0);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 0);
colorTextureBufferWidth_ = glstate_->viewport_width();
colorTextureBufferHeight_ = glstate_->viewport_height();
......@@ -445,6 +450,11 @@ glViewer::updateColorTextureBuffer() {
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);
......@@ -481,10 +491,10 @@ glViewer::updateDepthStencilTextureBuffer() {
// Depth stencil texture
pDepthStencilTexture_.bind();
glTexImage2D(GL_TEXTURE_RECTANGLE_NV, 0, GL_RGB, glstate_->viewport_width(), glstate_->viewport_height(), 0,
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_NV, 0);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 0);
depthStencilTextureBufferWidth_ = glstate_->viewport_width();
depthStencilTextureBufferHeight_ = glstate_->viewport_height();
......@@ -600,6 +610,12 @@ glViewer::updateCustomAnaglyphStereo()
if (!customAnaglyphSupported_)
return;
if ( !ACG::checkExtensionSupported("GL_ARB_texture_rectangle") ) {
std::cerr << "GL_ARB_texture_rectangle not supported! " << std::endl;
customAnaglyphSupported_ = false;
return;
}
if (!agProgram_)
{
GLint errorPos;
......@@ -634,13 +650,13 @@ glViewer::updateCustomAnaglyphStereo()
if (glstate_->viewport_width () != agTexWidth_ ||
glstate_->viewport_height () != agTexHeight_)
{
glBindTexture (GL_TEXTURE_RECTANGLE_NV, agTexture_[0]);
glTexImage2D (GL_TEXTURE_RECTANGLE_NV, 0, GL_RGB, glstate_->viewport_width (),
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, agTexture_[0]);
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_NV, agTexture_[1]);
glTexImage2D (GL_TEXTURE_RECTANGLE_NV, 0, GL_RGB, glstate_->viewport_width (),
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, agTexture_[1]);
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_NV, 0);
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, 0);
agTexWidth_ = glstate_->viewport_width ();
agTexHeight_ = glstate_->viewport_height ();
......@@ -709,9 +725,9 @@ glViewer::drawScene_customAnaglyphStereo()
glClear(GL_DEPTH_BUFFER_BIT);
drawScene_mono();
glBindTexture (GL_TEXTURE_RECTANGLE_NV, agTexture_[0]);
glCopyTexSubImage2D (GL_TEXTURE_RECTANGLE_NV, 0, 0, 0, vp_l, vp_b, vp_w, vp_h);
glBindTexture (GL_TEXTURE_RECTANGLE_NV, 0);
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, agTexture_[0]);
glCopyTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, vp_l, vp_b, vp_w, vp_h);
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, 0);
// right eye
glMatrixMode(GL_PROJECTION);
......@@ -723,17 +739,17 @@ glViewer::drawScene_customAnaglyphStereo()
glClear(GL_DEPTH_BUFFER_BIT);
drawScene_mono();
glBindTexture (GL_TEXTURE_RECTANGLE_NV, agTexture_[1]);
glCopyTexSubImage2D (GL_TEXTURE_RECTANGLE_NV, 0, 0, 0, vp_l, vp_b, vp_w, vp_h);
glBindTexture (GL_TEXTURE_RECTANGLE_NV, 0);
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, agTexture_[1]);
glCopyTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, vp_l, vp_b, vp_w, vp_h);
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, 0);
glActiveTexture (GL_TEXTURE0);
glBindTexture (GL_TEXTURE_RECTANGLE_NV, agTexture_[0]);
glEnable (GL_TEXTURE_RECTANGLE_NV);
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, agTexture_[0]);
glEnable (GL_TEXTURE_RECTANGLE_ARB);
glActiveTexture (GL_TEXTURE1);
glBindTexture (GL_TEXTURE_RECTANGLE_NV, agTexture_[1]);
glEnable (GL_TEXTURE_RECTANGLE_NV);
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, agTexture_[1]);
glEnable (GL_TEXTURE_RECTANGLE_ARB);
glEnable (GL_FRAGMENT_PROGRAM_ARB);
glBindProgramARB (GL_FRAGMENT_PROGRAM_ARB, agProgram_);
......@@ -775,12 +791,12 @@ glViewer::drawScene_customAnaglyphStereo()
glDisable (GL_FRAGMENT_PROGRAM_ARB);
glActiveTexture (GL_TEXTURE1);
glBindTexture (GL_TEXTURE_RECTANGLE_NV, 0);
glDisable (GL_TEXTURE_RECTANGLE_NV);
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, 0);
glDisable (GL_TEXTURE_RECTANGLE_ARB);
glActiveTexture (GL_TEXTURE0);
glBindTexture (GL_TEXTURE_RECTANGLE_NV, 0);
glDisable (GL_TEXTURE_RECTANGLE_NV);
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, 0);
glDisable (GL_TEXTURE_RECTANGLE_ARB);
}
......
......@@ -106,7 +106,9 @@ void QtGLGraphicsScene::drawBackground(QPainter *_painter, const QRectF &_rect)
{
// we use GLEW to manage extensions
// initialize it first
#ifndef __APPLE__
glewInit();
#endif
for (unsigned int i = 0; i < views_->size (); i++)
{
views_->at(i)->initializeGL ();
......
......@@ -110,7 +110,9 @@ void SimpleGLGraphicsScene::drawBackground(QPainter *_painter, const QRectF &_re
{
// we use GLEW to manage extensions
// initialize it first
#ifndef __APPLE__
glewInit();
#endif
view_->initializeGL();
cursorPainter_->initializeGL ();
initialized_ = true;
......
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