Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Draw GUI images cleanup.

  • Loading branch information...
commit 97ef0aee1bfd458ac563d6a024d11963df34cd70 1 parent 6ed3ad8
Per Inge Mathisen perim authored

Showing 1 changed file with 32 additions and 36 deletions. Show diff stats Hide diff stats

  1. +32 36 lib/ivis_opengl/pieblitfunc.cpp
68 lib/ivis_opengl/pieblitfunc.cpp
@@ -60,12 +60,6 @@ struct PIERECT ///< Screen rectangle.
60 60 {
61 61 SWORD x, y, w, h;
62 62 };
63   -struct PIEIMAGE ///< An area of texture.
64   -{
65   - SDWORD texPage;
66   - SWORD tu, tv, tw, th;
67   - float invTextureSize;
68   -};
69 63
70 64 /***************************************************************************/
71 65 /*
@@ -197,35 +191,37 @@ static bool assertValidImage(IMAGEFILE *imageFile, unsigned id)
197 191 return true;
198 192 }
199 193
200   -static void pie_DrawImage(const PIEIMAGE *image, const PIERECT *dest, PIELIGHT colour = WZCOL_WHITE)
  194 +static void pie_DrawImage(IMAGEFILE *imageFile, int id, Vector2i size, const PIERECT *dest, PIELIGHT colour = WZCOL_WHITE)
201 195 {
202   - pie_SetTexturePage(image->texPage);
  196 + ImageDef const &image2 = imageFile->imageDefs[id];
  197 + GLuint texPage = imageFile->pages[image2.TPageID].id;
  198 + GLfloat invTextureSize = 1.f / imageFile->pages[image2.TPageID].size;
  199 + int tu = image2.Tu;
  200 + int tv = image2.Tv;
  201 +
  202 + pie_SetTexturePage(texPage);
203 203 glColor4ubv(colour.vector);
204 204 glBegin(GL_TRIANGLE_STRIP);
205   - glTexCoord2f(image->tu * image->invTextureSize, image->tv * image->invTextureSize);
  205 + glTexCoord2f(tu * invTextureSize, tv * invTextureSize);
206 206 glVertex2f(dest->x, dest->y);
207 207
208   - glTexCoord2f((image->tu + image->tw) * image->invTextureSize, image->tv * image->invTextureSize);
  208 + glTexCoord2f((tu + size.x) * invTextureSize, tv * invTextureSize);
209 209 glVertex2f(dest->x + dest->w, dest->y);
210 210
211   - glTexCoord2f(image->tu * image->invTextureSize, (image->tv + image->th) * image->invTextureSize);
  211 + glTexCoord2f(tu * invTextureSize, (tv + size.y) * invTextureSize);
212 212 glVertex2f(dest->x, dest->y + dest->h);
213 213
214   - glTexCoord2f((image->tu + image->tw) * image->invTextureSize, (image->tv + image->th) * image->invTextureSize);
  214 + glTexCoord2f((tu + size.x) * invTextureSize, (tv + size.y) * invTextureSize);
215 215 glVertex2f(dest->x + dest->w, dest->y + dest->h);
216 216 glEnd();
217 217 }
218 218
219   -static PIEIMAGE makePieImage(IMAGEFILE *imageFile, unsigned id, PIERECT *dest = NULL, int x = 0, int y = 0)
  219 +static Vector2i makePieImage(IMAGEFILE *imageFile, unsigned id, PIERECT *dest = NULL, int x = 0, int y = 0)
220 220 {
221 221 ImageDef const &image = imageFile->imageDefs[id];
222   - PIEIMAGE pieImage;
223   - pieImage.texPage = imageFile->pages[image.TPageID].id;
224   - pieImage.invTextureSize = 1.f / imageFile->pages[image.TPageID].size;
225   - pieImage.tu = image.Tu;
226   - pieImage.tv = image.Tv;
227   - pieImage.tw = image.Width;
228   - pieImage.th = image.Height;
  222 + Vector2i pieImage;
  223 + pieImage.x = image.Width;
  224 + pieImage.y = image.Height;
229 225 if (dest != NULL)
230 226 {
231 227 dest->x = x + image.XOffset;
@@ -244,12 +240,12 @@ void iV_DrawImage(IMAGEFILE *ImageFile, UWORD ID, int x, int y)
244 240 }
245 241
246 242 PIERECT dest;
247   - PIEIMAGE pieImage = makePieImage(ImageFile, ID, &dest, x, y);
  243 + Vector2i pieImage = makePieImage(ImageFile, ID, &dest, x, y);
248 244
249 245 pie_SetRendMode(REND_ALPHA);
250 246 pie_SetAlphaTest(true);
251 247
252   - pie_DrawImage(&pieImage, &dest);
  248 + pie_DrawImage(ImageFile, ID, pieImage, &dest);
253 249 }
254 250
255 251 void iV_DrawImageTc(Image image, Image imageTc, int x, int y, PIELIGHT colour)
@@ -260,14 +256,14 @@ void iV_DrawImageTc(Image image, Image imageTc, int x, int y, PIELIGHT colour)
260 256 }
261 257
262 258 PIERECT dest;
263   - PIEIMAGE pieImage = makePieImage(image.images, image.id, &dest, x, y);
264   - PIEIMAGE pieImageTc = makePieImage(imageTc.images, imageTc.id);
  259 + Vector2i pieImage = makePieImage(image.images, image.id, &dest, x, y);
  260 + Vector2i pieImageTc = makePieImage(imageTc.images, imageTc.id);
265 261
266 262 pie_SetRendMode(REND_ALPHA);
267 263 pie_SetAlphaTest(true);
268 264
269   - pie_DrawImage(&pieImage, &dest);
270   - pie_DrawImage(&pieImageTc, &dest, colour);
  265 + pie_DrawImage(image.images, image.id, pieImage, &dest);
  266 + pie_DrawImage(imageTc.images, imageTc.id, pieImageTc, &dest, colour);
271 267 }
272 268
273 269 // Repeat a texture
@@ -282,22 +278,22 @@ void iV_DrawImageRepeatX(IMAGEFILE *ImageFile, UWORD ID, int x, int y, int Width
282 278 pie_SetAlphaTest(true);
283 279
284 280 PIERECT dest;
285   - PIEIMAGE pieImage = makePieImage(ImageFile, ID, &dest, x, y);
  281 + Vector2i pieImage = makePieImage(ImageFile, ID, &dest, x, y);
286 282
287 283 hRemainder = Width % Image->Width;
288 284
289 285 for (hRep = 0; hRep < Width / Image->Width; hRep++)
290 286 {
291   - pie_DrawImage(&pieImage, &dest);
  287 + pie_DrawImage(ImageFile, ID, pieImage, &dest);
292 288 dest.x += Image->Width;
293 289 }
294 290
295 291 // draw remainder
296 292 if (hRemainder > 0)
297 293 {
298   - pieImage.tw = hRemainder;
  294 + pieImage.x = hRemainder;
299 295 dest.w = hRemainder;
300   - pie_DrawImage(&pieImage, &dest);
  296 + pie_DrawImage(ImageFile, ID, pieImage, &dest);
301 297 }
302 298 }
303 299
@@ -312,22 +308,22 @@ void iV_DrawImageRepeatY(IMAGEFILE *ImageFile, UWORD ID, int x, int y, int Heigh
312 308 pie_SetAlphaTest(true);
313 309
314 310 PIERECT dest;
315   - PIEIMAGE pieImage = makePieImage(ImageFile, ID, &dest, x, y);
  311 + Vector2i pieImage = makePieImage(ImageFile, ID, &dest, x, y);
316 312
317 313 vRemainder = Height % Image->Height;
318 314
319 315 for (vRep = 0; vRep < Height / Image->Height; vRep++)
320 316 {
321   - pie_DrawImage(&pieImage, &dest);
  317 + pie_DrawImage(ImageFile, ID, pieImage, &dest);
322 318 dest.y += Image->Height;
323 319 }
324 320
325 321 // draw remainder
326 322 if (vRemainder > 0)
327 323 {
328   - pieImage.th = vRemainder;
  324 + pieImage.y = vRemainder;
329 325 dest.h = vRemainder;
330   - pie_DrawImage(&pieImage, &dest);
  326 + pie_DrawImage(ImageFile, ID, pieImage, &dest);
331 327 }
332 328 }
333 329
@@ -339,14 +335,14 @@ void iV_DrawImageScaled(IMAGEFILE *ImageFile, UWORD ID, int x, int y, int w, int
339 335 }
340 336
341 337 PIERECT dest;
342   - PIEIMAGE pieImage = makePieImage(ImageFile, ID, &dest, x, y);
  338 + Vector2i pieImage = makePieImage(ImageFile, ID, &dest, x, y);
343 339 dest.w = w;
344 340 dest.h = h;
345 341
346 342 pie_SetRendMode(REND_ALPHA);
347 343 pie_SetAlphaTest(true);
348 344
349   - pie_DrawImage(&pieImage, &dest);
  345 + pie_DrawImage(ImageFile, ID, pieImage, &dest);
350 346 }
351 347
352 348 /* FIXME: WTF is this supposed to do? Looks like some other functionality

0 comments on commit 97ef0ae

Please sign in to comment.
Something went wrong with that request. Please try again.