Commit ecbfb5f5 authored by zmoelnig's avatar zmoelnig
Browse files

more casts

git-svn-id: https://pd-gem.svn.sourceforge.net/svnroot/pd-gem/trunk/Gem@3058 49b2a0ca-c541-4d49-a7ef-d785e4371512
parent 89c164f7
......@@ -174,11 +174,11 @@ void gemframebuffer :: postrender(GemState *state)
glActiveTexture(GL_TEXTURE0_ARB + m_texunit);
if(m_texTarget== GL_TEXTURE_2D) {
w=(t_float)1.f;
h=(t_float)1.f;
w=1.f;
h=1.f;
} else {
w=(t_float)m_width;
h=(t_float)m_height;
w=static_cast<t_float>(m_width);
h=static_cast<t_float>(m_height);
}
// GPGPU CONCEPT 4: Viewport-Sized Quad = Data Stream Generator.
......@@ -206,11 +206,11 @@ void gemframebuffer :: postrender(GemState *state)
// send textureID, w, h, textureTarget to outlet
t_atom ap[5];
SETFLOAT(ap+0, (t_float)m_offScreenID);
SETFLOAT(ap+0, static_cast<t_float>(m_offScreenID));
SETFLOAT(ap+1, w);
SETFLOAT(ap+2, h);
SETFLOAT(ap+3, m_texTarget);
SETFLOAT(ap+4, (t_float)0);
SETFLOAT(ap+4, static_cast<t_float>(0.));
outlet_list(m_outTexInfo, 0, 5, ap);
}
......@@ -402,7 +402,7 @@ void gemframebuffer :: perspectiveMess(float f_left, float f_right,
}
void gemframebuffer :: formatMess(char* format)
void gemframebuffer :: formatMess(const char* format)
{
if (!strcmp(format, "YUV"))
{
......@@ -456,7 +456,7 @@ void gemframebuffer :: formatMess(char* format)
m_wantinit=true;
}
void gemframebuffer :: typeMess(char* type)
void gemframebuffer :: typeMess(const char* type)
{
if (!strcmp(type, "BYTE")){
m_type = GL_UNSIGNED_BYTE;
......@@ -513,21 +513,21 @@ void gemframebuffer :: bangMessCallback(void *data)
}
void gemframebuffer :: modeCallback(void *data, t_floatarg quality)
{
GetMyClass(data)->m_mode=((int)quality);
GetMyClass(data)->m_mode=(static_cast<int>(quality));
// changed mode, so we need to rebuild the FBO
GetMyClass(data)->m_wantinit=true;
}
void gemframebuffer :: dimMessCallback(void *data, t_floatarg width, t_floatarg height)
{
GetMyClass(data)->dimMess((int)width, (int)height);
GetMyClass(data)->dimMess(static_cast<int>(width), static_cast<int>(height));
}
void gemframebuffer :: formatMessCallback (void *data, t_symbol *format)
{
GetMyClass(data)->formatMess((char*)format->s_name);
GetMyClass(data)->formatMess(format->s_name);
}
void gemframebuffer :: typeMessCallback (void *data, t_symbol *type)
{
GetMyClass(data)->typeMess((char*)type->s_name);
GetMyClass(data)->typeMess(type->s_name);
}
void gemframebuffer :: colorMessCallback(void *data, t_floatarg red, t_floatarg green, t_floatarg blue, t_floatarg alpha)
......@@ -537,7 +537,7 @@ void gemframebuffer :: colorMessCallback(void *data, t_floatarg red, t_floatarg
void gemframebuffer :: texunitCallback(void *data, t_floatarg unit)
{
GetMyClass(data)->m_texunit=(GLuint)unit;
GetMyClass(data)->m_texunit=static_cast<GLuint>(unit);
}
void gemframebuffer :: perspectiveMessCallback(void *data, t_symbol*s,int argc, t_atom*argv)
......@@ -551,10 +551,15 @@ void gemframebuffer :: perspectiveMessCallback(void *data, t_symbol*s,int argc,
f_top= atom_getfloat(argv+3);
f_near=atom_getfloat(argv+4);
f_far= atom_getfloat(argv+5);
GetMyClass(data)->perspectiveMess((float)f_left, (float)f_right,
(float)f_bottom, (float)f_top, (float)f_near, (float)f_far);
GetMyClass(data)->perspectiveMess(
static_cast<float>(f_left),
static_cast<float>(f_right),
static_cast<float>(f_bottom),
static_cast<float>(f_top),
static_cast<float>(f_near),
static_cast<float>(f_far));
break;
default:
GetMyClass(data)->error("\"perspec\" expects 6 values for frustum - left, right, bottom, top, near, far");
}
}
\ No newline at end of file
}
......@@ -70,8 +70,8 @@ class GEM_EXTERN gemframebuffer : public GemBase
//////////
// format-message
virtual void formatMess(char* format);
virtual void typeMess(char* type);
virtual void formatMess(const char* format);
virtual void typeMess(const char* type);
virtual void colorMess(float red, float green, float blue, float alpha);
virtual void perspectiveMess( float left, float right, float bottom, float top, float near, float far);
......
......@@ -39,9 +39,9 @@ gemhead :: gemhead(t_floatarg priority)
: m_cache(NULL), m_renderOn(1)
{
// register with Gem
if (priority == 0)
priority = 50;
m_priority=(int)priority;
if (priority == 0.)
priority = 50.;
m_priority=priority;
GemMan::addObj(this, m_priority);
m_cache = new GemCache(this);
......@@ -100,9 +100,9 @@ void gemhead :: renderGL(GemState *state)
t_atom ap[2];
ap->a_type=A_POINTER;
ap->a_w.w_gpointer=(t_gpointer *)m_cache; // the cache ?
ap->a_w.w_gpointer=reinterpret_cast<t_gpointer*>(m_cache); // the cache ?
(ap+1)->a_type=A_POINTER;
(ap+1)->a_w.w_gpointer=(t_gpointer *)state;
(ap+1)->a_w.w_gpointer=reinterpret_cast<t_gpointer*>(state);
outlet_anything(this->m_out1, gensym("gem_state"), 2, ap);
m_cache->dirty = 0;
......@@ -148,9 +148,9 @@ void gemhead :: renderOnOff(int state)
/////////////////////////////////////////////////////////
void gemhead :: setMess(int priority)
{
if (priority == 0)priority=50;
if (priority == 0.)priority=50.;
GemMan::removeObj(this, m_priority);
GemMan::addObj(this, (int)priority);
GemMan::addObj(this, priority);
m_priority=priority;
}
......@@ -206,9 +206,9 @@ void gemhead :: bangMessCallback(void *data)
}
void gemhead :: intMessCallback(void *data, t_floatarg n)
{
GetMyClass(data)->renderOnOff((int)n);
GetMyClass(data)->renderOnOff(static_cast<int>(n));
}
void gemhead :: setMessCallback(void *data, t_floatarg n)
{
GetMyClass(data)->setMess((int)n);
GetMyClass(data)->setMess(static_cast<int>(n));
}
......@@ -56,7 +56,7 @@ gemkeyboard :: ~gemkeyboard()
void gemkeyboard :: KeyBoardPressed(int val, int state)
{
if (state==0)return;
outlet_float(m_outKeyVal, (t_float)val);
outlet_float(m_outKeyVal, static_cast<t_float>(val));
}
/////////////////////////////////////////////////////////
......@@ -67,5 +67,5 @@ void gemkeyboard :: obj_setupCallback(t_class *)
{ }
void gemkeyboard :: keyboardCallback(char* w, int x, int y, void *data)
{
((gemkeyboard *)data)->KeyBoardPressed(x, y);
(reinterpret_cast<gemkeyboard*>(data))->KeyBoardPressed(x, y);
}
......@@ -58,7 +58,7 @@ gemkeyname :: ~gemkeyname()
void gemkeyname :: KeyNamePressed(char *string, int val, int state)
{
outlet_symbol(m_outKeyVal, gensym(string));
outlet_float(m_outKeyState, (t_float)state);
outlet_float(m_outKeyState, static_cast<t_float>(state));
}
/////////////////////////////////////////////////////////
......@@ -69,5 +69,5 @@ void gemkeyname :: obj_setupCallback(t_class *)
{ }
void gemkeyname :: keynameCallback(char *x, int y, int z, void *data)
{
((gemkeyname *)data)->KeyNamePressed(x,y, z);
(reinterpret_cast<gemkeyname*>(data))->KeyNamePressed(x,y, z);
}
......@@ -86,9 +86,9 @@ void gemlist :: sendCacheState(GemCache *cache, GemState*state)
if(cache && state) {
t_atom ap[2];
ap->a_type=A_POINTER;
ap->a_w.w_gpointer=(t_gpointer *)cache;
ap->a_w.w_gpointer=reinterpret_cast<t_gpointer*>(cache);
(ap+1)->a_type=A_POINTER;
(ap+1)->a_w.w_gpointer=(t_gpointer *)state;
(ap+1)->a_w.w_gpointer=reinterpret_cast<t_gpointer*>(state);
outlet_anything(m_out1, gensym("gem_state"), 2, ap);
}
}
......@@ -156,7 +156,7 @@ void gemlist :: drawMess(t_atom arg)
m_drawType = GL_POINT;
break;
default:
m_drawType = (GLenum)getGLdefine(&arg);
m_drawType = static_cast<GLenum>(getGLdefine(&arg));
}
}
else m_drawType=atom_getint(&arg);
......@@ -215,7 +215,7 @@ void gemlist::gem_rightMessCallback(void *data, t_symbol *s, int argc, t_atom *a
{
if (argc==1 && argv->a_type==A_FLOAT){
} else if (argc==2 && argv->a_type==A_POINTER && (argv+1)->a_type==A_POINTER){
GetMyClass(data)->m_cache = (GemCache*)argv->a_w.w_gpointer;
GetMyClass(data)->rightRender((GemState *)(argv+1)->a_w.w_gpointer);
GetMyClass(data)->m_cache = reinterpret_cast<GemCache*>(argv->a_w.w_gpointer);
GetMyClass(data)->rightRender(reinterpret_cast<GemState*>((argv+1)->a_w.w_gpointer));
} else GetMyClass(data)->error("wrong righthand arguments....");
}
......@@ -107,8 +107,8 @@ void gemmouse :: mouseMotion(int x, int y)
break;
}
outlet_float(m_outYPos, (t_float)(y*scaley));
outlet_float(m_outXPos, (t_float)(x*scalex));
outlet_float(m_outYPos, static_cast<t_float>(y*scaley));
outlet_float(m_outXPos, static_cast<t_float>(x*scalex));
}
/////////////////////////////////////////////////////////
......@@ -118,9 +118,9 @@ void gemmouse :: mouseMotion(int x, int y)
void gemmouse :: mouseButton(int which, int state, int x, int y)
{
switch (which){
case 0: outlet_float(m_outLBut, (t_float)state); break;
case 1: outlet_float(m_outMBut, (t_float)state); break;
case 2: outlet_float(m_outRBut, (t_float)state); break;
case 0: outlet_float(m_outLBut, static_cast<t_float>(state)); break;
case 1: outlet_float(m_outMBut, static_cast<t_float>(state)); break;
case 2: outlet_float(m_outRBut, static_cast<t_float>(state)); break;
}
}
......@@ -140,13 +140,13 @@ void gemmouse :: obj_setupCallback(t_class *)
{ }
void gemmouse :: mouseMotionCallback(int x, int y, void *data)
{
((gemmouse *)data)->mouseMotion(x, y);
(reinterpret_cast<gemmouse*>(data))->mouseMotion(x, y);
}
void gemmouse :: mouseButtonCallback(int which, int state, int x, int y, void *data)
{
((gemmouse *)data)->mouseButton(which, state, x, y);
(reinterpret_cast<gemmouse*>(data))->mouseButton(which, state, x, y);
}
void gemmouse :: mouseWheelCallback(int axis, int value, void *data)
{
((gemmouse *)data)->mouseWheel(axis, value);
(reinterpret_cast<gemmouse*>(data))->mouseWheel(axis, value);
}
......@@ -57,7 +57,7 @@ t_gemreceive_proxy* gemreceive::find_key(t_symbol*key)
t_gemreceive_proxy*gemreceive::add_key(t_symbol*key)
{
t_gemreceive_proxy*bind_list=0;
bind_list=(t_gemreceive_proxy*)pd_new(gemreceive_proxy_class);
bind_list=reinterpret_cast<t_gemreceive_proxy*>(pd_new(gemreceive_proxy_class));
bind_list->key=key;
bind_list->elements=0;
bind_list->next=0;
......
......@@ -56,10 +56,10 @@ gemwin :: gemwin(t_floatarg framespersecond)
/* this is the only [gemwin] */
GemMan::resetState();
if (framespersecond > 0.)
GemMan::frameRate((float)framespersecond);
GemMan::frameRate(framespersecond);
} else {
if(framespersecond>0.)
GemMan::frameRate((float)framespersecond);
GemMan::frameRate(framespersecond);
}
m_FrameRate = outlet_new(this->x_obj, 0);
......@@ -265,7 +265,7 @@ void gemwin :: colorMess(float red, float green, float blue, float alpha)
/////////////////////////////////////////////////////////
void gemwin :: clearmaskMess(float bitmask)
{
GemMan::m_clear_mask = (GLbitfield) bitmask;
GemMan::m_clear_mask = static_cast<GLbitfield>(bitmask);
}
/////////////////////////////////////////////////////////
......@@ -378,7 +378,7 @@ void gemwin :: fogModeMess(int mode)
/////////////////////////////////////////////////////////
void gemwin :: cursorMess(float setting)
{
GemMan :: cursorOnOff((int)setting);
GemMan :: cursorOnOff(static_cast<int>(setting));
}
/////////////////////////////////////////////////////////
......@@ -387,7 +387,7 @@ void gemwin :: cursorMess(float setting)
/////////////////////////////////////////////////////////
void gemwin :: topmostMess(float topmost)
{
GemMan::topmostOnOff((int) topmost);
GemMan::topmostOnOff(static_cast<int>(topmost));
}
......@@ -524,11 +524,11 @@ void gemwin :: printMessCallback(void *)
}
void gemwin :: profileMessCallback(void *, t_floatarg state)
{
GemMan::m_profile = (int)state;
GemMan::m_profile = static_cast<int>(state);
}
void gemwin :: lightingMessCallback(void *, t_floatarg state)
{
GemMan::lightingOnOff((int)state);
GemMan::lightingOnOff(static_cast<int>(state));
}
void gemwin :: fogMessCallback(void *data, t_symbol *, int argc, t_atom *argv)
{
......@@ -554,7 +554,7 @@ void gemwin :: fogColorMessCallback(void *data, t_symbol*s,int argc, t_atom*argv
red= atom_getfloat(argv);
green=atom_getfloat(argv+1);
blue= atom_getfloat(argv+2);
GetMyClass(data)->fogColorMess((float)red, (float)green, (float)blue, (float)alpha);
GetMyClass(data)->fogColorMess(static_cast<float>(red), static_cast<float>(green), static_cast<float>(blue), static_cast<float>(alpha));
break;
default:
GetMyClass(data)->error("\"fogcolor\" expects 3 or 4 values");
......@@ -562,11 +562,11 @@ void gemwin :: fogColorMessCallback(void *data, t_symbol*s,int argc, t_atom*argv
}
void gemwin :: fogModeMessCallback(void *data, t_float val)
{
GetMyClass(data)->fogModeMess((int)val);
GetMyClass(data)->fogModeMess(static_cast<int>(val));
}
void gemwin :: stereoMessCallback(void *data, t_floatarg state)
{
int mode = (int)state;
int mode = static_cast<int>(state);
if (mode<0 || mode>3){
GetMyClass(data)->error("possible stereo-modes are: 0, 1, 2, 3");
return;
......@@ -588,7 +588,7 @@ void gemwin :: stereoLineMessCallback(void *, t_floatarg state)
}
void gemwin :: borderMessCallback(void *, t_floatarg state)
{
GemMan::m_border = (int)state;
GemMan::m_border = static_cast<int>(state);
}
void gemwin :: destroyMessCallback(void *)
{
......@@ -600,7 +600,7 @@ void gemwin :: resetMessCallback(void *)
}
void gemwin :: frameMessCallback(void *, t_floatarg rate)
{
GemMan::frameRate((float)rate);
GemMan::frameRate(static_cast<float>(rate));
}
void gemwin :: perspectiveMessCallback(void *data, t_symbol *, int argc, t_atom *argv)
{
......@@ -644,17 +644,17 @@ void gemwin :: viewMessCallback(void *data, t_symbol *, int argc, t_atom *argv)
break;
case 5 :
theta = (float)DEG2RAD * atom_getfloat(&argv[4]);
theta = static_cast<float>(DEG2RAD) * atom_getfloat(&argv[4]);
case 4 :
azimuth = (float)DEG2RAD * atom_getfloat(&argv[3]);
azimuth = static_cast<float>(DEG2RAD) * atom_getfloat(&argv[3]);
// just have position
case 3 :
{
const float dx = (float)(cos(theta) * sinf(azimuth));
const float dy = (float)(sin(theta));
const float dz = -(float)(cos(theta) * cosf(azimuth));
const float dx = static_cast<float>(cos(theta) * sinf(azimuth));
const float dy = static_cast<float>(sin(theta));
const float dz = -static_cast<float>(cos(theta) * cosf(azimuth));
GemMan::m_lookat[0] = atom_getfloat(&argv[0]); // eyex
GemMan::m_lookat[1] = atom_getfloat(&argv[1]); // eyey
......@@ -681,7 +681,7 @@ void gemwin :: bangMessCallback(void *data)
}
void gemwin :: floatMessCallback(void *data, t_float state)
{
GetMyClass(data)->intMess((int)state);
GetMyClass(data)->intMess(static_cast<int>(state));
}
void gemwin :: renderMessCallback(void *data)
{
......@@ -703,27 +703,27 @@ void gemwin :: createStereoMessCallback(void *data)
}
void gemwin :: bufferMessCallback(void *data, t_floatarg buf)
{
GetMyClass(data)->bufferMess((int)buf);
GetMyClass(data)->bufferMess(static_cast<int>(buf));
}
void gemwin :: fullscreenMessCallback(void *data, t_floatarg on)
{
GetMyClass(data)->fullscreenMess((int)on);
GetMyClass(data)->fullscreenMess(static_cast<int>(on));
}
void gemwin :: menuBarMessCallback(void *data, t_floatarg on)
{
GetMyClass(data)->menuBarMess((int)on);
GetMyClass(data)->menuBarMess(static_cast<int>(on));
}
void gemwin :: secondscreenMessCallback(void *data, t_floatarg on)
{
GetMyClass(data)->secondscreenMess((int)on);
GetMyClass(data)->secondscreenMess(static_cast<int>(on));
}
void gemwin :: dimensionsMessCallback(void *data, t_floatarg width, t_floatarg height)
{
GetMyClass(data)->dimensionsMess((int)width, (int)height);
GetMyClass(data)->dimensionsMess(static_cast<int>(width), static_cast<int>(height));
}
void gemwin :: offsetMessCallback(void *data, t_floatarg x, t_floatarg y)
{
GetMyClass(data)->offsetMess((int)x, (int)y);
GetMyClass(data)->offsetMess(static_cast<int>(x), static_cast<int>(y));
}
void gemwin :: colorMessCallback(void *data, t_symbol*s, int argc, t_atom*argv)
{
......@@ -735,7 +735,7 @@ void gemwin :: colorMessCallback(void *data, t_symbol*s, int argc, t_atom*argv)
red= atom_getfloat(argv);
green=atom_getfloat(argv+1);
blue= atom_getfloat(argv+2);
GetMyClass(data)->colorMess((float)red, (float)green, (float)blue, (float)alpha);
GetMyClass(data)->colorMess(static_cast<float>(red), static_cast<float>(green), static_cast<float>(blue), static_cast<float>(alpha));
break;
default:
GetMyClass(data)->error("\"color\" expects 3 or 4 values");
......@@ -743,7 +743,7 @@ void gemwin :: colorMessCallback(void *data, t_symbol*s, int argc, t_atom*argv)
}
void gemwin :: clearmaskMessCallback(void *data, t_floatarg bitmask)
{
GetMyClass(data)->clearmaskMess((float)bitmask);
GetMyClass(data)->clearmaskMess(static_cast<float>(bitmask));
}
void gemwin :: ambientMessCallback(void *data, t_symbol*s,int argc, t_atom*argv)
{
......@@ -755,7 +755,7 @@ void gemwin :: ambientMessCallback(void *data, t_symbol*s,int argc, t_atom*argv)
red= atom_getfloat(argv);
green=atom_getfloat(argv+1);
blue= atom_getfloat(argv+2);
GetMyClass(data)->ambientMess((float)red, (float)green, (float)blue, (float)alpha);
GetMyClass(data)->ambientMess(static_cast<float>(red), static_cast<float>(green), static_cast<float>(blue), static_cast<float>(alpha));
break;
default:
GetMyClass(data)->error("\"ambient\" expects 3 or 4 values");
......@@ -771,7 +771,7 @@ void gemwin :: specularMessCallback(void *data, t_symbol*s,int argc, t_atom*argv
red= atom_getfloat(argv);
green=atom_getfloat(argv+1);
blue= atom_getfloat(argv+2);
GetMyClass(data)->specularMess((float)red, (float)green, (float)blue, (float)alpha);
GetMyClass(data)->specularMess(static_cast<float>(red), static_cast<float>(green), static_cast<float>(blue), static_cast<float>(alpha));
break;
default:
GetMyClass(data)->error("\"specular\" expects 3 or 4 values");
......@@ -779,19 +779,19 @@ void gemwin :: specularMessCallback(void *data, t_symbol*s,int argc, t_atom*argv
}
void gemwin :: shininessMessCallback(void *data, t_floatarg val)
{
GetMyClass(data)->shininessMess((float)val);
GetMyClass(data)->shininessMess(static_cast<float>(val));
}
void gemwin :: cursorMessCallback(void *data, t_floatarg val)
{
GetMyClass(data)->cursorMess((float)val);
GetMyClass(data)->cursorMess(static_cast<float>(val));
}
void gemwin :: topmostMessCallback(void *data, t_floatarg val)
{
GetMyClass(data)->topmostMess((float)val);
GetMyClass(data)->topmostMess(static_cast<float>(val));
}
void gemwin :: blurMessCallback(void *data, t_floatarg val)
{
GetMyClass(data)->blurMess((float)val);
GetMyClass(data)->blurMess(static_cast<float>(val));
}
void gemwin :: fpsMessCallback(void *data)
{
......@@ -800,6 +800,6 @@ void gemwin :: fpsMessCallback(void *data)
void gemwin :: fsaaMessCallback(void *data, t_floatarg val)
{
GetMyClass(data)->fsaaMess((int) val);
GetMyClass(data)->fsaaMess(static_cast<int>(val));
}
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