Still working on the Sudoku game adding in menu options and custimizable backgrounds (ect). I added all the menu items into the game using a sprite sheet just so I could get used to texture mapping different sized shapes (I figured this was going to be important when I started having high poly count objects in a game, and this was a experiment to get around the power of 2 restriction.. accessing a part of the picture that isn't in a power of 2 while the picture itself is). Everything seems to work all right but I do get some white lines in the texture map (because the items are surrounded by white lines to fix this I changed the lines to black since the objects blended to black).
Important note: These are squares I'm working with.. I wanted to get them right before I switched to using two triangles.
While its an acceptable solution for this situation I would rather understand why I wasn't fully acurate.
How I approached this problem.
I use paint to make all my textures (cause I'm broke), and therefore used pixel reference points to where the map will start and where it will stop. Given I know a picture 1024/1024 will have a conversion rate to the float texture map points. This conversion rate can be calculated as.
conversionratio = maxtexture(1.0f)/maxpixels(1024)
Then I used that conversion ratio to map the texture having a function
Since width and height can calculate the bottomrightx and y texture coordinates.Code:Object.SetTexCoords(topleftx, toplefty, w, h);
To get the values of topleftx, toplefty, w and h converted from its pixel values which are easy to find in microsoft paint i used
Is my inacuracy because I'm using floats and the ratio of 1024 to 1 becomes a long decimal? Should I maybe use doubles, or smaller pictures possibly no larger than 256?Code:topleftx = topleftxpixel * conversionratio; toplefty = 1.0f - (topleftypixel * conversionratio); // because the top of a picture in pixels is 0, and in textures its 1.0f so I had // to swap the directions hence the 1.0f - (number); w = pixelw * conversionratio; h = pixelh * conversionratio;
Is my method itself internally flawed in a way that anyone notices?
Thanks again for your time.