hi there,

Okies, i wrote a short hello treelib template program. However, it won't
compile unmodified.
Creating a functioning opengl context and working user interaction is very
platform and/or foundation specific. I use modules from my own engine.
Adding them here would be useless to you.
You can use the file i attached as a template and fill in the missing
elements yourself. If you don't know how to create an opengl context, then
visit nehe.gamedev.net which is pretty much the best opengl tutorial site
i know.
All you need to make the template run is a valid OpenGL context and
working camera that focuses on the point of origin.
Explaining how all of those work manually (without the use of any
foundation) is a bit too much work for me atm.
Feel free to contact me again if you got a working OpenGL interface but no
tree on the screen :)

bye

> hi
>
> sorry >> my English is not very good ..
>
> but I hope that you can understand my message
>
> my qustion is about TreeLib.
>
> it is very nice .. but I try to make a simple program to draw a tiny
> tree but ....
>
> i read \" readme.txt \" .. and i linked the library .. and wrote the
> code ..
>
> I NEED A Hello World to Understand this library..
>
> and this is my email if you can send me the code ..
>
> Aboshammar@gmail.com
>
---------------------------


/* your includes here */

#include "treelib/treelib.h"		//include the treelib header
#include "treelib/interface.h"		//include the simplified interface header

/* your global structures here */

TreeGen::CTreeNode		my_tree(NULL);	//global tree object


void toggleBalance()	//simple handler function to toggle tree balancing
{
	bool balancing = TreeLib::getAttributei(my_tree,TL_AUTO_BALANCE);
	TreeLib::setAttributei(my_tree,TL_AUTO_BALANCE,!balancing);
	TreeLib::rebuildTree(my_tree);
}


void toggleRotate()		//simple handler function to toggle tree leaf rotation
{
	TreeLib::setAttributei(my_tree,TL_ROTATE_LEAVES,!rotating);
	TreeLib::rebuildTree(my_tree);
}

void randomizeTree()	//regenerate tree
{
	TreeLib::setAttributei(my_tree,TL_SEED,rand());
	TreeLib::rebuildTree(my_tree);
}


int main()
{
	/* Init application and OpenGL context. For reference on how to create an OpenGL context visit http://nehe.gamedev.net */

	if (!TreeLib::load("treelib/treelib.dll"))
	{
		cout << "Treelib failed to load.\n";
		cout << TreeLib::error();
		return -1;
	}
	
	my_tree = TreeLib::createTree();
	
	if (!my_tree)	//If tree creation failed then something went terribly wrong.
	{
		cout << "Failed to create tree.\n";
		cout << TreeLib::error();
		TreeLib::unload();
		return -1;
	}
	
	/* Configure OpenGL if you haven't already done that. You should enable GL_BLEND and setup the OpenGL blend-function to support alpha blending. */
	
	bool executing = true;
	while (executing)	//program core loop
	{
		/*Handle user events, Clear screen, Apply camera. */
		if (!TreeLib::renderTree(my_tree,0))	//render tree. '0' indicates auto viewing distance detection.
		{
			cout << "Failed to render tree.\n";	// A tree that can't be rendered is bad news. This is actually that unlikely that you might as well skip checking.
			cout << TreeLib::error();
			TreeLib::discardTree(my_tree);
			TreeLib::unload();
			return -1;
		}
		/*Render other elements. Render overlay, Swap buffers. */
	}
	TreeLib::discardTree(my_tree);
	TreeLib::unload();
	return 0;
}


