Table of Contents

Getting Started With DevCpp

Project Setup

Setting up your first project is simple. After creating a new blank project add libtv3dc65.a to the linker options. Copy tv3dc65.dll, newton.dll, and libtv3dc65.a to your project directory. Add the {tv3d 6.5 sdk}\sdk\cppgcc folder to the libraries directory list and include directory list in project settings. Then, last but not least, make sure that you have set your project type as “Win32 GUI“. And that is it! Simple enough huh?

Code Template

Here is a code template to get you started. This should be ready to go, just copy it into your project and give it a run.

Sample (Code):

//This template is the compilation of several other people's code, including the VC6 template,
//thanks to everyone that had code examples that I borrowed from.
#include <windows.h>
#include "CTVMesh.h"
#include "CTVEngine.h"
#include "CTVScene.h"
#include "CTVInputEngine.h"
#include "tv_types.h"
/*  Declare Windows procedure  */
/*  Make the class name into a global variable  */
char szClassName[ ] = "WindowsApp";
// TV3D Variables:
CTVEngine* pTV;
CTVScene* pScene;
CTVInputEngine* pInput;
BOOL DoLoop; //This is the boolean variable for our render/message loop
HWND hwnd;  //This is the handle for the window
//Get the Path of the file
void AppPath(char* PathOfFile, char* ret_Path)
	char* found = strrchr(PathOfFile, '\\');
		// check with '/' path format
		found = strrchr(PathOfFile, '/');
			// no path herre it's just a file.
			// so just blank output
			ret_Path[0] = 0;
			// copy just a part of the string
			int size = (int)found - (int)PathOfFile + 1;
			strncpy(ret_Path, PathOfFile, size);
			ret_Path[size] = 0;
		// copy just a part of the string
		int size = (int)found - (int)PathOfFile + 1;
		strncpy(ret_Path, PathOfFile, size);
		ret_Path[size] = 0;
//Function to Initialize the TV3D Engine
void InitTV3D()
	// Create the pTV Interface first:
	pTV = new CTVEngine();
	// Set the debug file/options.
	// Do this before the 3D init so it can log any errors found during init.
	char path[256];
	char srchpath[256];
	pTV->SetDebugMode(true, true);
	pTV->SetDebugFile(strcat(srchpath, "\\debugfile.txt"));
	// After setting the beta-key/license its time to init the engine:
	pTV->Init3DWindowed(hwnd, true);
	// Something good to do is to enable the auto-resize feature:
	// Get the default viewport and set autoresize to true for it:
	// Lets display the FPS:
	// Set the prefered angle system:
	// Now after we are done initializing the TVEngine component lets continue:
	// Create any other components after pTV init->
	pScene = new CTVScene();
	// Input has an additional init method to call->
	pInput = new CTVInputEngine();
        // Lets init both keyboard and mouse:
	pInput->Initialize(true, true);
	// Now we have setup the most basic of components->
	// Something to think about, if the component has a diffrent ATL init method
	// then the Object = new pTV<NAME>, use that one instead->
	// For example:
	// CTVMesh* Mesh;
	// Mesh = Scene->CreateMeshBuilder("MyMesh"); <- Instead of Mesh = new CTVMesh();
	// Same goes for RenderSurface, Viewport etc->
	// Setup the boolean for the loop.
	DoLoop = true;
//Begin Winmain, this is the equivelant to main in DOS or LINUX programs
int WINAPI WinMain (HINSTANCE hThisInstance,
                    HINSTANCE hPrevInstance,
                    LPSTR lpszArgument,
                    int nFunsterStil)
    MSG messages;            /* Here messages to the application are saved */
    HACCEL hAccelTable;
    WNDCLASSEX wincl;        /* Data structure for the windowclass */
    /* The Window structure */
    wincl.hInstance = hThisInstance;
    wincl.lpszClassName = szClassName;
    wincl.lpfnWndProc = WindowProcedure;      /* This function is called by windows */ = CS_DBLCLKS;                 /* Catch double-clicks */
    wincl.cbSize = sizeof (WNDCLASSEX);
    /* Use default icon and mouse-pointer */
    wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
    wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
    wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
    wincl.lpszMenuName = NULL;                 /* No menu */
    wincl.cbClsExtra = 0;                      /* No extra bytes after the window class */
    wincl.cbWndExtra = 0;                      /* structure or the window instance */
    /* Use Windows's default color as the background of the window */
    wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
    /* Register the window class, and if it fails quit the program */
    if (!RegisterClassEx (&wincl))
        return 0;
    /* The class is registered, let's create the program*/
    hwnd = CreateWindowEx (
           0,                   /* Extended possibilites for variation */
           szClassName,         /* Classname */
           "Windows App",       /* Title Text */
           WS_OVERLAPPEDWINDOW, /* default window */
           CW_USEDEFAULT,       /* Windows decides the position */
           CW_USEDEFAULT,       /* where the window ends up on the screen */
           544,                 /* The programs width */
           375,                 /* and height in pixels */
           HWND_DESKTOP,        /* The window is a child-window to desktop */
           NULL,                /* No menu */
           hThisInstance,       /* Program Instance handler */
           NULL                 /* No Window Creation data */
    /* Make the window visible on the screen */
    ShowWindow (hwnd, nFunsterStil);
   	//hAccelTable = LoadAccelerators(hThisInstance, (LPCTSTR)IDC_TEMPLATE);
    /* Run the message loop. It will run until GetMessage() returns 0 */
    while (DoLoop)
          if(GetFocus() == hwnd)
             //Render pointing go here
          BOOL peek = PeekMessage(&messages, NULL, 0, 0, TRUE);
          //Translate and Dispatch all messages for hwnd
          if (!TranslateAccelerator(messages.hwnd, hAccelTable, &messages)) 
    /* The program return-value is 0 - The value that PostQuitMessage() gave */
    return messages.wParam;
//This is the End of Winmain//
/*  This function is called by the Windows function DispatchMessage()  */
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    switch (message)                  /* handle the messages */
        case WM_DESTROY:
             //Stop Rendering loop
             DoLoop = false;
             // Free TV:
		     pTV = NULL;		
            PostQuitMessage (0);       /* send a WM_QUIT to the message queue */
        default:                      /* for messages that we don't deal with */
            return DefWindowProc (hwnd, message, wParam, lParam);
    return 0;


If you got the template to run, I am sure you noticed that it is basically a black screen. I am leaving it up to you to make that black screen into something spectacular. There are many other header files that you may need to include based on what you are trying accomplish. The purpose of this code is simply to get you started, because I had some troubles with getting the VC6 code to work in DevCpp.

tv3d/getting_started_with_c_using_devcpp.txt · Last modified: 2013/11/22 13:30