Blank screen
This is basicaly the first program you’ll write with the tv3d engine. It’s not hard to get, but it’s a great opportunity to learn something about the engine itself. There’s not a lot of code required to get something up and running with tv3d, but it’s good to know the possibilities of the engine as well. In the tutorial itself there are comments on the lines where they are necessary, but you can achieve more than just what’s being done already by experimenting yourself.

What do we need to get a blank screen?
We just need a form (to render to) and the truevision3d engine object (from MTV3D65.dll or TV3D65.dll). We don’t want to render anything just yet, so there are no other objects necessary.
How do we set up the engine?
There are a couple of things you need to think about when using the engine. Everyone makes mistakes, so there’s definitely a need for a debug file. Let’s set that up by using this line of code:
Of course that’s not the only thing you need to do, since we also need to specify if we are going to make a windows or a fullscreen 3d program. Everyone knows the fullscreen games, but not everyone knows that you can also render to a form or other object. That’s what we are going to do right now, we’re going to render to a form (later on I’ll show you what to do to get some fullscreen action). All we need to do is pass TV the hWnd (handle) of the form we created. Every language has its own way of creating a form, so i won’t go into details about that, the window is already made.
So we choose the right command, Init3DWindowed in this case, and then we pass our handle as our first parameter.
The second parameter is the Hardware Transform & Lighting (also known as T&L) boolean. This parameter tells TV whether to use T&L or not. T&L is usually supported in the hardware of a computer (99% of today’s hardware), so it should be set to true (to read more about this, goto: wikipedia ).
The combined code will look like this:
Initializing the TV engine before every other object you’re going to use is really important. Almost every object in the TV3D65.dll uses the TVEngine object, so it’s best to always initialize that before anything else.
How do we render to our form?
This is a fairly easy step. First thing we need to do is create a loop. The reason we need this loop is that we want to render as often as possible, since drawing something just once isn’t going to look good at all. Also if there would be any objects moving, we wouldn’t see it happen, since the engine isn’t drawing stuff onto the screen. When we’ve made the loop, we need to do 3 things:
-clear the screen. Why would we need that? We can just paint over the previous screen can’t we? Well, to be honest… No! Imagine we have a piece of transparent material (doesn’t matter how you’re supposed to make it yet). If we render that on our screen, it will look transparent. But what if it gets drawn again? Well, it’s quite simple. Imagine looking through sunglasses. If we have 1 pair of sunglasses, everything will look a bit browner. If we put another one over it, it’ll look browner again, and it gets darker and darker and darker, until you can’t see anything anymore if you add more layers of sunglasses. Well, to be short, the object gets opaque (you can’t see through it anymore). That’s exactly what would happen to the stuff you’re rendering, and it’s worse, but i won’t go into the details too much, it’s enough to know that you need to clear the screen. This is done by calling
-render to the screen. Quite obvious i think, we need to render to our screen, since that’s what we’re trying to accomplish, aren’t we? This is done by
-check if the program needs to do anything else. Of course we don’t want our program to ignore everything that happens in windows. The user of our program might have clicked the X button on the top right, or might have done something else of course. That’s why we’re going to give the program/form the opportunity to do their events. In .NET it’s being done by Application.DoEvents(), but every language has something comparable.
Congratulations, you just painted your form black, awesome!
Just 1 thing more: What if the user aborts the program? Should we just leave everything in the memory? Don’t think that’s a good idea, so let’s clean everything a bit up. We can clean and release everything by 2 simple lines.
releases all the objects that are in use by the engine. After that we need to destroy the TV object, every language has it’s own way of doing this, but in .NET we’re using TV=null.
Additions/changes you can make yourself
-Like I mentioned above, you can also render TV3D to some other controls on your form. Let’s try it, by adding a picturebox on your form. Now we change the first parameter of the Init3DWindowed command to picturebox1.Handle. And look! We just made TV render to a picturebox instead of a form.
-Of course, when you’re creating a game, you’ll want to make full use of a user’s screen. That’s why TV can render fullscreen as well. You can tell TV to render fullscreen by using TV.InitFullscreen(Width, Height). Of course you can substitute the width and height with numbers, but just to make the purpose of those numbers clear, i put the names in there. I made my blank screen render in a 800x600pixels fullscreen by commenting the Init3DWindowed line, and writing a new line: