Commit 662ad087 authored by Ivica Bukvic's avatar Ivica Bukvic
Browse files

updated gem2pdp to be in sync with pd-extended

parent 54a8ec88
......@@ -12,7 +12,7 @@ GEM2PDP_DISTRO = /mnt/c/ydegoyon.free.fr/gem2pdp-$(GEM2PDP_VERSION)
GEM2PDP_TARBALL = $(GEM2PDP_DISTRO).tar.gz
# build flags
INCLUDES = @INCLUDES@ -I$(PD_DIR)/src -I. -I$(PDP_DIR)/include -I$(GEM_DIR)/src
INCLUDES = @INCLUDES@ -I$(PD_DIR)/src -I. -I$(PDP_DIR)/include -I$(GEM_DIR)/src -I$(GEM_DIR)/src/deprecated
CFLAGS = -fPIC -DPD -O2 -funroll-loops -fomit-frame-pointer -ffast-math \
-Wall -W -Wno-unused -Wno-parentheses -Wno-switch \
-DGEM2PDP_VERSION=\"$(GEM2PDP_VERSION)\" -g @CFLAGS@
......
......@@ -29,9 +29,9 @@ then
elif test -d ../../gem/Gem;
then
GEM_DIR=../../gem/Gem
elif test -d ../../Gem;
elif test -d ../../gem/Gem;
then
GEM_DIR=../../Gem
GEM_DIR=../../gem/Gem
else
echo "Gem sources not found"
fi
......@@ -69,7 +69,7 @@ then
fi
echo -n "looking for gem sources (required) ... "
if test -f $GEM_DIR/src/Base/GemBase.h
if test -f $GEM_DIR/src/Base/CPPExtern.h
then
AC_SUBST(GEM_DIR)
echo "ok."
......
......@@ -11,8 +11,8 @@
#include "gem2pdp.h"
#include "yuv.h"
#include "Gem/Manager.h"
#include "Gem/Cache.h"
#include "Base/GemMan.h"
#include "Base/GemCache.h"
#if defined(GEM_VERSION_MAJOR) && defined (GEM_VERSION_MINOR) && (GEM_VERSION_MAJOR>0 || GEM_VERSION_MINOR>=91)
# define GEM2PDP_LEGACY_GEM 0
......@@ -35,6 +35,7 @@ gem2pdp :: gem2pdp(void)
GemMan::getDimen(&m_width, &m_height);
#endif
m_image = NULL;
m_buffer = GL_FRONT_LEFT;
m_pdpoutlet = outlet_new(this->x_obj, &s_anything);
}
......@@ -43,6 +44,52 @@ gem2pdp :: ~gem2pdp()
if (m_image) cleanImage();
}
void gem2pdp :: bufferMess(int buffer)
{
switch(buffer)
{
case 0:
m_buffer = GL_FRONT_LEFT;
break;
case 1:
m_buffer = GL_FRONT_RIGHT;
break;
case 2:
m_buffer = GL_BACK_LEFT;
break;
case 3:
m_buffer = GL_BACK_RIGHT;
break;
case 4:
m_buffer = GL_FRONT;
break;
case 5:
m_buffer = GL_BACK;
break;
case 6:
m_buffer = GL_LEFT;
break;
case 7:
m_buffer = GL_RIGHT;
break;
case 8:
m_buffer = GL_FRONT_AND_BACK;
break;
case 9:
m_buffer = GL_AUX0;
break;
case 10:
m_buffer = GL_AUX1;
break;
case 11:
m_buffer = GL_AUX2;
break;
case 12:
m_buffer = GL_AUX3;
break;
}
}
void gem2pdp :: bangMess()
{
t_int needNew=0, pbuffers;
......@@ -50,7 +97,6 @@ void gem2pdp :: bangMess()
short int *pY, *pU, *pV;
unsigned char r,g,b,a;
t_int cpt;
void *idontknowwhatitis=NULL;
if ( !GemMan::windowExists() )
{
......@@ -68,9 +114,6 @@ void gem2pdp :: bangMess()
GemMan::getOffset(&m_x, &m_y);
GemMan::getDimen(&m_width, &m_height);
#endif
pbuffers = GemMan::m_buffer;
// GemMan::m_buffer = 1;
// GemMan::render(idontknowwhatitis);
// post("gem2pdp : got dimensions : x=%d y=%d w=%d h=%d", m_x, m_y, m_width, m_height);
if (m_width <= 0 || m_height <= 0)
......@@ -105,6 +148,7 @@ void gem2pdp :: bangMess()
post( "gem2pdp : allocated image : w=%d h=%d", m_image->xsize, m_image->ysize );
}
glReadBuffer(m_buffer);
glReadPixels(m_x, m_y, m_image->xsize, m_image->ysize,
m_image->format, m_image->type, m_image->data);
......@@ -141,10 +185,6 @@ void gem2pdp :: bangMess()
pdp_packet_pass_if_valid(m_pdpoutlet, &m_packet0);
// restore buffer state
// GemMan::m_buffer = pbuffers;
// GemMan::render(idontknowwhatitis);
// post("gem2pdp : read image");
}
......@@ -159,6 +199,8 @@ void gem2pdp :: obj_setupCallback(t_class *classPtr)
::post( "gem2pdp : a bridge between GEM and PDP/PiDiP v"GEM2PDP_VERSION" (ydegoyon@free.fr)" );
class_addmethod(classPtr, (t_method)&gem2pdp::bangMessCallback,
gensym("bang"), A_NULL);
class_addmethod(classPtr, (t_method)&gem2pdp::bufferMessCallback,
gensym("buffer"), A_FLOAT, A_NULL);
class_sethelpsymbol( classPtr, gensym("gem2pdp.pd") );
}
......@@ -167,8 +209,14 @@ void gem2pdp :: bangMessCallback(void *data)
GetMyClass(data)->bangMess();
}
void gem2pdp :: bufferMessCallback(void *data, t_floatarg buffer)
{
GetMyClass(data)->bufferMess((int)buffer);
}
void gem2pdp :: render(GemState *state)
{
GemMan::render(state);
m_gemstate=state;
// GemMan::render(state);
return;
}
......@@ -11,7 +11,7 @@
#define INCLUDE_GEM2PDP_H_
#include "Base/GemBase.h"
#include "Gem/Image.h"
#include "Base/GemPixUtil.h"
#include "pdp.h"
class GEM_EXTERN gem2pdp : public GemBase
......@@ -30,14 +30,18 @@ class GEM_EXTERN gem2pdp : public GemBase
t_outlet *m_pdpoutlet;
virtual ~gem2pdp(void);
virtual void bangMess(void);
virtual void bufferMess(int);
virtual void render(GemState *state);
void cleanImage();
int m_packet0;
t_pdp *m_header;
short int *m_data;
void *m_gemstate;
GLenum m_buffer;
private:
static void bangMessCallback(void *data);
static void bufferMessCallback(void *data, t_floatarg buffer);
};
#endif
......@@ -10,7 +10,8 @@
#include "pdp2gem.h"
#include "Gem/State.h"
#include "Base/GemState.h"
#include "Base/GemVersion.h"
#include "yuv.h"
CPPEXTERN_NEW_WITH_ONE_ARG(pdp2gem, t_symbol *, A_DEFSYM)
......@@ -235,13 +236,17 @@ void pdp2gem :: startRendering()
void pdp2gem :: render(GemState *state)
{
if ( m_data )
if ( m_data && state )
{
// lock mutex
pthread_mutex_lock(m_mutex);
m_pixBlock.newimage = 1;
#if GEM_VERSION_MINOR >= 93
state->set(GemState::_PIX, &m_pixBlock);
#else
state->image = &m_pixBlock;
#endif
}
}
......
......@@ -21,7 +21,7 @@
#include <stdio.h>
#include "Base/GemBase.h"
#include "Gem/Image.h"
#include "Base/GemPixUtil.h"
#include "pdp.h"
#include <pthread.h>
......
......@@ -57,6 +57,10 @@ void pix_2pdp::bangMess()
// make pdp packet
psize = gem_xsize * gem_ysize;
m_packet0 = pdp_packet_new_image_YCrCb( gem_xsize, gem_ysize);
if(!m_packet0) {
error("couldn't allocate new pdp packet...");
return;
}
m_header = pdp_packet_header(m_packet0);
m_data = (short int *)pdp_packet_data(m_packet0);
......@@ -88,8 +92,9 @@ void pix_2pdp::bangMess()
*(pV) = ( yuv_RGBtoV( (g1<<16) + (g2<<8) + g3 ) - 128 ) << 8;
*(pU) = ( yuv_RGBtoU( (g1<<16) + (g2<<8) + g3 ) - 128 ) << 8;
pY++;
if ( (px%2==0) && (py%2==0) )
if ( (px%2==0) && (py%2==0) ) {
pV++; pU++;
}
}
}
pdp_packet_pass_if_valid(m_pdpoutlet, &m_packet0);
......
Supports Markdown
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