Commit 337d820d authored by IOhannes m zmölnig's avatar IOhannes m zmölnig
Browse files

Indent with 2 spaces

parent 4fe2d9c3
......@@ -53,12 +53,12 @@ CPPExtern :: CPPExtern()
m_canvas(NULL),
m_endpost(true)
{
m_canvas = canvas_getcurrent();
if(m_holdname) {
m_objectname=gensym(m_holdname);
} else {
m_objectname=gensym("unknown Gem object");
}
m_canvas = canvas_getcurrent();
if(m_holdname) {
m_objectname=gensym(m_holdname);
} else {
m_objectname=gensym("unknown Gem object");
}
}
CPPExtern :: CPPExtern(const CPPExtern&org) :
x_obj(org.x_obj),
......@@ -189,7 +189,7 @@ bool CPPExtern :: checkGemVersion(const int major, const int minor) {
::error("GEM version mismatch: compiled for %d.%d but we are running %s",
major, minor,
GemVersion::versionString());
return false;
return false;
}
return true;
}
......
......@@ -51,8 +51,8 @@ GemGluObj :: GemGluObj(t_floatarg size, t_floatarg slices, t_floatarg stacks)
/////////////////////////////////////////////////////////
GemGluObj :: ~GemGluObj()
{
// in case we are deleted while still running
inlet_free(m_sliceInlet);
// in case we are deleted while still running
inlet_free(m_sliceInlet);
}
/////////////////////////////////////////////////////////
......@@ -61,15 +61,15 @@ GemGluObj :: ~GemGluObj()
/////////////////////////////////////////////////////////
void GemGluObj :: numSlicesMess(int numSlices)
{
m_numSlices = (numSlices < 2) ? 2 : numSlices;
m_numStacks = m_numSlices;
setModified();
m_numSlices = (numSlices < 2) ? 2 : numSlices;
m_numStacks = m_numSlices;
setModified();
}
void GemGluObj :: numSlicesMess(int numSlices, int numStacks)
{
m_numSlices = (numSlices < 2) ? 2 : numSlices;
m_numStacks = (numStacks < 2) ? 2 : numStacks;
setModified();
m_numSlices = (numSlices < 2) ? 2 : numSlices;
m_numStacks = (numStacks < 2) ? 2 : numStacks;
setModified();
}
/////////////////////////////////////////////////////////
......@@ -78,8 +78,8 @@ void GemGluObj :: numSlicesMess(int numSlices, int numStacks)
/////////////////////////////////////////////////////////
void GemGluObj :: obj_setupCallback(t_class *classPtr)
{
class_addmethod(classPtr, reinterpret_cast<t_method>(&GemGluObj::numSlicesMessCallback),
gensym("numslices"), A_GIMME, A_NULL);
class_addmethod(classPtr, reinterpret_cast<t_method>(&GemGluObj::numSlicesMessCallback),
gensym("numslices"), A_GIMME, A_NULL);
}
void GemGluObj :: numSlicesMessCallback(void *data, t_symbol*, int argc, t_atom*argv)
{
......
......@@ -33,13 +33,13 @@ GemPathBase :: GemPathBase(int argc, t_atom *argv)
if (argc >= 2)
openMess(atom_getsymbol(&argv[1]));
if (argc >= 1) {
m_numDimens = (int)atom_getfloat(&argv[0]);
if (m_numDimens < 1) m_numDimens = 1;
if (m_numDimens > 64) {
error("too many dimensions, must be below 64");
m_numDimens = 64;
}
m_numDimens = (int)atom_getfloat(&argv[0]);
if (m_numDimens < 1) m_numDimens = 1;
if (m_numDimens > 64) {
error("too many dimensions, must be below 64");
m_numDimens = 64;
}
}
}
/////////////////////////////////////////////////////////
......@@ -59,35 +59,35 @@ void GemPathBase :: openMess(t_symbol *arrayname)
{
m_array = (t_garray *)pd_findbyclass(arrayname, garray_class);
if (!m_array) {
error("unable to find array %s", arrayname->s_name);
return;
}
error("unable to find array %s", arrayname->s_name);
return;
}
}
void GemPathBase :: floatMess(t_float val)
{
if (!m_array) {
error("no array");
return;
}
if (!m_array) {
error("no array");
return;
}
int size;
t_word *vec;
if (!garray_getfloatwords(m_array, &size, &vec))
return;
int size;
t_word *vec;
if (!garray_getfloatwords(m_array, &size, &vec))
return;
if (size % m_numDimens) {
error("size is not a mod of dimensions");
return;
}
if (size % m_numDimens) {
error("size is not a mod of dimensions");
return;
}
t_float output[64];
lookupFunc(val, output, m_numDimens, size / m_numDimens, &(vec->w_float));
t_float output[64];
lookupFunc(val, output, m_numDimens, size / m_numDimens, &(vec->w_float));
t_atom argv[64];
for (int i = 0; i < m_numDimens; i++)
SETFLOAT((&argv[i]), output[i]);
t_atom argv[64];
for (int i = 0; i < m_numDimens; i++)
SETFLOAT((&argv[i]), output[i]);
outlet_list(m_out1, &s_list, m_numDimens, argv);
outlet_list(m_out1, &s_list, m_numDimens, argv);
}
/////////////////////////////////////////////////////////
......
......@@ -31,26 +31,26 @@
inline int c99_vsnprintf(char* str, size_t size, const char* format, va_list ap)
{
int count = -1;
int count = -1;
if (size != 0)
count = _vsnprintf_s(str, size, _TRUNCATE, format, ap);
if (count == -1)
count = _vscprintf(format, ap);
if (size != 0)
count = _vsnprintf_s(str, size, _TRUNCATE, format, ap);
if (count == -1)
count = _vscprintf(format, ap);
return count;
return count;
}
inline int c99_snprintf(char* str, size_t size, const char* format, ...)
{
int count;
va_list ap;
int count;
va_list ap;
va_start(ap, format);
count = c99_vsnprintf(str, size, format, ap);
va_end(ap);
va_start(ap, format);
count = c99_vsnprintf(str, size, format, ap);
va_end(ap);
return count;
return count;
}
#endif // _MSC_VER
......@@ -70,8 +70,8 @@ GemPixDualObj :: GemPixDualObj()
org_pixRightValid(-1),
m_inlet(NULL)
{
m_inlet = inlet_new(this->x_obj, &this->x_obj->ob_pd, gensym("gem_state"), gensym("gem_right"));
memset(&m_pixRight, 0, sizeof(m_pixRight));
m_inlet = inlet_new(this->x_obj, &this->x_obj->ob_pd, gensym("gem_state"), gensym("gem_right"));
memset(&m_pixRight, 0, sizeof(m_pixRight));
}
/////////////////////////////////////////////////////////
......@@ -80,7 +80,7 @@ GemPixDualObj :: GemPixDualObj()
/////////////////////////////////////////////////////////
GemPixDualObj :: ~GemPixDualObj()
{
inlet_free(m_inlet);
inlet_free(m_inlet);
}
/////////////////////////////////////////////////////////
......@@ -96,32 +96,32 @@ void GemPixDualObj :: render(GemState *state)
// processImage
//
/////////////////////////////////////////////////////////
#define PROCESS_DUALIMAGE_SIMD(CS) \
switch(m_simd){ \
case (GEM_SIMD_MMX): \
#define PROCESS_DUALIMAGE_SIMD(CS) \
switch(m_simd){ \
case (GEM_SIMD_MMX): \
process##CS ##_MMX(image, m_pixRight->image); \
break; \
case(GEM_SIMD_SSE2): \
break; \
case(GEM_SIMD_SSE2): \
process##CS ##_SSE2(image, m_pixRight->image); \
break; \
break; \
case(GEM_SIMD_ALTIVEC): \
process##CS ##_Altivec(image, m_pixRight->image); \
process##CS ##_Altivec(image, m_pixRight->image); \
break; \
default: \
process##CS ##_##CS(image, m_pixRight->image); \
process##CS ##_##CS(image, m_pixRight->image); \
}
#define PROCESS_DUALIMAGE(CS1, CS2) \
#define PROCESS_DUALIMAGE(CS1, CS2) \
process##CS1 ##_##CS2 (image, m_pixRight->image);
#define PROCESS_COLORSPACE(FUN_RGBA, FUN_YUV, FUN_GRAY) \
switch (m_pixRight->image.format) { \
case GL_RGBA: case GL_BGRA_EXT: \
found=true; FUN_RGBA; break; \
case GL_LUMINANCE: \
found=true; FUN_GRAY; break; \
case GL_YCBCR_422_GEM: \
found=true; FUN_YUV ; break; \
#define PROCESS_COLORSPACE(FUN_RGBA, FUN_YUV, FUN_GRAY) \
switch (m_pixRight->image.format) { \
case GL_RGBA: case GL_BGRA_EXT: \
found=true; FUN_RGBA; break; \
case GL_LUMINANCE: \
found=true; FUN_GRAY; break; \
case GL_YCBCR_422_GEM: \
found=true; FUN_YUV ; break; \
default:break;}
void GemPixDualObj :: processImage(imageStruct &image)
......@@ -134,41 +134,41 @@ void GemPixDualObj :: processImage(imageStruct &image)
//if (!m_cacheRight || !&image || !&m_pixRight || !&m_pixRight->image) return;
if (!m_pixRightValid || !&image || !&m_pixRight || !&m_pixRight->image) return;
if (image.xsize != m_pixRight->image.xsize ||
image.ysize != m_pixRight->image.ysize) {
error("two images do not have equal dimensions (%dx%d != %dx%d)",
image.xsize, image.ysize,
m_pixRight->image.xsize, m_pixRight->image.ysize);
m_pixRightValid = 0;
return;
}
if (image.xsize != m_pixRight->image.xsize ||
image.ysize != m_pixRight->image.ysize) {
error("two images do not have equal dimensions (%dx%d != %dx%d)",
image.xsize, image.ysize,
m_pixRight->image.xsize, m_pixRight->image.ysize);
m_pixRightValid = 0;
return;
}
if(image.upsidedown != m_pixRight->image.upsidedown) {
image.fixUpDown();
m_pixRight->image.fixUpDown();
}
if(image.upsidedown != m_pixRight->image.upsidedown) {
image.fixUpDown();
m_pixRight->image.fixUpDown();
}
bool found = false;
switch (image.format) {
case GL_RGBA:
case GL_BGRA_EXT:
PROCESS_COLORSPACE(PROCESS_DUALIMAGE_SIMD(RGBA),
PROCESS_DUALIMAGE(RGBA, YUV),
PROCESS_DUALIMAGE(RGBA, Gray));
break;
case GL_LUMINANCE:
PROCESS_COLORSPACE(PROCESS_DUALIMAGE(Gray, RGBA),
PROCESS_DUALIMAGE(Gray, YUV),
PROCESS_DUALIMAGE_SIMD(Gray));
break;
case GL_YCBCR_422_GEM:
PROCESS_COLORSPACE(PROCESS_DUALIMAGE(YUV, RGBA),
PROCESS_DUALIMAGE_SIMD(YUV),
PROCESS_DUALIMAGE(YUV, Gray));
break;
default: break;
}
if (!found)processDualImage(image, m_pixRight->image);
bool found = false;
switch (image.format) {
case GL_RGBA:
case GL_BGRA_EXT:
PROCESS_COLORSPACE(PROCESS_DUALIMAGE_SIMD(RGBA),
PROCESS_DUALIMAGE(RGBA, YUV),
PROCESS_DUALIMAGE(RGBA, Gray));
break;
case GL_LUMINANCE:
PROCESS_COLORSPACE(PROCESS_DUALIMAGE(Gray, RGBA),
PROCESS_DUALIMAGE(Gray, YUV),
PROCESS_DUALIMAGE_SIMD(Gray));
break;
case GL_YCBCR_422_GEM:
PROCESS_COLORSPACE(PROCESS_DUALIMAGE(YUV, RGBA),
PROCESS_DUALIMAGE_SIMD(YUV),
PROCESS_DUALIMAGE(YUV, Gray));
break;
default: break;
}
if (!found)processDualImage(image, m_pixRight->image);
}
/////////////////////////////////////////////////////////
......@@ -176,25 +176,25 @@ void GemPixDualObj :: processImage(imageStruct &image)
//
/////////////////////////////////////////////////////////
namespace {
std::string format2string(GLenum fmt) {
std::string result="unknown";
switch (fmt) {
case GL_RGBA:
case GL_BGRA_EXT:
result = "RGBA";break;
case GL_LUMINANCE:
result = "Gray";break;
case GL_YCBCR_422_GEM:
result = "YUV";break;
default: do {
char fmtstring[7];
snprintf(fmtstring, 6, "0x%04X", (unsigned int)fmt);
fmtstring[6]='\0';
result=fmtstring;
} while(0);
std::string format2string(GLenum fmt) {
std::string result="unknown";
switch (fmt) {
case GL_RGBA:
case GL_BGRA_EXT:
result = "RGBA";break;
case GL_LUMINANCE:
result = "Gray";break;
case GL_YCBCR_422_GEM:
result = "YUV";break;
default: do {
char fmtstring[7];
snprintf(fmtstring, 6, "0x%04X", (unsigned int)fmt);
fmtstring[6]='\0';
result=fmtstring;
} while(0);
}
return result;
}
return result;
}
}
void GemPixDualObj :: processDualImage(imageStruct &left, imageStruct &right){
std::string lformat=format2string(left.format);
......@@ -246,8 +246,8 @@ void GemPixDualObj :: rightRender(GemState *statePtr)
/////////////////////////////////////////////////////////
void GemPixDualObj :: obj_setupCallback(t_class *classPtr)
{
class_addmethod(classPtr, reinterpret_cast<t_method>(&GemPixDualObj::gem_rightMessCallback),
gensym("gem_right"), A_GIMME, A_NULL);
class_addmethod(classPtr, reinterpret_cast<t_method>(&GemPixDualObj::gem_rightMessCallback),
gensym("gem_right"), A_GIMME, A_NULL);
}
void GemPixDualObj :: gem_rightMessCallback(void *data, t_symbol *s, int argc, t_atom *argv)
{
......
......@@ -32,8 +32,8 @@ GemPixObj :: GemPixObj() :
m_simd(GemSIMD::getCPU()),
m_doROI(false)
{
cachedPixBlock.newimage=0;
cachedPixBlock.newfilm =0;
cachedPixBlock.newimage=0;
cachedPixBlock.newfilm =0;
}
......@@ -157,7 +157,7 @@ void GemPixObj :: processImage(imageStruct &image)
case GL_RGB:
case GL_BGR_EXT:
error("cannot handle RGB image");
break;
break;
case GL_LUMINANCE:
error("cannot handle Grey image");
break;
......@@ -212,8 +212,8 @@ void GemPixObj :: processYUVAltivec (imageStruct &image)
/////////////////////////////////////////////////////////
void GemPixObj :: processOnOff(int on)
{
m_processOnOff = on;
setPixModified();
m_processOnOff = on;
setPixModified();
}
/////////////////////////////////////////////////////////
......
......@@ -125,7 +125,7 @@ void GemShape :: SetVertex(GemState* state,float x, float y, float z, float tx,
}
} else { // no multitexturing!
glTexCoord2f(tx, ty);
}
}
glVertex3f( x, y, z );
}
......@@ -149,7 +149,7 @@ void GemShape :: SetVertex(GemState* state,float x, float y, float z,
glMultiTexCoord4fARB(GL_TEXTURE0+i, s, t, r, q);
} else { // no multitexturing!
glTexCoord4f(s, t, r, q);
}
}
glVertex3f( x, y, z );
}
......@@ -162,8 +162,8 @@ void GemShape :: SetVertex(GemState* state,float x, float y, float z,
/////////////////////////////////////////////////////////
void GemShape :: linewidthMess(float linewidth)
{
m_linewidth = (linewidth < 0.0f) ? 0.0f : linewidth;
setModified();
m_linewidth = (linewidth < 0.0f) ? 0.0f : linewidth;
setModified();
}
/////////////////////////////////////////////////////////
......@@ -172,8 +172,8 @@ void GemShape :: linewidthMess(float linewidth)
/////////////////////////////////////////////////////////
void GemShape :: sizeMess(float size)
{
m_size = size;
setModified();
m_size = size;
setModified();
}
/////////////////////////////////////////////////////////
......
......@@ -33,38 +33,38 @@ GEM_EXTERN void gemAbortRendering();
/////////////////////////////////////////////////////////
BOOL bSetupPixelFormat(HDC hdc, const WindowHints &hints)
{
PIXELFORMATDESCRIPTOR pfd;
// clean out the descriptor
memset(&pfd, 0, sizeof(PIXELFORMATDESCRIPTOR));
pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);
pfd.nVersion = 1;
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL;
if (hints.buffer == 2)
pfd.dwFlags = pfd.dwFlags | PFD_DOUBLEBUFFER;
pfd.dwLayerMask = PFD_MAIN_PLANE;
pfd.iPixelType = PFD_TYPE_RGBA;
pfd.cColorBits = 24;
pfd.cRedBits = 8;
pfd.cBlueBits = 8;
pfd.cGreenBits = 8;
pfd.cDepthBits = 16;
pfd.cAccumBits = 0;
pfd.cStencilBits = 8;
int pixelformat;
if ( (pixelformat = ChoosePixelFormat(hdc, &pfd)) == 0 )
PIXELFORMATDESCRIPTOR pfd;
// clean out the descriptor
memset(&pfd, 0, sizeof(PIXELFORMATDESCRIPTOR));
pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);
pfd.nVersion = 1;
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL;
if (hints.buffer == 2)
pfd.dwFlags = pfd.dwFlags | PFD_DOUBLEBUFFER;
pfd.dwLayerMask = PFD_MAIN_PLANE;
pfd.iPixelType = PFD_TYPE_RGBA;
pfd.cColorBits = 24;
pfd.cRedBits = 8;
pfd.cBlueBits = 8;
pfd.cGreenBits = 8;
pfd.cDepthBits = 16;
pfd.cAccumBits = 0;
pfd.cStencilBits = 8;
int pixelformat;
if ( (pixelformat = ChoosePixelFormat(hdc, &pfd)) == 0 )
{
post("GEM: ChoosePixelFormat failed");
return(FALSE);
post("GEM: ChoosePixelFormat failed");
return(FALSE);
}
if (SetPixelFormat(hdc, pixelformat, &pfd) == FALSE)
if (SetPixelFormat(hdc, pixelformat, &pfd) == FALSE)
{
post("GEM: SetPixelFormat failed");
return(FALSE);
post("GEM: SetPixelFormat failed");
return(FALSE);
}
return(TRUE);
return(TRUE);
}
/////////////////////////////////////////////////////////
......@@ -73,64 +73,64 @@ BOOL bSetupPixelFormat(HDC hdc, const WindowHints &hints)
/////////////////////////////////////////////////////////
LONG WINAPI MainWndProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
static RECT rcClient;
static int ctrlKeyDown = 0;
static RECT rcClient;
static int ctrlKeyDown = 0;
// assume that we handle the message
long lRet = 0;
// assume that we handle the message
long lRet = 0;
switch (uMsg)
switch (uMsg)
{
// mouse motion
case WM_MOUSEMOVE:
triggerMotionEvent(LOWORD(lParam), HIWORD(lParam));
break;
// left button up
case WM_LBUTTONUP:
triggerButtonEvent(0, 0, LOWORD(lParam), HIWORD(lParam));
break;
// left button down
case WM_LBUTTONDOWN:
triggerButtonEvent(0, 1, LOWORD(lParam), HIWORD(lParam));
break;
// middle button up
case WM_MBUTTONUP:
triggerButtonEvent(1, 0, LOWORD(lParam), HIWORD(lParam));
break;
// middle button down
case WM_MBUTTONDOWN:
triggerButtonEvent(1, 1, LOWORD(lParam), HIWORD(lParam));
break;
// right button up
case WM_RBUTTONUP:
triggerButtonEvent(2, 0, LOWORD(lParam), HIWORD(lParam));
break;
// right button down
case WM_RBUTTONDOWN:
triggerButtonEvent(2, 1, LOWORD(lParam), HIWORD(lParam));
break;
// keyboard action
case WM_KEYUP:
if ((int)wParam == VK_CONTROL)
ctrlKeyDown = 0;
triggerKeyboardEvent((char*)&wParam, (int)wParam, 1);
break;
// keyboard action
// mouse motion
case WM_MOUSEMOVE:
triggerMotionEvent(LOWORD(lParam), HIWORD(lParam));
break;
// left button up
case WM_LBUTTONUP:
triggerButtonEvent(0, 0, LOWORD(lParam), HIWORD(lParam));
break;
// left button down
case WM_LBUTTONDOWN:
triggerButtonEvent(0, 1, LOWORD(lParam), HIWORD(lParam));
break;
// middle button up
case WM_MBUTTONUP:
triggerButtonEvent(1, 0, LOWORD(lParam), HIWORD(lParam));
break;