Browse Source

less warnings

Thomas Buck 11 years ago
parent
commit
23a245a82f
11 changed files with 104 additions and 127 deletions
  1. 12
    12
      include/Camera.h
  2. 5
    5
      include/MatMath.h
  3. 0
    7
      include/Matrix.h
  4. 0
    2
      include/Network.h
  5. 57
    57
      src/Camera.cpp
  6. 4
    4
      src/Emitter.cpp
  7. 1
    1
      src/GLString.cpp
  8. 10
    10
      src/MatMath.cpp
  9. 0
    10
      src/Matrix.cpp
  10. 7
    11
      src/Network.cpp
  11. 8
    8
      src/Texture.cpp

+ 12
- 12
include/Camera.h View File

@@ -104,7 +104,7 @@ public:
104 104
      * \brief Get angle/yaw of camera
105 105
      * \returns theta angle/yaw of camera
106 106
      */
107
-    double getRadianYaw();
107
+    vec_t getRadianYaw();
108 108
     /*------------------------------------------------------
109 109
      * Pre  :
110 110
      * Post : Returns theta angle/yaw of camera
@@ -125,7 +125,7 @@ public:
125 125
      * \brief Get angle/pitch of camera
126 126
      * \returns phi angle/pitch of camera
127 127
      */
128
-    double getRadianPitch();
128
+    vec_t getRadianPitch();
129 129
 
130 130
     /*!
131 131
      * \brief Check if the coordinate is behind camera eye
@@ -208,16 +208,16 @@ private:
208 208
     unsigned int mId;             //!< Unique id
209 209
     Quaternion mQ;                //!< Quaternion for rotation
210 210
     unsigned int mFlags;          //!< For testing with flags
211
-    double mPos[4];               //!< Location in 3 space (aka eye)
212
-    double mTarget[4];            //!< Postition we're looking at
213
-    double mUp[4];                //!< Up vector
214
-    double mSide[4];              //!< Side vector
215
-    double mViewDistance;         //!< Distance from target
216
-    double mTranslateDelta;       //!< Step size to move
217
-    double mRotateDelta;          //!< Radians to rotate Y
218
-    double mTheta;                //!< View angle Y
219
-    double mRotateDelta2;         //!< Radians to rotate Z
220
-    double mTheta2;               //!< View angle Z
211
+    vec_t mPos[4];               //!< Location in 3 space (aka eye)
212
+    vec_t mTarget[4];            //!< Postition we're looking at
213
+    vec_t mUp[4];                //!< Up vector
214
+    vec_t mSide[4];              //!< Side vector
215
+    vec_t mViewDistance;         //!< Distance from target
216
+    vec_t mTranslateDelta;       //!< Step size to move
217
+    vec_t mRotateDelta;          //!< Radians to rotate Y
218
+    vec_t mTheta;                //!< View angle Y
219
+    vec_t mRotateDelta2;         //!< Radians to rotate Z
220
+    vec_t mTheta2;               //!< View angle Z
221 221
     bool mUpdate;                 //!< Check to see if view needs updating
222 222
     static unsigned int mCounter; //!< Id system use
223 223
 };

+ 5
- 5
include/MatMath.h View File

@@ -11,11 +11,11 @@
11 11
 #ifndef _MATMATH_H
12 12
 #define _MATMATH_H
13 13
 
14
-#define HEL_PI           M_PI //!< pi
15
-#define HEL_2_PI         (M_PI * 2.0) //!< pi*2
16
-#define HEL_PI_OVER_4    M_PI_4 //!< pi/4
17
-#define HEL_PI_OVER_180  (M_PI / 180.0) //!< pi/180
18
-#define HEL_180_OVER_PI  (180.0 / M_PI) //!< 180/pi
14
+#define HEL_PI           ((float)M_PI) //!< pi
15
+#define HEL_2_PI         (HEL_PI * 2.0f) //!< pi*2
16
+#define HEL_PI_OVER_4    (M_PI_4 / 4.0f) //!< pi/4
17
+#define HEL_PI_OVER_180  (HEL_PI / 180.0f) //!< pi/180
18
+#define HEL_180_OVER_PI  (180.0f / HEL_PI) //!< 180/pi
19 19
 
20 20
 #define HEL_RAD_TO_DEG(x) ((x) * HEL_180_OVER_PI) //!< Convert radians to degrees
21 21
 #define HEL_DEG_TO_RAD(x) ((x) * HEL_PI_OVER_180) //!< Convert degrees to radians

+ 0
- 7
include/Matrix.h View File

@@ -87,13 +87,6 @@ public:
87 87
 
88 88
     /*!
89 89
      * \brief Multiplies v vector and this matrix
90
-     * \param v double[4] vector
91
-     * \param result where the result will be stored, may be same as v
92
-     */
93
-    void multiply4d(double *v, double *result);
94
-
95
-    /*!
96
-     * \brief Multiplies v vector and this matrix
97 90
      * \param v vector
98 91
      * \param result where the result will be stored, may be same as v
99 92
      */

+ 0
- 2
include/Network.h View File

@@ -67,8 +67,6 @@ public:
67 67
 
68 68
     unsigned int getUID();
69 69
 
70
-    float getRandom(float from, float to);
71
-
72 70
     int getPort();
73 71
 
74 72
     void setDebug(bool toggle);

+ 57
- 57
src/Camera.cpp View File

@@ -26,10 +26,10 @@ Camera::Camera()
26 26
 {
27 27
     mId = ++mCounter;
28 28
     mFlags = 0;
29
-    mViewDistance = 14.0;
30
-    mTranslateDelta = 256.0;
31
-    mRotateDelta = HEL_DEG_TO_RAD(15.0);
32
-    mRotateDelta2 = HEL_DEG_TO_RAD(5.0);
29
+    mViewDistance = 14.0f;
30
+    mTranslateDelta = 256.0f;
31
+    mRotateDelta = HEL_DEG_TO_RAD(15.0f);
32
+    mRotateDelta2 = HEL_DEG_TO_RAD(5.0f);
33 33
     mFlags &= Camera_FlyMode;
34 34
     reset();
35 35
 }
@@ -80,13 +80,13 @@ float Camera::getYaw()
80 80
 }
81 81
 
82 82
 
83
-double Camera::getRadianYaw()
83
+vec_t Camera::getRadianYaw()
84 84
 {
85 85
     return mTheta;
86 86
 }
87 87
 
88 88
 
89
-double Camera::getRadianPitch()
89
+vec_t Camera::getRadianPitch()
90 90
 {
91 91
     return mTheta2;
92 92
 }
@@ -100,9 +100,9 @@ void Camera::rotate(float angle, float x, float y, float z)
100 100
 {
101 101
     Quaternion t, n;
102 102
     Matrix matrix;
103
-    double side[4] = { 1, 0,  0, 1 };
104
-    double up[4] =   { 0, 1,  0, 1 };
105
-    double look[4] = { 0, 0, -1, 1 };
103
+    vec_t side[4] = { 1.0f, 0.0f,  0.0f, 1.0f };
104
+    vec_t up[4] =   { 0.0f, 1.0f,  0.0f, 1.0f };
105
+    vec_t look[4] = { 0.0f, 0.0f, -1.0f, 1.0f };
106 106
     unsigned int i;
107 107
     matrix_t m;
108 108
 
@@ -113,9 +113,9 @@ void Camera::rotate(float angle, float x, float y, float z)
113 113
 
114 114
     n.getMatrix(m);
115 115
     matrix.setMatrix(m);
116
-    matrix.multiply4d(side, mSide);
117
-    matrix.multiply4d(look, mTarget);
118
-    matrix.multiply4d(up, mUp);
116
+    matrix.multiply4v(side, mSide);
117
+    matrix.multiply4v(look, mTarget);
118
+    matrix.multiply4v(up, mUp);
119 119
 
120 120
     for (i = 0; i < 3; ++i)
121 121
     {
@@ -131,8 +131,8 @@ void Camera::rotate(float angle, float x, float y, float z)
131 131
 void Camera::translate(float x, float y, float z)
132 132
 {
133 133
     int i;
134
-    double result[4];
135
-    double v[4];
134
+    vec_t result[4];
135
+    vec_t v[4];
136 136
     matrix_t m;
137 137
     Matrix matrix;
138 138
 
@@ -160,7 +160,7 @@ void Camera::translate(float x, float y, float z)
160 160
     m[15] = 1;
161 161
 
162 162
     matrix.setMatrix(m);
163
-    matrix.multiply4d(v, result);
163
+    matrix.multiply4v(v, result);
164 164
 
165 165
     for (i = 0; i < 3; ++i)
166 166
     {
@@ -178,27 +178,27 @@ void Camera::translate(float x, float y, float z)
178 178
 
179 179
 void Camera::reset()
180 180
 {
181
-    mTheta = 0.0;
182
-    mTheta2 = 0.0;
181
+    mTheta = 0.0f;
182
+    mTheta2 = 0.0f;
183 183
 
184
-    mPos[0] = 0.0;
185
-    mPos[1] = 0.0;
186
-    mPos[2] = 0.0;
184
+    mPos[0] = 0.0f;
185
+    mPos[1] = 0.0f;
186
+    mPos[2] = 0.0f;
187 187
 
188
-    mTarget[0] = 0.0;
189
-    mTarget[1] = 0.0;
188
+    mTarget[0] = 0.0f;
189
+    mTarget[1] = 0.0f;
190 190
     mTarget[2] = mViewDistance;
191 191
 
192
-    mSide[0] = 1.0;
193
-    mSide[1] = 0.0;
194
-    mSide[2] = 0.0;
192
+    mSide[0] = 1.0f;
193
+    mSide[1] = 0.0f;
194
+    mSide[2] = 0.0f;
195 195
 
196
-    mUp[0] = 0.0;
197
-    mUp[1] = 1.0;
198
-    mUp[2] = 0.0;
196
+    mUp[0] = 0.0f;
197
+    mUp[1] = 1.0f;
198
+    mUp[2] = 0.0f;
199 199
 
200 200
     mQ.setIdentity();
201
-    translate(0.0, 0.0, 0.0);
201
+    translate(0.0f, 0.0f, 0.0f);
202 202
 }
203 203
 
204 204
 
@@ -222,63 +222,63 @@ void Camera::command(enum camera_command cmd)
222 222
         case CAMERA_MOVE_FORWARD:
223 223
             if (mFlags & Camera_FlyMode)
224 224
             {
225
-                mPos[2] += (mTranslateDelta * cos(mTheta));
225
+                mPos[2] += (mTranslateDelta * cosf(mTheta));
226 226
             }
227 227
 
228
-            mPos[0] += (mTranslateDelta * sin(mTheta));
229
-            mPos[1] += (mTranslateDelta * sin(mTheta2));
228
+            mPos[0] += (mTranslateDelta * sinf(mTheta));
229
+            mPos[1] += (mTranslateDelta * sinf(mTheta2));
230 230
             break;
231 231
         case CAMERA_MOVE_BACKWARD:
232 232
             if (mFlags & Camera_FlyMode)
233 233
             {
234
-                mPos[2] -= (mTranslateDelta * cos(mTheta));
234
+                mPos[2] -= (mTranslateDelta * cosf(mTheta));
235 235
             }
236 236
 
237
-            mPos[0] -= (mTranslateDelta * sin(mTheta));
238
-            mPos[1] -= (mTranslateDelta * sin(mTheta2));
237
+            mPos[0] -= (mTranslateDelta * sinf(mTheta));
238
+            mPos[1] -= (mTranslateDelta * sinf(mTheta2));
239 239
             break;
240 240
         case CAMERA_MOVE_LEFT:
241
-            mPos[0] -= (mTranslateDelta * sin(mTheta - 90.0f));
242
-            mPos[2] -= (mTranslateDelta * cos(mTheta - 90.0f));
241
+            mPos[0] -= (mTranslateDelta * sinf(mTheta - 90.0f));
242
+            mPos[2] -= (mTranslateDelta * cosf(mTheta - 90.0f));
243 243
             break;
244 244
         case CAMERA_MOVE_RIGHT:
245
-            mPos[0] -= (mTranslateDelta * sin(mTheta + 90.0f));
246
-            mPos[2] -= (mTranslateDelta * cos(mTheta + 90.0f));
245
+            mPos[0] -= (mTranslateDelta * sinf(mTheta + 90.0f));
246
+            mPos[2] -= (mTranslateDelta * cosf(mTheta + 90.0f));
247 247
             break;
248 248
         case CAMERA_ROTATE_UP:
249 249
             if (mTheta2 < (M_PI / 2)) {
250 250
                 mTheta2 += mRotateDelta2;
251
-                rotate(mTheta2, 1.0, 0.0, 0.0);
251
+                rotate(mTheta2, 1.0f, 0.0f, 0.0f);
252 252
             }
253 253
             break;
254 254
         case CAMERA_ROTATE_DOWN:
255 255
             if (mTheta2 > -(M_PI / 2)) {
256 256
                 mTheta2 -= mRotateDelta2;
257
-                rotate(mTheta2, 1.0, 0.0, 0.0);
257
+                rotate(mTheta2, 1.0f, 0.0f, 0.0f);
258 258
             }
259 259
             break;
260 260
         case CAMERA_ROTATE_RIGHT:
261 261
             mTheta += mRotateDelta;
262
-            rotate(mTheta, 0.0, 1.0, 0.0);
262
+            rotate(mTheta, 0.0f, 1.0f, 0.0f);
263 263
             break;
264 264
         case CAMERA_ROTATE_LEFT:
265 265
             mTheta -= mRotateDelta;
266
-            rotate(mTheta, 0.0, 1.0, 0.0);
266
+            rotate(mTheta, 0.0f, 1.0f, 0.0f);
267 267
             break;
268 268
         case CAMERA_MOVE_UP:
269
-            mPos[1] -= mTranslateDelta / 2.0;
270
-            mTarget[1] -= mTranslateDelta / 2.0;
269
+            mPos[1] -= mTranslateDelta / 2.0f;
270
+            mTarget[1] -= mTranslateDelta / 2.0f;
271 271
             break;
272 272
         case CAMERA_MOVE_DOWN:
273
-            mPos[1] += mTranslateDelta / 2.0;
274
-            mTarget[1] += mTranslateDelta / 2.0;
273
+            mPos[1] += mTranslateDelta / 2.0f;
274
+            mTarget[1] += mTranslateDelta / 2.0f;
275 275
             break;
276 276
         case CAMERA_SPEED_UP:
277 277
             ++mTranslateDelta;
278 278
             break;
279 279
         case CAMERA_SPEED_DOWN:
280
-            if (--mTranslateDelta < 0.0)
281
-                mTranslateDelta = 1.0;
280
+            if (--mTranslateDelta < 0.0f)
281
+                mTranslateDelta = 1.0f;
282 282
             break;
283 283
         default:
284 284
             ;
@@ -289,7 +289,7 @@ void Camera::command(enum camera_command cmd)
289 289
 //! \fixme Mostly invalid for QUAT_CAM (can rotate on XYZ)
290 290
 bool Camera::isBehind(int x, int z)
291 291
 {
292
-    double bTheta, bCameraX, bCameraZ, Distance;
292
+    vec_t bTheta, bCameraX, bCameraZ, Distance;
293 293
 
294 294
 
295 295
     // Set up a "virtual camera" a huge distance behind us
@@ -299,14 +299,14 @@ bool Camera::isBehind(int x, int z)
299 299
         bTheta -= HEL_2_PI;
300 300
 
301 301
     // 64k is a fair distance away...
302
-    bCameraX = (65536.0 * sin(bTheta)) + mPos[0];
303
-    bCameraZ = (65536.0 * cos(bTheta)) + mPos[2];
302
+    bCameraX = (65536.0f * sinf(bTheta)) + mPos[0];
303
+    bCameraZ = (65536.0f * cosf(bTheta)) + mPos[2];
304 304
 
305 305
     bCameraX -= x;
306 306
     bCameraZ -= z;
307
-    Distance = sqrt((bCameraX * bCameraX) + (bCameraZ * bCameraZ));
307
+    Distance = sqrtf((bCameraX * bCameraX) + (bCameraZ * bCameraZ));
308 308
 
309
-    return (Distance < 65536.0);
309
+    return (Distance < 65536.0f);
310 310
 }
311 311
 
312 312
 
@@ -318,9 +318,9 @@ void Camera::setSpeed(float s)
318 318
 
319 319
 void Camera::update()
320 320
 {
321
-    mTarget[2] = (mViewDistance * cos(mTheta)) + mPos[2];
322
-    mTarget[0] = (mViewDistance * sin(mTheta)) + mPos[0];
323
-    mTarget[1] = (mViewDistance * sin(mTheta2)) + mPos[1]; // + height_offset;
321
+    mTarget[2] = (mViewDistance * cosf(mTheta)) + mPos[2];
322
+    mTarget[0] = (mViewDistance * sinf(mTheta)) + mPos[0];
323
+    mTarget[1] = (mViewDistance * sinf(mTheta2)) + mPos[1]; // + height_offset;
324 324
 }
325 325
 
326 326
 

+ 4
- 4
src/Emitter.cpp View File

@@ -226,16 +226,16 @@ void Emitter::Draw() {
226 226
             // Render tristrip quad
227 227
             glBegin(GL_TRIANGLE_STRIP);
228 228
             glTexCoord2d(1.0, 1.0);
229
-            glVertex3f(x + 0.5, y + 0.5, z);
229
+            glVertex3f(x + 0.5f, y + 0.5f, z);
230 230
 
231 231
             glTexCoord2d(0.0, 1.0);
232
-            glVertex3f(x - 0.5, y + 0.5, z);
232
+            glVertex3f(x - 0.5f, y + 0.5f, z);
233 233
 
234 234
             glTexCoord2d(1.0, 0.0);
235
-            glVertex3f(x + 0.5, y - 0.5, z);
235
+            glVertex3f(x + 0.5f, y - 0.5f, z);
236 236
 
237 237
             glTexCoord2d(0.0, 0.0);
238
-            glVertex3f(x - 0.5, y - 0.5, z);
238
+            glVertex3f(x - 0.5f, y - 0.5f, z);
239 239
             glEnd();
240 240
 
241 241
             // Update particle's attributes for it's life cycle

+ 1
- 1
src/GLString.cpp View File

@@ -159,7 +159,7 @@ int GLString::glPrintf(int x, int y, const char *string, ...) {
159 159
     va_end(args);
160 160
 
161 161
     // Mongoose 2002.01.04, Remeber string size, for future rebuffering use
162
-    _string[_num_string].len = sz;
162
+    _string[_num_string].len = (unsigned short)sz;
163 163
 
164 164
     // Mongoose 2002.01.01, Incement string counter, since we just
165 165
     //   allocated a string

+ 10
- 10
src/MatMath.cpp View File

@@ -88,13 +88,13 @@ int helIntersectionOfAbstractSphereAndLine(vec3_t center, vec_t radius,
88 88
         // Two intersections
89 89
 
90 90
         // First intersection
91
-        mu = (-b + sqrt( square(b) - 4*a*c)) / (2*a);
91
+        mu = (-b + sqrtf( square(b) - 4.0f*a*c)) / (2.0f*a);
92 92
         intersectionA[1] = posA[0] + mu*(posB[0]-posA[0]);
93 93
         intersectionA[2] = posA[1] + mu*(posB[1]-posA[1]);
94 94
         intersectionA[3] = posA[2] + mu*(posB[2]-posA[2]);
95 95
 
96 96
         // Second intersection
97
-        mu = (-b - sqrt(square(b) - 4*a*c)) / (2*a);
97
+        mu = (-b - sqrtf(square(b) - 4.0f*a*c)) / (2.0f*a);
98 98
         intersectionB[0] = posA[0] + mu*(posB[0]-posA[0]);
99 99
         intersectionB[1] = posA[1] + mu*(posB[1]-posA[1]);
100 100
         intersectionB[2] = posA[2] + mu*(posB[2]-posA[2]);
@@ -235,7 +235,7 @@ vec_t helDistToBboxFromPlane3v(vec3_t min, vec3_t max, vec4_t plane)
235 235
 
236 236
 vec_t helDist3v(vec3_t a, vec3_t b)
237 237
 {
238
-    return (sqrt( ((b[0] - a[0]) * (b[0] - a[0])) +
238
+    return (sqrtf( ((b[0] - a[0]) * (b[0] - a[0])) +
239 239
                 ((b[1] - a[1]) * (b[1] - a[1])) +
240 240
                 ((b[2] - a[2]) * (b[2] - a[2]))));
241 241
 }
@@ -243,32 +243,32 @@ vec_t helDist3v(vec3_t a, vec3_t b)
243 243
 
244 244
 void helMidpoint3v(vec3_t a, vec3_t b, vec3_t mid)
245 245
 {
246
-    mid[0] = (a[0] + b[0]) / 2;
247
-    mid[1] = (a[1] + b[1]) / 2;
248
-    mid[2] = (a[2] + b[2]) / 2;
246
+    mid[0] = (a[0] + b[0]) / 2.0f;
247
+    mid[1] = (a[1] + b[1]) / 2.0f;
248
+    mid[2] = (a[2] + b[2]) / 2.0f;
249 249
 }
250 250
 
251 251
 
252 252
 vec_t helNorm4v(vec4_t v)
253 253
 {
254
-    return (sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2] + v[3]*v[3]));
254
+    return (sqrtf(v[0]*v[0] + v[1]*v[1] + v[2]*v[2] + v[3]*v[3]));
255 255
 }
256 256
 
257 257
 
258 258
 vec_t helNorm3v(vec3_t v)
259 259
 {
260
-    return (sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]));
260
+    return (sqrtf(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]));
261 261
 }
262 262
 
263 263
 
264 264
 vec_t helNorm2v(vec2_t v)
265 265
 {
266
-    return (sqrt(v[0]*v[0] + v[1]*v[1]));
266
+    return (sqrtf(v[0]*v[0] + v[1]*v[1]));
267 267
 }
268 268
 
269 269
 
270 270
 vec_t helRandomNum(vec_t from, vec_t to)
271 271
 {
272
-    return from + ((to - from) * rand() / (RAND_MAX + 1.0));
272
+    return from + ((to - from) * rand() / (RAND_MAX + 1.0f));
273 273
 }
274 274
 

+ 0
- 10
src/Matrix.cpp View File

@@ -214,16 +214,6 @@ void Matrix::multiply3v(vec3_t v, vec3_t result)
214 214
     result[2] = mMatrix[8]*x + mMatrix[9]*y + mMatrix[10]*z + mMatrix[11];
215 215
 }
216 216
 
217
-void Matrix::multiply4d(double *v, double *result)
218
-{
219
-    double x = v[0], y = v[1], z = v[2], w = v[3];
220
-
221
-    result[0] = mMatrix[ 0]*x + mMatrix[ 1]*y + mMatrix[ 2]*z + mMatrix[ 3]*w;
222
-    result[1] = mMatrix[ 4]*x + mMatrix[ 5]*y + mMatrix[ 6]*z + mMatrix[ 7]*w;
223
-    result[2] = mMatrix[ 8]*x + mMatrix[ 9]*y + mMatrix[10]*z + mMatrix[11]*w;
224
-    result[3] = mMatrix[12]*x + mMatrix[13]*y + mMatrix[14]*z + mMatrix[15]*w;
225
-}
226
-
227 217
 void Matrix::multiply4v(vec4_t v, vec4_t result)
228 218
 {
229 219
     vec_t x = v[0], y = v[1], z = v[2], w = v[3];

+ 7
- 11
src/Network.cpp View File

@@ -22,6 +22,8 @@
22 22
 #include <arpa/inet.h>
23 23
 #include <stdlib.h>
24 24
 
25
+#include <MatMath.h> // Random Number
26
+
25 27
 //#define LOCAL_BCAST
26 28
 #define MAX_CLIENTS 32
27 29
 
@@ -126,17 +128,11 @@ unsigned int Network::getUID()
126 128
 
127 129
     srand(tv.tv_usec);
128 130
 
129
-    return ((unsigned int)(tv.tv_sec * getRandom(2.0, 3.3) -
130
-                tv.tv_sec * getRandom(1.0, 2.0)) +
131
-            (unsigned int)(tv.tv_usec * getRandom(2.0, 3.3) -
132
-                tv.tv_usec * getRandom(1.0, 2.0)) +
133
-            (unsigned int)getRandom(666.0, 5000.0));
134
-}
135
-
136
-
137
-float Network::getRandom(float from, float to)
138
-{
139
-    return from + (to*rand()/(RAND_MAX+1.0));
131
+    return ((unsigned int)(tv.tv_sec * helRandomNum(2.0f, 3.3f) -
132
+                tv.tv_sec * helRandomNum(1.0f, 2.0f)) +
133
+            (unsigned int)(tv.tv_usec * helRandomNum(2.0f, 3.3f) -
134
+                tv.tv_usec * helRandomNum(1.0f, 2.0f)) +
135
+            (unsigned int)helRandomNum(666.0f, 5000.0f));
140 136
 }
141 137
 
142 138
 

+ 8
- 8
src/Texture.cpp View File

@@ -448,13 +448,13 @@ ttf_texture_t *Texture::generateFontTexture(const char *filename, int pointSize,
448 448
 
449 449
     for (i = 0; i < count; ++i)
450 450
     {
451
-        glyph = TTF_RenderGlyph_Blended(font, i + utf8Offset, sdlColor);
451
+        glyph = TTF_RenderGlyph_Blended(font, (Uint16)(i + utf8Offset), sdlColor);
452 452
 
453 453
         if (glyph)
454 454
         {
455 455
             image = (unsigned char*)glyph->pixels;
456 456
 
457
-            TTF_GlyphMetrics(font, i + utf8Offset,
457
+            TTF_GlyphMetrics(font, (Uint16)(i + utf8Offset),
458 458
                     &texture->glyphs[i].minx, &texture->glyphs[i].maxx,
459 459
                     &texture->glyphs[i].miny, &texture->glyphs[i].maxy,
460 460
                     &texture->glyphs[i].advance);
@@ -886,15 +886,15 @@ void Texture::glScreenShot(char *base, unsigned int width, unsigned int height)
886 886
 
887 887
     delete [] swap_row;
888 888
 
889
-    comment_lenght = strlen(comment);
889
+    comment_lenght = (unsigned char)strlen(comment);
890 890
     colormap_type = 0;
891 891
     image_type = 2;
892 892
     colormap_index = 0;
893 893
     colormap_lenght = 0;
894 894
     colormap_bbp = 0;
895 895
     origin_x = origin_y = 0;
896
-    swidth = width;
897
-    sheight = height;
896
+    swidth = (unsigned short)width;
897
+    sheight = (unsigned short)height;
898 898
     bpp = 24;
899 899
     desc_flags = 32;
900 900
 
@@ -1133,9 +1133,9 @@ unsigned char *Texture::scaleBuffer(unsigned char *image,
1133 1133
 
1134 1134
                 for (k = 0; k < components; ++k)
1135 1135
                 {
1136
-                    s1 = *src00++ * (1.0 - beta) + *src01++ * beta;
1137
-                    s2 = *src10++ * (1.0 - beta) + *src11++ * beta;
1138
-                    *dst++ = s1 * (1.0 - alpha) + s2 * alpha;
1136
+                    s1 = *src00++ * (1.0f - beta) + *src01++ * beta;
1137
+                    s2 = *src10++ * (1.0f - beta) + *src11++ * beta;
1138
+                    *dst++ = s1 * (1.0f - alpha) + s2 * alpha;
1139 1139
                 }
1140 1140
             }
1141 1141
         }

Loading…
Cancel
Save