Commit 44cb1e84 authored by IOhannes m zmölnig's avatar IOhannes m zmölnig
Browse files

make libGLU somewhat optional

parent 3779aace
......@@ -164,6 +164,7 @@ GEM_CHECK_WERROR
GEM_CPPFLAGS=""
GEM_CHECK_EXTERNAL
AC_ARG_WITH([GLU], AC_HELP_STRING([--without-GLU], [force building without GLU (*not* recommended!)]))
GEM_ARG_ENABLE([mmx], [MMX-support])
dnl disabled SSE2 by default, since there are still few chips around that fully support it
dnl unlike MMX or SSE
......@@ -250,11 +251,18 @@ AS_IF([test "x$with_x" != "xno"], [
])
IEM_CHECK_GL
no_glu=yes
IEM_CHECK_GLU
AM_CONDITIONAL(HAVE_GLU, [test "x${no_glu}" != "xyes"])
IEM_CHECK_GLUT
IEM_CHECK_GLX
IEM_CHECK_AGL
AS_IF([test "x$no_glu" != "xyes"],
AC_DEFINE([GEM_HAVE_GLU], [1], [whether we can use libGLU (normally: yes)])
)
## use system's libGLEW
GEM_ARG_ENABLE([multicontext], [experimental support for multiple windows])
## glewmx-args default to glew-args
......
......@@ -32,11 +32,19 @@
# define GLEW_MX
#endif
#ifndef GEM_HAVE_GLU
# define GLEW_NO_GLU
#else
#endif
#ifdef __EMSCRIPTEN__
# include <GL/glew.h>
# include <SDL/SDL_opengl.h>
# include <GL/gl.h>
# include <GL/glu.h>
# ifdef GEM_HAVE_GLU
# include <GL/glu.h>
# endif
#else
# include "Gem/glew.h"
#endif
......
......@@ -356,7 +356,7 @@ void GemMan :: resetValues()
// TODO:
// shouldn't this be called here?
// glLoadIdentity();
gluLookAt(m_lookat[0], m_lookat[1], m_lookat[2], m_lookat[3], m_lookat[4],
gem::utils::gl::gluLookAt(m_lookat[0], m_lookat[1], m_lookat[2], m_lookat[3], m_lookat[4],
m_lookat[5], m_lookat[6], m_lookat[7], m_lookat[8]);
if (m_fogMode == FOG_OFF) {
......@@ -622,7 +622,7 @@ void GemMan :: render(void *)
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(m_lookat[0] - m_stereoSep / 100.f, m_lookat[1], m_lookat[2],
gem::utils::gl::gluLookAt(m_lookat[0] - m_stereoSep / 100.f, m_lookat[1], m_lookat[2],
m_lookat[3], m_lookat[4],
m_lookat[5] + m_stereoFocal, m_lookat[6], m_lookat[7], m_lookat[8]);
......@@ -633,7 +633,7 @@ void GemMan :: render(void *)
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(0 - m_stereoSep / 100.f, 0, 4, 0, 0, 0 + m_stereoFocal, 0, 1, 0);
gem::utils::gl::gluLookAt(0 - m_stereoSep / 100.f, 0, 4, 0, 0, 0 + m_stereoFocal, 0, 1, 0);
renderChain(chain2, &currentState);
// setup the right viewpoint
......@@ -650,7 +650,7 @@ void GemMan :: render(void *)
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(m_lookat[0] + m_stereoSep / 100.f, m_lookat[1], m_lookat[2],
gem::utils::gl::gluLookAt(m_lookat[0] + m_stereoSep / 100.f, m_lookat[1], m_lookat[2],
m_lookat[3], m_lookat[4],
m_lookat[5] + m_stereoFocal, m_lookat[6], m_lookat[7], m_lookat[8]);
......@@ -662,7 +662,7 @@ void GemMan :: render(void *)
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(0 + m_stereoSep / 100.f, 0, 4, 0, 0, 0 + m_stereoFocal, 0, 1, 0);
gem::utils::gl::gluLookAt(0 + m_stereoSep / 100.f, 0, 4, 0, 0, 0 + m_stereoFocal, 0, 1, 0);
renderChain(chain2, &currentState);
......@@ -678,7 +678,7 @@ void GemMan :: render(void *)
glFrustum(-1, 1, -1, 1, 1, 20);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(0, 0, 4, 0, 0, 0, 0, 1, 0);
gem::utils::gl::gluLookAt(0, 0, 4, 0, 0, 0, 0, 1, 0);
glLineWidth(2.f);
glColor3f(1.f, 1.f, 1.f);
......@@ -718,7 +718,7 @@ void GemMan :: render(void *)
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(m_lookat[0] - m_stereoSep / 100.f, m_lookat[1], m_lookat[2],
gem::utils::gl::gluLookAt(m_lookat[0] - m_stereoSep / 100.f, m_lookat[1], m_lookat[2],
m_lookat[3], m_lookat[4],
m_lookat[5] + m_stereoFocal, m_lookat[6], m_lookat[7], m_lookat[8]);
......@@ -727,7 +727,7 @@ void GemMan :: render(void *)
renderChain(chain1, &currentState);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(0 - m_stereoSep / 100.f, 0, 4, 0, 0, 0 + m_stereoFocal, 0, 1, 0);
gem::utils::gl::gluLookAt(0 - m_stereoSep / 100.f, 0, 4, 0, 0, 0 + m_stereoFocal, 0, 1, 0);
renderChain(chain2, &currentState);
// setup the right viewpoint
......@@ -746,7 +746,7 @@ void GemMan :: render(void *)
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(m_lookat[0] + m_stereoSep / 100.f, m_lookat[1], m_lookat[2],
gem::utils::gl::gluLookAt(m_lookat[0] + m_stereoSep / 100.f, m_lookat[1], m_lookat[2],
m_lookat[3], m_lookat[4],
m_lookat[5] + m_stereoFocal, m_lookat[6], m_lookat[7], m_lookat[8]);
......@@ -758,7 +758,7 @@ void GemMan :: render(void *)
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(0 + m_stereoSep / 100.f, 0, 4, 0, 0, 0 + m_stereoFocal, 0, 1, 0);
gem::utils::gl::gluLookAt(0 + m_stereoSep / 100.f, 0, 4, 0, 0, 0 + m_stereoFocal, 0, 1, 0);
renderChain(chain2, &currentState);
glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE);
......@@ -784,7 +784,7 @@ void GemMan :: render(void *)
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
gluLookAt(m_lookat[0] - m_stereoSep / 100.f, m_lookat[1], m_lookat[2],
gem::utils::gl::gluLookAt(m_lookat[0] - m_stereoSep / 100.f, m_lookat[1], m_lookat[2],
m_lookat[3], m_lookat[4],
m_lookat[5] + m_stereoFocal, m_lookat[6], m_lookat[7], m_lookat[8]);
......@@ -793,7 +793,7 @@ void GemMan :: render(void *)
renderChain(chain1, &currentState);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(0 - m_stereoSep / 100.f, 0, 4, 0, 0, 0 + m_stereoFocal, 0, 1, 0);
gem::utils::gl::gluLookAt(0 - m_stereoSep / 100.f, 0, 4, 0, 0, 0 + m_stereoFocal, 0, 1, 0);
renderChain(chain2, &currentState);
// setup the right viewpoint
......@@ -812,7 +812,7 @@ void GemMan :: render(void *)
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
gluLookAt(m_lookat[0] + m_stereoSep / 100.f, m_lookat[1], m_lookat[2],
gem::utils::gl::gluLookAt(m_lookat[0] + m_stereoSep / 100.f, m_lookat[1], m_lookat[2],
m_lookat[3], m_lookat[4],
m_lookat[5] + m_stereoFocal, m_lookat[6], m_lookat[7], m_lookat[8]);
......@@ -824,7 +824,7 @@ void GemMan :: render(void *)
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(0 + m_stereoSep / 100.f, 0, 4, 0, 0, 0 + m_stereoFocal, 0, 1, 0);
gem::utils::gl::gluLookAt(0 + m_stereoSep / 100.f, 0, 4, 0, 0, 0 + m_stereoFocal, 0, 1, 0);
renderChain(chain2, &currentState);
glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE);
......@@ -837,7 +837,7 @@ void GemMan :: render(void *)
// setup the matrices
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(0, 0, 4, 0, 0, 0, 0, 1, 0);
gem::utils::gl::gluLookAt(0, 0, 4, 0, 0, 0, 0, 1, 0);
renderChain(chain2, &currentState);
}
}
......@@ -1223,7 +1223,7 @@ void GemMan :: swapBuffers()
// TODO:
// shouldn't this be called here?
// glLoadIdentity();
gluLookAt(m_lookat[0], m_lookat[1], m_lookat[2], m_lookat[3], m_lookat[4],
gem::utils::gl::gluLookAt(m_lookat[0], m_lookat[1], m_lookat[2], m_lookat[3], m_lookat[4],
m_lookat[5], m_lookat[6], m_lookat[7], m_lookat[8]);
}
#endif /* GEM_MULTICONTEXT */
......
......@@ -48,6 +48,7 @@ void light :: renderDebug()
{
const GLfloat size=0.2f;
if (m_debug) {
#ifdef GEM_HAVE_GLU
glPushMatrix();
glDisable(GL_LIGHTING);
glColor3fv(m_color);
......@@ -55,6 +56,7 @@ void light :: renderDebug()
gluSphere(m_thing, size, 10, 10);
glEnable(GL_LIGHTING);
glPopMatrix();
#endif
}
}
......
......@@ -98,12 +98,14 @@ void spot_light :: lightParamMess(float linAtt, float cutoff,
void spot_light :: renderDebug()
{
if (m_debug) { // display source
#ifdef GEM_HAVE_GLU
glPushMatrix();
glDisable(GL_LIGHTING);
glColor3fv(m_color);
gluCylinder(m_thing, 0.2f, 0, 0.4f, 10, 10);
glEnable(GL_LIGHTING);
glPopMatrix();
#endif
}
}
void spot_light :: render(GemState *state)
......
......@@ -29,7 +29,10 @@ CPPEXTERN_NEW_WITH_ONE_ARG(world_light, t_floatarg, A_DEFFLOAT);
//
/////////////////////////////////////////////////////////
world_light :: world_light(t_floatarg lightNum)
: m_debug(0), m_thing(NULL)
: m_debug(0)
#ifdef GEM_HAVE_GLU
, m_thing(NULL)
#endif
{
m_color[0] = m_color[1] = m_color[2] = m_color[3] = 1.0;
......@@ -87,6 +90,9 @@ void world_light :: lightOnOffMess(int state)
////////////////////////////////////////////////////////
void world_light :: debugMess(int state)
{
#ifndef GEM_HAVE_GLU
error("Gem has been compiled without GLU - disabled light debugging");
#endif
m_debug = state;
m_change = 1;
setModified();
......@@ -133,12 +139,14 @@ void world_light :: lightColorMess(t_symbol*s, int argc, t_atom*argv)
////////////////////////////////////////////////////////
void world_light :: startRendering()
{
#ifdef GEM_HAVE_GLU
if (m_thing) {
stopRendering();
}
m_thing = gluNewQuadric();
gluQuadricTexture(m_thing, GL_FALSE);
gluQuadricDrawStyle(m_thing, static_cast<GLenum>(GLU_FILL));
#endif
m_change = 1;
}
......@@ -148,10 +156,12 @@ void world_light :: startRendering()
////////////////////////////////////////////////////////
void world_light :: stopRendering()
{
#ifdef GEM_HAVE_GLU
if (m_thing) {
gluDeleteQuadric(m_thing);
}
m_thing = NULL;
#endif
if (m_light) {
glDisable(m_light);
......@@ -167,6 +177,7 @@ void world_light :: renderDebug()
{
const GLfloat size=0.2f;
if (m_debug) {
#ifdef GEM_HAVE_GLU
glPushMatrix();
glDisable(GL_LIGHTING);
glColor3fv(m_color);
......@@ -174,6 +185,7 @@ void world_light :: renderDebug()
gluCylinder(m_thing, size, size, size * 2.f, 10, 10);
glEnable(GL_LIGHTING);
glPopMatrix();
#endif
}
}
......
......@@ -15,6 +15,7 @@
#ifndef _INCLUDE__GEM_NONGEOS_WORLD_LIGHT_H_
#define _INCLUDE__GEM_NONGEOS_WORLD_LIGHT_H_
#include "Gem/GemConfig.h"
#include "Base/GemBase.h"
#include "Gem/GemGL.h"
......@@ -107,8 +108,10 @@ protected:
// The light number with reference to OpenGL
GLenum m_light;
#ifdef GEM_HAVE_GLU
//////////
GLUquadricObj *m_thing;
#endif
};
#endif // for header file
......@@ -15,6 +15,7 @@
//
/////////////////////////////////////////////////////////
#include "Gem/GemConfig.h"
#include "pix_resize.h"
#include "Gem/GemGL.h"
#include "Utils/Functions.h"
......@@ -55,19 +56,29 @@ void pix_resize :: processImage(imageStruct &image)
int hN = (m_height>0)?m_height:powerOfTwo(image.ysize);
if (wN != image.xsize || hN != image.ysize) {
GLint gluError;
m_image.xsize=wN;
m_image.ysize=hN;
m_image.setCsizeByFormat(image.format);
m_image.reallocate();
m_image.reallocate(
wN*hN*4); // just for safety: it seems like gluScaleImage needs more memory then just the x*y*c
// just for safety: it seems like gluScaleImage needs more memory then just the x*y*c
m_image.reallocate(wN*hN*4);
GLint gluError = 0;
#ifdef GEM_HAVE_GLU
gluError = gluScaleImage(image.format,
image.xsize, image.ysize,
image.type, image.data,
wN, hN,
image.type, m_image.data);
#else
static bool firsttime = true;
if(firsttime) {
firsttime = false;
error("Gem has been compiled without GLU - disabled pix resizing");
return;
}
#endif
if ( gluError ) {
post("gluError %d: unable to resize image", gluError);
return;
......
......@@ -15,6 +15,7 @@
//
/////////////////////////////////////////////////////////
#include "Gem/GemConfig.h"
#include "GLUtil.h"
#include <map>
#include "Gem/RTE.h"
......@@ -36,7 +37,12 @@ GLenum gem::utils::gl::glReportError (bool verbose)
{
GLenum err = glGetError();
if (verbose && GL_NO_ERROR != err) {
post("GL: %d %s",err,(char*)gluErrorString(err));
#ifdef GEM_HAVE_GLU
post("GL[%d]: %s", err, (char*)gluErrorString(err));
#else
post("GL: %d", err);
#endif
}
// ensure we are returning an OSStatus noErr if no error condition
if (err == GL_NO_ERROR) {
......
......@@ -9,6 +9,7 @@
// OF ALL WARRANTIES, see the file "GEM.LICENSE.TERMS"
//
#include "Gem/GemConfig.h"
#include "GEMgluLookAt.h"
#include "Gem/Exception.h"
......@@ -105,6 +106,9 @@ GEMgluLookAt :: ~GEMgluLookAt ()
//
void GEMgluLookAt :: render(GemState *state)
{
#ifndef GEM_HAVE_GLU
gem::utils::gl::
#endif
gluLookAt (m_eyeX, m_eyeY, m_eyeZ, m_centerX, m_centerY, m_centerZ, m_upX,
m_upY, m_upZ);
}
......
......@@ -54,6 +54,9 @@ GEMgluPerspective :: ~GEMgluPerspective ()
//
void GEMgluPerspective :: render(GemState *state)
{
#ifndef GEM_HAVE_GLU
gem::utils::gl::
#endif
gluPerspective (fovy, aspect, m_near, m_far);
}
......
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