changeset 2376 | ece7b87f1334 |
parent 2372 | f3e7a066c2b8 |
child 2382 | bfd378dfc4e7 |
2375:99f05a01a6a3 | 2376:ece7b87f1334 |
---|---|
358 begin |
358 begin |
359 new(Surface2Tex); |
359 new(Surface2Tex); |
360 Surface2Tex^.w:= surf^.w; |
360 Surface2Tex^.w:= surf^.w; |
361 Surface2Tex^.h:= surf^.h; |
361 Surface2Tex^.h:= surf^.h; |
362 |
362 |
363 if (surf^.format^.BytesPerPixel = 3) then |
363 if (surf^.format^.BytesPerPixel = 3) then |
364 begin |
364 begin |
365 modeIntFormat:= GL_RGB; |
365 modeIntFormat:= GL_RGB; |
366 modeFormat:= modeIntFormat; |
366 modeFormat:= modeIntFormat; |
367 end |
367 end |
368 else |
368 else |
390 tw:= toPowerOf2(Surf^.w); |
390 tw:= toPowerOf2(Surf^.w); |
391 th:= toPowerOf2(Surf^.h); |
391 th:= toPowerOf2(Surf^.h); |
392 |
392 |
393 Surface2Tex^.rx:= Surf^.w / tw; |
393 Surface2Tex^.rx:= Surf^.w / tw; |
394 Surface2Tex^.ry:= Surf^.h / th; |
394 Surface2Tex^.ry:= Surf^.h / th; |
395 |
395 |
396 GetMem(tmpp, tw * th * surf^.format^.BytesPerPixel); |
396 GetMem(tmpp, tw * th * surf^.format^.BytesPerPixel); |
397 |
397 |
398 if surf^.format^.BytesPerPixel = 4 then |
398 if surf^.format^.BytesPerPixel = 4 then |
399 begin |
399 begin |
400 fromP4:= Surf^.pixels; |
400 fromP4:= Surf^.pixels; |
452 end; |
452 end; |
453 end; |
453 end; |
454 |
454 |
455 // legacy resizing function |
455 // legacy resizing function |
456 // gluScaleImage(mode, Surf^.w, Surf^.h, GL_UNSIGNED_BYTE, Surf^.pixels, tw, th, GL_UNSIGNED_BYTE, tmpp); |
456 // gluScaleImage(mode, Surf^.w, Surf^.h, GL_UNSIGNED_BYTE, Surf^.pixels, tw, th, GL_UNSIGNED_BYTE, tmpp); |
457 |
457 |
458 glTexImage2D(GL_TEXTURE_2D, 0, modeIntFormat, tw, th, 0, modeFormat, GL_UNSIGNED_BYTE, tmpp); |
458 glTexImage2D(GL_TEXTURE_2D, 0, modeIntFormat, tw, th, 0, modeFormat, GL_UNSIGNED_BYTE, tmpp); |
459 |
459 |
460 FreeMem(tmpp, tw * th * surf^.format^.BytesPerPixel) |
460 FreeMem(tmpp, tw * th * surf^.format^.BytesPerPixel) |
461 end else |
461 end else |
462 begin |
462 begin |
463 Surface2Tex^.rx:= 1.0; |
463 Surface2Tex^.rx:= 1.0; |
464 Surface2Tex^.ry:= 1.0; |
464 Surface2Tex^.ry:= 1.0; |