Recent Changes - Search:

Documentation

Help

Tutorials

RoadMap

Help Docs for wiki writers:

PmWiki

edit SideBar

LessonOne

Lesson One: Hello World this lesson teaches how to create a new window and render text to the screen

After adding EpeeEngine.cpp and EpeeEngine.h to your project create a new file that will be the main file of your program.

Inside this file add the following line at the top #include "EpeeEngine.h" this line will include all that you need to use the Epee Engine. First we are going to create a window and start the rendering cycle.

int main (int argc, char *argv[ ])
{
EpeeEngine GraphicsEngine;

Here we create a new instance of the Epee Engine

GraphicsEngine.SetUp(800,600,false,"Hello World",false,300,32);\\

This initlizes the Epee Engine and creates a new window only the first two arguments are necessary. See the documentations for SetUp? for more info about the arguments

GraphicsEngine.CreateTextBox("hello",20,50,3,"Hello World","Current",-1,-1);
This creates a new text box named hello that uses the a default font, displays it at position X 20 and Y 50, sets the hight and width of the text box to the size of the string Hello World, and adds it to the current render list. See CreateTextBox on how to change the color and font/font location.

the default fonts and locations are as follows Mac: font Chalkboard.ttf font location /Library/Fonts/

Windows: font ARIAL.TTF font location C:\WINDOWS\Fonts there are no defaults for Linux

Linux users will need to change the font and font location to do this make this call instead

GraphicsEngine.CreateTextBox("hello",20,50,3,"Hello World","Current",-1,-1,"truetypefont.ttf",18,255,255,255,"/fonts/");

where "truetypefont.ttf" is the name of a true type font file and /font/ is a location of that file. The argument after "truetypefont.ttf" is the font size.

while (1)
{
  GraphicsEngine.RenderSeen(true);
}
return 0;
}

This draws the textbox that we created to the screen and passing in true update the screen. See RenderSeen? for more information

The program without comments:

int main (int argc, char *argv[ ])
{
   EpeeEngine GraphicsEngine;
   GraphicsEngine.SetUp(800,600,false,"Hello World",false,300,32);
   GraphicsEngine.CreateTextBox("hello",20,50,3,"Hello World","Current",-1,-1);
while (1)
{
  GraphicsEngine.RenderSeen(true);
}
return 0;
}

Ok, we are done make sure you run this code in debug mode. If you do not see the words hello world in a new window look in the error file stderr.txt located in your project folder. This file records all errors reported by the epee engine there is also a debug file called stdout.txt located in the same directory as stderr.txt, which contains debug info.This code will display a new window and display "Hello World" in a new text box it. Sadly the code will run forever so in lesson two we will start learning how to handle keybord events and how to exit the EpeeEngine correctly.

If you have any question on need help with this example just PM on the forum and I would be happy to help.

Edit - History - Print - Recent Changes - Search
Page last modified on March 12, 2008, at 02:12 PM