Personal tools
You are here: Home cmgui Wiki Texture Coordinates Explained
Views
FrontPage >> Peters notes >>

Texture Coordinates Explained

last edited 1 year ago by pbier

Suppose I have a little 2D element which has dimensions 20x10 and I want to place an image onto the surface of my element.

It is easy to modify the surface to use a material coloured red or green but it is slightly trickier to modify the surface to use an image. The first step is to read the image into cmgui. In cmgui images are stored in something called a texture. A 2D texture knows about all the pixels from the image read in. It is also possible to create 3D textures by stacking images one on top of the other. When you create a texture you should specify its size. For example you could make your texture to have a width of 100 and a height of 100.

Creating a 2D texture is a bit like giving a friend a blank piece of paper that you have cut to a desired size, supplying them with an image and telling them to copy the image onto the piece of paper keeping every detail of the original. Even if you gave them a smaller piece of paper they have to record every detail. Once they have their perfect copy they can discard the original image confident they have all the information from the image. A texture can be created from all sorts of different image types (jpeg, tif, dcm etc). Once created Cmgui knows how to do various useful things with a textures too.

Back to the problem at hand, I have created a texture and now want to place the image onto the surface of my little element. I need a material to place on my surface. I'm going to have to ask my friend with the texture to make me a material of exactly the right size to fit the element. Unfortunately the only thing he knows about is the texture and there is no guarantee that his texture is the same size as my little element.

Contributing to this site

Please add to the wiki any relevant information that you think might be useful to other users of this website. For example, you might like to contribute your experiences, questions and answers.

You are encouraged to contribute to this site regardless of your level of experience. Contributions are welcomed from new and regular visitors.

If you ask a question and receive an answer from a developer you should record it in the wiki. This information is extremely useful and can help other users overcome the same problem.

See how to add and edit pages for more information.