Ok thanks CuteAlien.
I understand about the priorities. No rush.
Later when I know more what I'm doing I will try to help with tracker items.
CuteAlien wrote:Still I guess in this case the question is most likely if any of the drawing functions should really get another parameter (as soon as you get above 5 parameters you should think _really_ hard about that) or if it wouldn't be possible to make rotations easier by adding an extra rotation state-function which then would work with _all_ drawing functions.
Personally, I think that making a rotation state variable would be worse, and a function that sets a rotation matrix or that does anything would really be wasted effort.
It would mean that you must set the rotation for every individual object before drawing it, even if the object rotation is 0. Objects normally have no rotation and if there is rotation, each rotation could be different so you just need to set it every time.
Adding the extra rotation state does not make it easier.
Created 1 new draw2DImage function
In my latest patch I made a new draw2DImage function that has the rotation as the 2nd parameter (before the destRect). I use the destRect to scale the image at the same time.
The function works by rotating the sourceRect of the image, and then scaling it up by the ratio of the destRect (size) divided by the sourceRect (size). It draws the center of the new rotated and scaled image to the center of the destRect.
Created 3 new functions in IImage
copyToScaling : copies part of the image and scales that part, putting the result in the target parameter.
createScaledImage : copies part of the image and scales it, returning the resulting image.
createRotatedImage : copies part of the image and rotates it, returning the resulting image.
Modified two createImage functions in IVideoDriver/CNullDriver
They can now take a rotation parameter which is 0 by default, so it doesn't break the engine.
The draw2DImage functions are near complete.
OpenGL and DirectX versions are working perfectly as far as I have tested them.
I need some help with my new createRotatedImage function in IImage.
I have been busting my brain all over the place trying to get it to work properly.
I don't understand translation well enough to see my flaws.
There are minor rounding errors.
When I de-transform to find the source coordinate from the destination coordinate, I don't get an exact 1-1 mapping. I can't tell by looking, but it's as if some pixels round up when they should round down, and vice versa. It is evident around the border where you see the erratic pixel step.
I have searched the net and tried various methods. None of them seem to work exactly, except when they are using openGL, directX or .NET classes to do the drawing. Is it something to do with using float tcoords?
I don't understand that yet.
Can anyone provide some insight or references?
P.S. I have tried transforming the pixels from the source to the destination, but this leaves gaps everywhere in the destination. I have also read many times that it cannot be done this way. Everyone seems to reverse translate from the destination to find the relative source pixel.
**EDIT**
I have discovered a fundamental flaw in my code. Fixing this may fix everything. I messed up the rectangles for the textures, and the way they relate to image size. I had mix ups all over the place so I'm just fixing them all now. I wasn't even drawing the boundary in the correct place.