Iv come up with the following code to draw from a Texture Atlas to a face, but it draws what looks like a border around the face using parts of the texture which are lying outside of the area i told OpenGL to draw from.
// Input is the standard texture coordinates (For rendering the whole texture on the surface)
Code:
function TTextureSurface.BuildTexCoord(BaseX,BaseY : Double) : TVec2d; begin Result := SetVec2d(BaseX,BaseY);
if not Assigned(FTexture) then Exit;
Result[0] := Result[0]*((16)/FTexture.GetActualWidth); //16x16 is the size of the individual texture on the Atlas Result[1] := Result[1]*((16)/FTexture.GetActualHeight);
If i reduce the size of the area OpenGL is taking the image from it does "Fix" the problem, but i was wondering if there was a better solution than not rendering part of the image.
Maybe you need to use just "FXPos" instead of "16*FXPos", depending what FXPos exactly is.
Zitat:
but it draws what looks like a border around the face using parts of the texture which are lying outside of the area i told OpenGL to draw from.
In any way you will need a border around each image. Especially when using mipmaps, because then the image gets scaled down and the colors are mixed. However, because your local textures are size power of two (16) it might work even with mipmaps.
Edit: You might also want to try to clamp locale localTexelCoord to range 0....localTextureSize-1.
The 0.5's cancel each other out in your code. FXPos is the X Position and FYPos is the Y Position(In Pixels). Multiplying it by 16 would make it an invalid coordinate.
Zitat:
In any way you will need a border around each image.
I can't modify the image. Its from a game, my app loads the levels of the game. So that its compatible with future updates to the game (And its textures) i can't make my own textures. Game doesn't suffer from the border problem and it uses OpenGL. Mipmaps arn't a problem as im not using any (Textures are 8bit style, so im just using GL_NEAREST)
Mitglieder in diesem Forum: 0 Mitglieder und 2 Gäste
Du darfst keine neuen Themen in diesem Forum erstellen. Du darfst keine Antworten zu Themen in diesem Forum erstellen. Du darfst deine Beiträge in diesem Forum nicht ändern. Du darfst deine Beiträge in diesem Forum nicht löschen. Du darfst keine Dateianhänge in diesem Forum erstellen.