NOGDUS

Articles, Tutorials, and other things. => ClanLib Game Programming => : Richard Marks March 14, 2009, 10:04:03 AM



: Getting started with ClanLib - Part II
: Richard Marks March 14, 2009, 10:04:03 AM
Getting started with ClanLib - Part II

In this article I'm going to show you how to load and draw images on your newly created window.

I am going to assume that you have already read the first article (http://ccpssolutions.com/nogdusforums/index.php?topic=392.0), and will not re-post the code that is in it here.
I am just going to show you the changes to the code.

I duplicated the first article's project files in a new project directory, and then started editing.

First thing was to edit the comments :D
:
// Project: ClanLib Test Project #2 (CLTEST2)

and update the namespace
:
namespace CLTEST2

now do a search replace and change the class name from CLTest1Application to CLTest2Application.

after we create the main window, we add this code to give us a pointer to the graphics context of the window for drawing on:
:
// get the graphics context of the window
CL_GraphicContext* graphicsContext = mainWindow.get_gc();

and right after we add this code for loading our image:
:
// load the title screen image
CL_Surface title("data/graphics/title.png");

Now, in the main loop, right after we clear the screen, we draw our title screen image
:
// draw the title screen image on the graphics context
title.draw(0, 0, graphicsContext);

last change is the instance creation at the end:
:
// create the application instance
CLTEST2::CLTest2Application globalApplicationInstance;

Ok. thats it! After you build your project, you should see your image (don't forget to create one!)

Thanks for reading! 8)


Sorry, the copyright must be in the template.
Please notify this forum's administrator that this site is missing the copyright message for SMF so they can rectify the situation. Display of copyright is a legal requirement. For more information on this please visit the Simple Machines website.