PasSFML
PasSFML copied to clipboard
Textures not working with TSfmlVertexArray
I have written a small FPC project which attempted to load a texture into a TVertexArray and display it, along with a couple other reference graphics. I have a TCircleShape with a texture that displays just fine and a TVertexArray with colors on the vertices which displays very well. However, the textured vertex array does not. I made sure that the VA would display without the texture very simply by removing the pointer to the Render State in the Draw command. It shows just fine with a color, but nothing is displayed with a texture. I have also played with the texture coordinates on the vertices, thinking that maybe I should define a standard rectangle instead of texture coordinates that mimic the shape of the VA.
Code and a snapshot of the running code with the reference texture file (in Gimp) are attached. Sadly, the lpr file had to be given a TXT extension in order to attach. To keep the attachments under control, I did not include the SFML dll files and the Arial font file. All the code resides in just the lpr file. I am currently using Lazarus 1.6 on a Windows 10 machine. The project is configured to be a Win64 exe and -WG is turned on.
I would really like to find out that this is just a simple coding issue, but I have been playing with this for a while, getting nowhere and finding nothing online about it. Any and all help will be greatly appreciated.
Texture:
Snapshot:
Code: textureloadtest.lpr.txt
Update: From what I've seen, the methods which utilize a ^TSfmlRenderStates parameter do not show the associated render target with a texture applied.
In one instance, I created a TSfmlConvexShape and was able to show the shape with a texture by assigning a Texture to the shape, as in:
CxShp1.SetTexture(tex.Handle, False);
If, however, I were to use the DrawConvexShape method, I cannot get the shape to appear with a texture. This also implies that I cannot alter blend modes or apply Shaders via the RenderStates object.
What this also unfortunately means is that I will need to load many more textures for my objects, rather than just creating references to different parts of a texture via the RenderStates object. Bummer. I really wanted to use FPC and SFML together.
IF I find the time, I may look into the interface. Things like changing the C++ BlendModes class into a Pascal Record leave me thinking there are changes which I haven't found which contribute to the problem I am seeing.