strip blitting + image offsets == trouble

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
Zettablade
Posts: 71
Joined: Fri May 05, 2006 5:59 pm

strip blitting + image offsets == trouble

Post by Zettablade »

For some reason, my blitting function isn't working. It doesn't resize properly when I change the width or height, and I get weird results when the offsets are changed. Anyone know what I'm doing wrong?

Code: Select all

void drawImageFast(float x, float y, float width, float height, float u0, float u1, float v0, float v1, IMAGE *img)
{
	float ii = 0;
	short slice = 32;

	sceGuTexImage(0,img->realWidth,img->realHeight,img->realWidth,(void*)img->data);
	
	for&#40;i = 0; ii < u1; ii += slice&#41; &#123;
		VertexUV* vertices = &#40;VertexUV*&#41;sceGuGetMemory&#40;2 * sizeof&#40;VertexUV&#41;&#41;;

		slice = 32;

		if &#40;ii + slice > u1&#41; slice = width - ii;

		vertices&#91;0&#93;.u = u0 + ii;
		vertices&#91;0&#93;.v = v0;
		vertices&#91;0&#93;.x = x + ii;
		vertices&#91;0&#93;.y = y;

		vertices&#91;1&#93;.u = u0 + ii + slice;
		vertices&#91;1&#93;.v = v0 + v1;
		vertices&#91;1&#93;.x = x + ii + slice;
		vertices&#91;1&#93;.y = y + height;
		
		sceGuDrawArray&#40;GU_SPRITES, GU_TEXTURE_32BITF|GU_VERTEX_32BITF|GU_TRANSFORM_2D, 2, 0, vertices&#41;;
	&#125;
&#125;
hlide
Posts: 739
Joined: Sun Sep 10, 2006 2:31 am

Post by hlide »

I can read in /pspsdk/gu/doc/commands.txt :
Floats processed in the command-stream are 24 bits instead of 32 that are
used by the CPU. Conversion from 32 to 24 bits is done by shifting the
value down 8 bits, losing the least significant bits of the mantissa.
if it does so and have 256.0 as a float value, would it be converted into 1.0 because of losing the least significant bits of the mantissa !?

Well, I'm totaly new with GU but I hope you will find your error and share your solution :)
Post Reply