hessiess
April 10th, 2009, 05:54 PM
As you may already know, I have bean developing a 2D graphics engine, but as writing documentation isn't my best aria, the documentation may suffer. Has anyone got any tips for writing easy to understand tutorials?
This is what I currently have for one of the basic usage tutorial:
/*
This is a simple application that demonstrates the basic usage
of the Quad-Ren graphics library.
First we need to include the Quad-Ren header file.
*/
#include <quad-ren/quad-ren.h>
int main()
{
/*
To display anything we first need to create an instance of
qr_renderer. The constructor takes four arguments, these are:
*View port aspect ratio
The aspect ratio of the view port, it is automatically
leterboxed to maintain the aspect ratio, regardless of
the window size.
*Projection Width
The width of the view port in relative co-ordinate space.
*Full screen
This parameter controls if the application will run
full screen or windowed.
*Window resolution
The default size of the window in pixels, passing 0
creates a maximised window. This parameter is ignored
if full screen is set to true, in which case Quad-Ren
will render at the screens maximum resolution.
*/
qr_renderer *renderer = new qr_renderer(vector2d_i(16, 9),
10.0 ,false ,vector2d_i(0, 0));
/*
Set the window title.
*/
renderer -> set_window_title("Hello World! - Quad-Ren 0.4");
/*
next we fetch a pointer to the resource manager from the renderer.
*/
qr_resource_manager *res_man = renderer ->
get_resource_manager();
/*
We are going to display an image containing the "hello world!"
message. First we create a new sprite object for the image.
The qr_sprite constructor takes two arguments, a pointer to the
resource manager and the total number of frames which the sprite
is going to store.
*/
qr_sprite *message = new qr_sprite(res_man, 1);
/*
The image we want to display is stored in the "media" folder and
is in the PNG format. PNG images are supported natively and can
be loaded easily with a call to the load_png_frame method.
All frames in an animation must be powers of 2, square and the
same size.
*/
message -> load_png_frame(
"../media/hello_world.png", 1);
/*
Before a sprite can be used it must first be converted, this
converts all of the image data into the correct format for
the renderer. Be aware that once a sprite has bean converted,
it is no longer editable.
*/
message -> convert_data();
/*
The easiest way to display a sprite is to attach it to the
background quad, which is always the same size as the view
port, and moves to follow the camera. Lets attach the sprite
containing the hello world image to the background quad.
*/
renderer -> set_bg_sprite(message);
/*
Thats it for set-up, to render the scene the run method
of the renderer is ran inside of a for loop. The run()
method returns true until the user closes the window or
an event receiver returns false.
*/
while(renderer -> run())
{
}
/*
When the above while loop exits application exits we need
to free the renderer, sprites and any other allocated
resources. This can be achieved by calling drop on the
renderer, which then instructs the resource manager to
delete all registered resources.
*/
renderer -> drop();
}
Thanks in advance for any advice.
This is what I currently have for one of the basic usage tutorial:
/*
This is a simple application that demonstrates the basic usage
of the Quad-Ren graphics library.
First we need to include the Quad-Ren header file.
*/
#include <quad-ren/quad-ren.h>
int main()
{
/*
To display anything we first need to create an instance of
qr_renderer. The constructor takes four arguments, these are:
*View port aspect ratio
The aspect ratio of the view port, it is automatically
leterboxed to maintain the aspect ratio, regardless of
the window size.
*Projection Width
The width of the view port in relative co-ordinate space.
*Full screen
This parameter controls if the application will run
full screen or windowed.
*Window resolution
The default size of the window in pixels, passing 0
creates a maximised window. This parameter is ignored
if full screen is set to true, in which case Quad-Ren
will render at the screens maximum resolution.
*/
qr_renderer *renderer = new qr_renderer(vector2d_i(16, 9),
10.0 ,false ,vector2d_i(0, 0));
/*
Set the window title.
*/
renderer -> set_window_title("Hello World! - Quad-Ren 0.4");
/*
next we fetch a pointer to the resource manager from the renderer.
*/
qr_resource_manager *res_man = renderer ->
get_resource_manager();
/*
We are going to display an image containing the "hello world!"
message. First we create a new sprite object for the image.
The qr_sprite constructor takes two arguments, a pointer to the
resource manager and the total number of frames which the sprite
is going to store.
*/
qr_sprite *message = new qr_sprite(res_man, 1);
/*
The image we want to display is stored in the "media" folder and
is in the PNG format. PNG images are supported natively and can
be loaded easily with a call to the load_png_frame method.
All frames in an animation must be powers of 2, square and the
same size.
*/
message -> load_png_frame(
"../media/hello_world.png", 1);
/*
Before a sprite can be used it must first be converted, this
converts all of the image data into the correct format for
the renderer. Be aware that once a sprite has bean converted,
it is no longer editable.
*/
message -> convert_data();
/*
The easiest way to display a sprite is to attach it to the
background quad, which is always the same size as the view
port, and moves to follow the camera. Lets attach the sprite
containing the hello world image to the background quad.
*/
renderer -> set_bg_sprite(message);
/*
Thats it for set-up, to render the scene the run method
of the renderer is ran inside of a for loop. The run()
method returns true until the user closes the window or
an event receiver returns false.
*/
while(renderer -> run())
{
}
/*
When the above while loop exits application exits we need
to free the renderer, sprites and any other allocated
resources. This can be achieved by calling drop on the
renderer, which then instructs the resource manager to
delete all registered resources.
*/
renderer -> drop();
}
Thanks in advance for any advice.