question

Chris Smith avatar image
0 Likes"
Chris Smith asked Chris Smith commented

How do I add a texture to a mesh when using the mesh API

I have been unable to figure out how to add a texture to a mesh when using the mesh API. I assume adding a texture is possible as it is my understanding that the mesh API is used for drawing conveyor objects.

The mesh I am drawing is being drawn and shows the correct ambient and diffuse colors if I use fglDisable(GL_TEXTURE_2D). The example in the following question seems to use that to disable the texture rendering to display those colors:

https://answers.flexsim.com/questions/46673/how-to-use-mesh-api.html

I have tried using bindtexture, but it doesn't seem to display the provided texture. If anyone has any examples or tips on how to get the texture to show, then that would be appreciated.

FlexSim 18.2.2
meshopengl
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

Phil BoBo avatar image
2 Likes"
Phil BoBo answered Chris Smith commented

Add texture coordinates to your vertices and then bind the texture before drawing the mesh:

mesh-with-texture.fsm


mesh-texture.png (206.1 KiB)
· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Chris Smith avatar image Chris Smith commented ·

@phil.bobo

Thanks for the quick response! That did the trick.

0 Likes 0 ·