equal
deleted
inserted
replaced
207 var |
207 var |
208 x0, y0, x1, y1, tmp: Real; |
208 x0, y0, x1, y1, tmp: Real; |
209 w, h, aw, ah: LongInt; |
209 w, h, aw, ah: LongInt; |
210 p: PChar; |
210 p: PChar; |
211 const |
211 const |
212 texelOffset = 0.0; |
212 texelOffsetPos = 0.5; |
|
213 texelOffsetNeg = 0.0; |
213 begin |
214 begin |
214 aw:=texture^.atlas^.w; |
215 aw:=texture^.atlas^.w; |
215 ah:=texture^.atlas^.h; |
216 ah:=texture^.atlas^.h; |
216 |
217 |
217 if texture^.isRotated then |
218 if texture^.isRotated then |
222 begin |
223 begin |
223 w:=r^.w; |
224 w:=r^.w; |
224 h:=r^.h; |
225 h:=r^.h; |
225 end; |
226 end; |
226 |
227 |
227 x0:= (texture^.x + {r^.x} + texelOffset)/aw; |
228 x0:= (texture^.x + {r^.x} + texelOffsetPos)/aw; |
228 x1:= (texture^.x + {r^.x} + w - texelOffset)/aw; |
229 x1:= (texture^.x + {r^.x} + w + texelOffsetNeg)/aw; |
229 y0:= (texture^.y + {r^.y} + texelOffset)/ah; |
230 y0:= (texture^.y + {r^.y} + texelOffsetPos)/ah; |
230 y1:= (texture^.y + {r^.y} + h - texelOffset)/ah; |
231 y1:= (texture^.y + {r^.y} + h + texelOffsetNeg)/ah; |
231 |
232 |
232 if (texture^.isRotated) then |
233 if (texture^.isRotated) then |
233 begin |
234 begin |
234 tb^[0].X:= x0; |
235 tb^[0].X:= x0; |
235 tb^[0].Y:= y0; |
236 tb^[0].Y:= y0; |
251 tb^[3].Y:= y1; |
252 tb^[3].Y:= y1; |
252 end; |
253 end; |
253 end; |
254 end; |
254 |
255 |
255 procedure ResetVertexArrays(texture: PTexture); |
256 procedure ResetVertexArrays(texture: PTexture); |
256 var r: TSDL_Rect; |
257 var |
257 begin |
258 rect: TSDL_Rect; |
|
259 l, t, r, b: Real; |
|
260 const |
|
261 halfTexelOffsetPos = 1.0; |
|
262 halfTexelOffsetNeg = -0.0; |
|
263 begin |
|
264 l:= texture^.cropInfo.l + halfTexelOffsetPos; |
|
265 r:= texture^.cropInfo.l + texture^.w + halfTexelOffsetNeg; |
|
266 t:= texture^.cropInfo.t + halfTexelOffsetPos; |
|
267 b:= texture^.cropInfo.t + texture^.h + halfTexelOffsetNeg; |
|
268 |
258 with texture^ do |
269 with texture^ do |
259 begin |
270 begin |
260 vb[0].X:= texture^.cropInfo.l; |
271 vb[0].X:= l; |
261 vb[0].Y:= texture^.cropInfo.t; |
272 vb[0].Y:= t; |
262 vb[1].X:= texture^.cropInfo.l + w; |
273 vb[1].X:= r; |
263 vb[1].Y:= texture^.cropInfo.t; |
274 vb[1].Y:= t; |
264 vb[2].X:= texture^.cropInfo.l + w; |
275 vb[2].X:= r; |
265 vb[2].Y:= texture^.cropInfo.t + h; |
276 vb[2].Y:= b; |
266 vb[3].X:= texture^.cropInfo.l; |
277 vb[3].X:= l; |
267 vb[3].Y:= texture^.cropInfo.t + h; |
278 vb[3].Y:= b; |
268 end; |
279 end; |
269 |
280 |
270 r.x:= 0; |
281 rect.x:= 0; |
271 r.y:= 0; |
282 rect.y:= 0; |
272 r.w:= texture^.w; |
283 rect.w:= texture^.w; |
273 r.h:= texture^.h; |
284 rect.h:= texture^.h; |
274 ComputeTexcoords(texture, @r, @texture^.tb); |
285 ComputeTexcoords(texture, @rect, @texture^.tb); |
275 end; |
286 end; |
276 |
287 |
277 function NewTexture(width, height: Longword; buf: Pointer): PTexture; |
288 function NewTexture(width, height: Longword; buf: Pointer): PTexture; |
278 begin |
289 begin |
279 new(NewTexture); |
290 new(NewTexture); |
401 Surface2Atlas^.nextFrame:= nil; |
412 Surface2Atlas^.nextFrame:= nil; |
402 Surface2Atlas^.cropInfo:= cropInfo; |
413 Surface2Atlas^.cropInfo:= cropInfo; |
403 exit; |
414 exit; |
404 end; |
415 end; |
405 |
416 |
406 if (surf^.w <= 512) and (surf^.h <= 512) then |
417 //if (surf^.w <= 512) and (surf^.h <= 512) then |
|
418 // nothing should use the old codepath anymore once we are done! |
407 begin |
419 begin |
408 Surface2Atlas:= Surface2Tex_(surf, enableClamp); // run the atlas side by side for debugging |
420 Surface2Atlas:= Surface2Tex_(surf, enableClamp); // run the atlas side by side for debugging |
409 Surface2Atlas^.cropInfo:= cropInfo; |
421 Surface2Atlas^.cropInfo:= cropInfo; |
410 ResetVertexArrays(Surface2Atlas); |
422 ResetVertexArrays(Surface2Atlas); |
411 exit; |
423 exit; |