Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

switch openGL-loader to GLAD #339

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
14 changes: 14 additions & 0 deletions abstractions/gemwin.pd
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,14 @@
#X msg 59 124 buffer \$1;
#X msg 203 121 FSAA \$1;
#X obj 203 99 r \$0-FSAA;
#X obj 294 97 r \$0-sharedcontext;
#X msg 294 120 sharedcontext \$1;
#X connect 0 0 2 0;
#X connect 2 0 1 0;
#X connect 3 0 1 0;
#X connect 4 0 3 0;
#X connect 5 0 6 0;
#X connect 6 0 1 0;
#X restore 126 291 pd rendercontext;
#X obj 282 602 t b b;
#N canvas 6 61 450 300 gemman 0;
Expand Down Expand Up @@ -967,6 +971,15 @@
#X connect 13 0 14 0;
#X restore 118 301 pd render;
#X text 299 352 blur print profile frame fps;
#N canvas 329 517 450 300 sharedcontext 0;
#X obj 37 37 inlet;
#X obj 37 60 route sharedcontext;
#X obj 37 87 s \$0-sharedcontext;
#X obj 148 37 outlet;
#X connect 0 0 1 0;
#X connect 1 0 2 0;
#X connect 1 1 3 0;
#X restore 118 324 pd sharedcontext;
#X connect 0 0 2 0;
#X connect 1 0 3 0;
#X connect 2 0 4 0;
Expand All @@ -977,6 +990,7 @@
#X connect 7 0 8 0;
#X connect 8 0 14 0;
#X connect 14 0 15 0;
#X connect 15 0 17 0;
#X restore 126 127 pd callbacks;
#N canvas 524 589 450 333 resetValues 0;
#N canvas 252 532 377 366 viewpoint 0;
Expand Down
38 changes: 2 additions & 36 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ AC_CONFIG_FILES([Makefile abstractions/Makefile])
AC_CONFIG_FILES([help/Makefile doc/Makefile examples/Makefile])

# src
AC_CONFIG_FILES([src/Makefile src/Gem/Makefile src/Utils/Makefile])
AC_CONFIG_FILES([src/Makefile src/Gem/Makefile src/glad/Makefile src/Utils/Makefile])
AC_CONFIG_FILES([src/RTE/Makefile src/Base/Makefile src/plugins/Makefile ])
AC_CONFIG_FILES([src/Output/Makefile ])
AC_CONFIG_FILES([src/deprecated/Makefile ])
Expand Down Expand Up @@ -163,7 +163,6 @@ 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
Expand Down Expand Up @@ -250,43 +249,18 @@ AS_IF([test "x$with_x" != "xno"], [
])

IEM_CHECK_GL
no_glu=yes
AS_IF([test "x$with_GLU" != "xno"], [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
## use GLAD (shpiped with Gem)
GEM_ARG_ENABLE([multicontext], [experimental support for multiple windows])
## glewmx-args default to glew-args
AS_IF([test "x$with_glewmx" = "x"], [with_glewmx="$with_glew"])
AS_IF([test "x$with_glewmx-includes" = "x"], [with_glewmx-includes="$with_glew-includes"])
AS_IF([test "x$with_glewmx-libs" = "x"], [with_glewmx-libs="$with_glew-libs"])

GEM_CHECK_LIB([glew], [GLEW],[GL/glew.h], [glewInit],,,,[OpenGL Extension Wrangler library], [no])
GEM_CHECK_LIB([glewmx], [GLEWmx],[GL/glew.h], [glewInit],,,,[OpenGL Extension Wrangler library], [no])


AS_IF([test "x$enable_multicontext" = "xyes"], [
have_glew="${have_glewmx}"
GEM_LIB_GLEW_CFLAGS="$GEM_LIB_GLEWMX_CFLAGS"
GEM_LIB_GLEW_LIBS="$GEM_LIB_GLEWMX_LIBS"

AM_CONDITIONAL(HAVE_LIB_GLEW, [test "x${have_glew}" = "xyes"])
AC_DEFINE([GEM_MULTICONTEXT], [1], [whether Gem is built with multi-context support])
])
AM_CONDITIONAL(ENABLE_MULTICONTEXT, [test "x${enable_multicontext}" = "xyes"])

AS_IF([test "x${have_glew}" != "xyes"], [
AC_DEFINE([GLEW_BUILD], [1], [Define to 1 if using the built-in glew])
])

GEM_CHECK_LIB([sdl], [SDL],[SDL.h], [SDL_Quit],,,,[SDL windowing])
GEM_CHECK_LIB([sdl2], [SDL2],[SDL_log.h], [SDL_Quit],,,,[SDL2 windowing])

Expand Down Expand Up @@ -855,12 +829,4 @@ AS_IF([test "x$have_pd" = "xno"], [
AC_MSG_ERROR([Pd (header) is mandatory and seems to be missing!])
])

AS_IF([test "x$no_gl" = "xyes"], [
AC_MSG_ERROR([GL (headers) not found! you need openGL!!!])
])

AS_IF([test "x$no_glu" = "xyes" && test "x$no_agl" = "xyes"], [
AS_IF([test "x$with_GLU" != "xno"],[AC_MSG_ERROR([GLU (headers) not found! you need openGL Utility Library!!!])])
])

AC_MSG_RESULT([Now run make ...])
85 changes: 57 additions & 28 deletions examples/14.multiple_windows/03.texture_sharing.pd
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
#N canvas 224 736 1147 233 10;
#N canvas 983 248 1147 303 10;
#X declare -lib Gem;
#X obj 33 169 gemwin 20 a;
#X obj 396 181 square;
#X obj 141 26 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1
-1;
#X obj 141 26 bng 15 250 50 0 empty empty empty 17 7 0 10 #fcfcfc #000000 #000000;
#X obj 396 37 gemhead a;
#X text 158 24 1 create windows;
#X obj 396 104 pix_texture;
#X obj 596 181 square;
#X obj 596 155 pix_texture;
#X obj 396 72 pix_image ../data/fractal.JPG;
#X obj 596 59 translateXYZ 2 0 0;
Expand All @@ -16,30 +13,62 @@
#X msg 596 4 context a;
#X msg 669 4 context b;
#X msg 80 118 destroy;
#X text 731 150 on Linux \, this is only supported by [gemglutwindow].
;
#X text 730 98 support for texture sharing is limited by Operating
System \, ggraphics hardware \, openGL implementation and the windowing
backend.;
#X msg 33 87 title a \, create \, 1;
#X msg 168 117 title b \, create \, 1;
#X text 731 150 on Linux \, this is only supported by [gemglutwindow].;
#X text 730 98 support for texture sharing is limited by Operating System \, graphics hardware \, openGL implementation and the windowing backend.;
#X obj 1030 16 declare -lib Gem;
#X obj 141 46 t b b;
#X obj 80 141 t a a;
#X connect 2 0 20 0;
#X connect 3 0 8 0;
#X connect 5 0 1 0;
#X connect 5 1 7 1;
#X connect 7 0 6 0;
#X connect 8 0 5 0;
#X connect 9 0 7 0;
#X connect 10 0 9 0;
#X connect 12 0 10 0;
#X connect 13 0 10 0;
#X connect 14 0 21 0;
#X msg 168 117 title b \, offset 512 0 \, create \, 1;
#X msg 33 87 title a \, offset 0 0 \, create \, 1;
#N canvas 735 418 450 300 rotating_square 0;
#X obj 204 202 square;
#X obj 204 118 t a b;
#X obj 204 181 rotateXYZ;
#X obj 277 123 i;
#X obj 277 146 + 1;
#X obj 277 169 % 360;
#X obj 277 192 t f f;
#X obj 88 53 inlet;
#X obj 88 76 t a a;
#X obj 204 97 separator;
#X obj 88 99 outlet;
#X obj 349 56 inlet;
#X connect 1 0 2 0;
#X connect 1 1 3 0;
#X connect 2 0 0 0;
#X connect 3 0 4 0;
#X connect 4 0 5 0;
#X connect 5 0 6 0;
#X connect 6 0 2 3;
#X connect 6 0 2 2;
#X connect 6 0 2 1;
#X connect 6 1 3 1;
#X connect 7 0 8 0;
#X connect 8 0 10 0;
#X connect 8 1 9 0;
#X connect 9 0 1 0;
#X connect 11 0 4 1;
#X restore 396 181 pd rotating_square;
#X obj 512 181 tgl 18 0 empty empty empty 0 -9 0 10 #fcfcfc #000000 #000000 0 1;
#X obj 215 199 loadbang;
#X msg 215 222 sharedcontext 1;
#X connect 1 0 16 0;
#X connect 2 0 6 0;
#X connect 4 0 20 0;
#X connect 4 1 5 1;
#X connect 5 0 20 0;
#X connect 6 0 4 0;
#X connect 7 0 5 0;
#X connect 8 0 7 0;
#X connect 10 0 8 0;
#X connect 11 0 8 0;
#X connect 12 0 17 0;
#X connect 16 0 19 0;
#X connect 16 1 18 0;
#X connect 17 0 0 0;
#X connect 18 0 11 0;
#X connect 20 0 17 0;
#X connect 20 1 18 0;
#X connect 21 0 0 0;
#X connect 21 1 11 0;
#X connect 17 1 9 0;
#X connect 18 0 9 0;
#X connect 19 0 0 0;
#X connect 21 0 20 1;
#X connect 22 0 23 0;
#X connect 23 0 17 0;
54 changes: 34 additions & 20 deletions src/Base/GemWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include "RTE/MessageCallbacks.h"

#include "Gem/Settings.h"
#include "GemContext.h"
#include "Gem/Context.h"
#include "Gem/Exception.h"
#include "GemBase.h"

Expand Down Expand Up @@ -84,8 +84,8 @@ class GemWindow::PIMPL
double dispatchTime;
void dispatch(void)
{
parent->dispatch();
clock_delay(dispatchClock, dispatchTime);
parent->dispatch();
}
static void dispatchCallBack(PIMPL*x)
{
Expand Down Expand Up @@ -243,7 +243,12 @@ void GemWindow :: info(const std::string& s, const std::string& value)

void GemWindow :: bang(void)
{
outlet_bang(m_pimpl->infoOut);
if(pushContext()) {
outlet_bang(m_pimpl->infoOut);
popContext();
} else {
error("unable to switch to current context, cannot render!");
}
}


Expand Down Expand Up @@ -379,8 +384,10 @@ void GemWindow::stopInAllContexts(GemBase*obj)
++it) {
GemWindow*w=(*it);
w->makeCurrent();
w->pushContext();
t_pd*x=&obj->x_obj->ob_pd;
sendContextDestroyedMsg(x);
w->popContext();
}
}

Expand Down Expand Up @@ -411,7 +418,9 @@ bool GemWindow::createGemWindow(void)
void GemWindow::destroyGemWindow(void)
{
// tell all objects that this context is vanishing
pushContext();
sendContextDestroyedMsg(gensym("__gemBase")->s_thing);
popContext();
// do the rest
m_pimpl->mycontext=destroyContext(m_pimpl->mycontext);
m_pimpl->undispatch();
Expand All @@ -420,16 +429,7 @@ void GemWindow::destroyGemWindow(void)

bool GemWindow::pushContext(void)
{
if(!m_context) {
return false;
}

if(!m_context->push()) {
return false;
}

dispatch();
return true;
return (m_context && m_context->push());
}
bool GemWindow::popContext(void)
{
Expand All @@ -442,16 +442,25 @@ void GemWindow::render(void)
error("unable to switch to current window (do you have one?), cannot render!");
return;
}
if(!pushContext()) {
error("unable to switch to current context, cannot render!");

if(pushContext()) {
dispatch();
popContext();
} else {
error("unable to switch to current context, cannot dispatch!");
return;
}

bang();
if(m_buffer==2) {
swapBuffers();
}

popContext();
if(2 == m_buffer) {
if (pushContext()) {
swapBuffers();
popContext();
} else {
error("unable to switch to current context, cannot swapBuffers!");
}
}
}

void GemWindow:: bufferMess(int buf)
Expand Down Expand Up @@ -522,7 +531,6 @@ void GemWindow:: printMess(void)
post("\tVendor: %s", glGetString(GL_VENDOR));
post("\tRenderer: %s", glGetString(GL_RENDERER));
post("\tVersion: %s", glGetString(GL_VERSION));
post("\tGLEW: %s", glewGetString(GLEW_VERSION));

std::string extensions = (char*)glGetString(GL_EXTENSIONS);
std::string ext;
Expand All @@ -533,6 +541,11 @@ void GemWindow:: printMess(void)
}
}

void GemWindow::sharedcontextMess(bool on)
{
m_context_sharing=on;
}

void GemWindow:: anyMess(t_symbol*s, int argc, t_atom*argv)
{
outlet_anything(m_pimpl->rejectOut, s, argc, argv);
Expand All @@ -555,6 +568,7 @@ void GemWindow :: obj_setupCallback(t_class *classPtr)
CPPEXTERN_MSG1(classPtr, "border", borderMess, bool);
CPPEXTERN_MSG1(classPtr, "cursor", cursorMess, bool);
CPPEXTERN_MSG1(classPtr, "transparent", transparentMess, bool);
CPPEXTERN_MSG1(classPtr, "sharedcontext", sharedcontextMess, bool);

CPPEXTERN_MSG0(classPtr, "print", printMess);

Expand Down
4 changes: 4 additions & 0 deletions src/Base/GemWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,9 @@ class GEM_EXTERN GemWindow : public CPPExtern
/* print some info */
virtual void printMess(void);

/* print some info */
virtual void sharedcontextMess(bool);

/* fallback callback */
virtual void anyMess(t_symbol*s, int argc, t_atom*argv);

Expand All @@ -213,6 +216,7 @@ class GEM_EXTERN GemWindow : public CPPExtern
bool m_cursor;
bool m_transparent;
int m_fsaa;
bool m_context_sharing;

gem::Context* m_context;
};
Expand Down
4 changes: 1 addition & 3 deletions src/Base/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,14 @@ libBase_la_include_HEADERS= \

libBase_la_include_HEADERS+= \
GemWindow.h \
GemContext.h
$(empty)

libBase_la_SOURCES= \
CPPExtern.cpp \
CPPExtern.h \
GemBase.cpp \
GemBase.h \
GemGLBase.h \
GemContext.cpp \
GemContext.h \
GemGluObj.cpp \
GemGluObj.h \
GemPathBase.cpp \
Expand Down
2 changes: 0 additions & 2 deletions src/Controls/gemcubeframebuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,6 @@ bool gemcubeframebuffer :: isRunnable()
m_canRectangle=GL_TEXTURE_2D;
if(GLEW_ARB_texture_rectangle) {
m_canRectangle=GL_TEXTURE_RECTANGLE_ARB;
} else if (GLEW_EXT_texture_rectangle) {
m_canRectangle=GL_TEXTURE_RECTANGLE_EXT;
}

return true;
Expand Down
Loading