Simple 2D
In this tutorial, we’re going to render some 2D stuff. We will draw a rectangle and a 2D image. This can be really usefull when you’re going to make a menu for your game or application.

What do we need?
- We need a 2D image, which will be the truevision3d logo, ripped of the website.
- We need some way to draw 2D textures, which is the TVScreen2DImmediate.
How do we set things up?
- We just create the TVScreen2DImmediate by its constructor.
- We load the texture by calling:
You’ve seen this before, so I won’t explain it again.
How do we render this?
- Just like with the text rendering, we will use a begin/end block.
Screen2D.Action_End2D();
You can see it is a little different, but it works the same as with the text.
- To draw the texture, we’ll call:
The first argument is of course the ID of the texture we want to draw.
The second and third argument are the start position on the screen (in pixels).
The fourth and fifth argument are the end position of the texture on the screen (once again in pixels).
The next 4 arguments are the colors of the vertices at the corners. If you set them, you can make cool gradients that multiply with the texture. If you supply -1, it will be no color, so white. If you supply -2 as the last 3, it will use the same color as color1.
The last 4 arguments are the texture coordinates on the texture. 0,0 is the top left corner, 1,1 is the bottom right corner, so we draw the whole texture.
- To draw the blue rectangle, we call the following method:
It will draw the box from the middle – 128 pixels to the middle + 128 pixels. That’s the first 4 parameters.
The next 4 arguments are the colors of the vertices on the corners. The last 3 are just -2 because it’s easier, you tell the engine that it needs to pick the color that has already been supplied for the first vertex, which means it will be blue.
- Of course we need to render the text after the rectangle, since it needs to go on top of the rectangle.
Things you can add/change yourself
- It would be a good idea to experiment with loading other textures and drawing them somewhere on the screen.
- Experiment with the color of the corners of the rectangle to know what’s happening if you’d change it on the texture as well. Especially changing the alpha value is usefull when you want a texture to fade out. Another possibility would of course be to put an alpha channel in the texture, but that will take a little more memory.