What is happening here?

Started by
1 comment, last by CirdanValen 11 years, 11 months ago
EDIT: Nvm, this isn't the problem.

Gotta love it when a piece of simple and unrelated code stops working for absolutely no reason. angry.png

// Store the image sizes
mHeight = surface->h;
mWidth = surface->w;


I haven't touched this file all day, and it decided to start giving me problems for no reason. The "surface" variable is an SDL_Surface. I set a breakpoint right after these two lines and surface is an object, and both h and w have valid and expected values. mHeight stores the h value as expected. mWidth does not store the value at all. If I swap the two lines, the same problem occurs to the second line of code.

Would the disassembly help?
13: mWidth = 0;
002219C7 fldz
002219C9 push ebx
002219CA fst dword ptr [esi+4]
14: mHeight = 0;
002219CD fstp dword ptr [esi+8]
...
37:
38: // Store the image sizes
39: mHeight = surface->h;
00221A19 fild dword ptr [eax+0Ch] // Convert h to a float and store it on the stack
00221A1C lea ecx,[eax+0Ch] // store the address of our converted h value into the ecx register
00221A1F push edi // Push whatever is in the edi register onto the stack?
40: mWidth = surface->w;
00221A20 add eax,8 // Add 8 to the eax register? I.E. point eax to the w variable?
00221A23 fstp dword ptr [esi+8] // "copy the value on the top of the floating point register stack to ... another variable"
41:


(I did do Windows updates last night, did the VS Service Pack 1 break something?)
Advertisement
It's unlikely that the SP broke anything; what is more likely is that the original code never worked properly in the first place, but somehow managed to get the correct result owing to a compiler and/or linker bug that has since been fixed by the SP.

If code in a completely unrelated place starts breaking the first thing to look at is memory corruption. You probably have a bad pointer somewhere else and are scribbling over this memory.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

Thanks for the reply. The problem isn't those variables. VS debugger seems to try and hide as much information as it can from me, so the only way I can really debug is to cout all the values I need to check.

My problem is, I'm drawing sprites to a RenderTexture. However, the whole RenderTexture becomes the color of the very first pixel. I can't figure it out because I know both the sprite and the RenderTexture are working correctly in other areas of the code.

EDIT: Solved the problem dry.png I have no idea what it is about writing forum posts that make me magically realize the problem.

This topic is closed to new replies.

Advertisement