Graphics

Summary
Graphics
Structures
IMAGE_INFO
Variables
widthContains the width of the image
heightContains the height of the image
formatContains the format of the image.
dataPointer to the image data.
VIDEO_MODE
Functions
Quads
gfx_quads_beginBegins a quad drawing session.
gfx_quads_endEnds a quad session.
gfx_quads_setrotationSets the rotation to use when drawing a quad.
gfx_quads_setsubsetSets the uv coordinates to use.
gfx_quads_setsubset_freeTODO
gfx_quads_drawTLDraws a quad by specifying the top-left point.
gfx_quads_drawDraws a quad by specifying the center point.
gfx_quads_draw_freeformDraws a quad by specifying the corner points.
gfx_quads_textTODO
Lines
gfx_lines_beginTODO
gfx_lines_drawTODO
gfx_lines_endTODO
Text
gfx_textTODO
gfx_text_widthTODO
gfx_text_colorTODO
gfx_text_set_default_fontTODO
Other
gfx_get_video_modesFetches a list of all the available video modes.
gfx_load_pngLoads a PNG image from disk.
gfx_load_textureLoads a texture from a file.
gfx_load_texture_rawLoads a texture from memory.
gfx_texture_setSets the active texture.
gfx_unload_textureUnloads a texture.
gfx_clearClears the screen with the specified color.
gfx_screenaspectReturns the aspect ratio between width and height.
gfx_screenwidthReturns the screen width.
gfx_screenheightReturns the screen height.
gfx_mapscreenSpecifies the coordinate system for the screen.
gfx_blend_normalSet the active blending mode to normal (src, 1-src).
gfx_blend_additiveSet the active blending mode to additive (src, one).
gfx_blend_noneDisables blending
gfx_setcolorvertexSets the color of a vertex.
gfx_setcolorSets the color of all the vertices.
gfx_getscreenTODO
gfx_memory_usageTODO
gfx_screenshotTODO
gfx_clip_enableTODO
gfx_clip_disableTODO

Structures

IMAGE_INFO

Summary
Variables
widthContains the width of the image
heightContains the height of the image
formatContains the format of the image.
dataPointer to the image data.

Variables

width

int width

Contains the width of the image

height

int height

Contains the height of the image

format

int format

Contains the format of the image.  See Image Formats for more information.

data

void *data

Pointer to the image data.

VIDEO_MODE

Functions

Summary
Quads
gfx_quads_beginBegins a quad drawing session.
gfx_quads_endEnds a quad session.
gfx_quads_setrotationSets the rotation to use when drawing a quad.
gfx_quads_setsubsetSets the uv coordinates to use.
gfx_quads_setsubset_freeTODO
gfx_quads_drawTLDraws a quad by specifying the top-left point.
gfx_quads_drawDraws a quad by specifying the center point.
gfx_quads_draw_freeformDraws a quad by specifying the corner points.
gfx_quads_textTODO
Lines
gfx_lines_beginTODO
gfx_lines_drawTODO
gfx_lines_endTODO
Text
gfx_textTODO
gfx_text_widthTODO
gfx_text_colorTODO
gfx_text_set_default_fontTODO
Other
gfx_get_video_modesFetches a list of all the available video modes.
gfx_load_pngLoads a PNG image from disk.
gfx_load_textureLoads a texture from a file.
gfx_load_texture_rawLoads a texture from memory.
gfx_texture_setSets the active texture.
gfx_unload_textureUnloads a texture.
gfx_clearClears the screen with the specified color.
gfx_screenaspectReturns the aspect ratio between width and height.
gfx_screenwidthReturns the screen width.
gfx_screenheightReturns the screen height.
gfx_mapscreenSpecifies the coordinate system for the screen.
gfx_blend_normalSet the active blending mode to normal (src, 1-src).
gfx_blend_additiveSet the active blending mode to additive (src, one).
gfx_blend_noneDisables blending
gfx_setcolorvertexSets the color of a vertex.
gfx_setcolorSets the color of all the vertices.
gfx_getscreenTODO
gfx_memory_usageTODO
gfx_screenshotTODO
gfx_clip_enableTODO
gfx_clip_disableTODO

Quads

gfx_quads_begin

void gfx_quads_begin()

Begins a quad drawing session.

Remarks

This functions resets the rotation, color and subset.  End the session by using gfx_quads_end.  You can’t change texture or blending mode during a session.

See Also

gfx_quads_end

gfx_quads_end

void gfx_quads_end()

Ends a quad session.

See Also

gfx_quads_begin

gfx_quads_setrotation

void gfx_quads_setrotation(float angle)

Sets the rotation to use when drawing a quad.

Arguments

angleAngle in radians.

Remarks

The angle is reset when gfx_quads_begin is called.

gfx_quads_setsubset

void gfx_quads_setsubset(float tl_u,
float tl_v,
float br_u,
float br_v)

Sets the uv coordinates to use.

Arguments

tl_uTop-left U value.
tl_vTop-left V value.
br_uBottom-right U value.
br_vBottom-right V value.

Remarks

O,0 is top-left of the texture and 1,1 is bottom-right.  The color is reset when gfx_quads_begin is called.

gfx_quads_setsubset_free

void gfx_quads_setsubset_free(float x0,
float y0,
float x1,
float y1,
float x2,
float y2,
float x3,
float y3)

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

gfx_quads_drawTL

void gfx_quads_drawTL(float x,
float y,
float width,
float height)

Draws a quad by specifying the top-left point.

Arguments

xX coordinate of the top-left corner.
yY coordinate of the top-left corner.
widthWidth of the quad.
heightHeight of the quad.

Remarks

Rotation still occurs from the center of the quad.  You must call gfx_quads_begin before calling this function.

See Also

<gfx_quads_draw, gfx_quads_draw_freeform>

gfx_quads_draw

void gfx_quads_draw(float x,
float y,
float w,
float h)

Draws a quad by specifying the center point.

Arguments

xX coordinate of the center.
yY coordinate of the center.
widthWidth of the quad.
heightHeight of the quad.

Remarks

You must call gfx_quads_begin before calling this function.

See Also

<gfx_quads_drawTL, gfx_quads_draw_freeform>

gfx_quads_draw_freeform

void gfx_quads_draw_freeform(float x0,
float y0,
float x1,
float y1,
float x2,
float y2,
float x3,
float y3)

Draws a quad by specifying the corner points.

Arguments

x0, y0Coordinates of the upper left corner.
x1, y1Coordinates of the upper right corner.
x2, y2Coordinates of the lower left corner.  // TODO: DOUBLE CHECK!!!
x3, y3Coordinates of the lower right corner.  // TODO: DOUBLE CHECK!!!

See Also

<gfx_quads_draw, gfx_quads_drawTL>

gfx_quads_text

void gfx_quads_text(float x,
float y,
float size,
const char *text)

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

Lines

gfx_lines_begin

void gfx_lines_begin()

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

gfx_lines_draw

void gfx_lines_draw(float x0,
float y0,
float x1,
float y1)

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

gfx_lines_end

void gfx_lines_end()

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

Text

gfx_text

void gfx_text(void *font,
float x,
float y,
float size,
const char *text,
int max_width)

TODO

Arguments

arg1desc

Returns

returns the number of lines written See Also: <other_func>

gfx_text_width

float gfx_text_width(void *font,
float size,
const char *text,
int length)

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

gfx_text_color

void gfx_text_color(float r,
float g,
float b,
float a)

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

gfx_text_set_default_font

void gfx_text_set_default_font(void *font)

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

Other

gfx_get_video_modes

int gfx_get_video_modes(VIDEO_MODE *list,
int maxcount)

Fetches a list of all the available video modes.

Arguments

listAn array to recive the modes.  Must be able to contain maxcount number of modes.
maxcountThe maximum number of modes to fetch.

Returns

The number of video modes that was fetched.

gfx_load_png

int gfx_load_png(IMAGE_INFO *img,
const char *filename)

Loads a PNG image from disk.

Arguments

imgPointer to an structure to be filled out with the image information.
filenameFilename of the image to load.

Returns

Returns non-zero on success and zero on error.

Remarks

The caller are responsible for cleaning up the allocated memory in the IMAGE_INFO structure.

See Also

gfx_load_texture

gfx_load_texture

int gfx_load_texture(const char *filename,
int store_format,
int flags)

Loads a texture from a file.  TGA and PNG supported.

Arguments

filenameNull terminated string to the file to load.
store_formatWhat format to store on gfx card as.
flagscontrols how the texture is uploaded

Returns

An ID to the texture.  -1 on failure.

See Also

<gfx_unload_texture, gfx_load_png>

gfx_load_texture_raw

int gfx_load_texture_raw(int w,
int h,
int format,
const void *data,
int store_format,
int flags)

Loads a texture from memory.

Arguments

wWidth of the texture.
hHeight of the texture.
dataPointer to the pixel data.
formatFormat of the pixel data.
store_formatThe format to store the texture on the graphics card.
flagscontrols how the texture is uploaded

Returns

An ID to the texture.  -1 on failure.

Remarks

The pixel data should be in RGBA format with 8 bit per component.  So the total size of the data should be w*h*4.

See Also

gfx_unload_texture

gfx_texture_set

void gfx_texture_set(int id)

Sets the active texture.

Arguments

idID to the texture to set.

gfx_unload_texture

int gfx_unload_texture(int id)

Unloads a texture.

Arguments

idID to the texture to unload.

See Also

<gfx_load_texture_tga>, gfx_load_texture_raw

Remarks

NOT IMPLEMENTED

gfx_clear

void gfx_clear(float r,
float g,
float b)

Clears the screen with the specified color.

Arguments

rRed component.
gGreen component.
bRed component.

Remarks

The value of the components are given in 0.01.0 ranges.

gfx_screenaspect

float gfx_screenaspect()

Returns the aspect ratio between width and height.

See Also

gfx_screenwidth, gfx_screenheight

gfx_screenwidth

int gfx_screenwidth()

Returns the screen width.

See Also

gfx_screenheight

gfx_screenheight

int gfx_screenheight()

Returns the screen height.

See Also

gfx_screenwidth

gfx_mapscreen

void gfx_mapscreen(float tl_x,
float tl_y,
float br_x,
float br_y)

Specifies the coordinate system for the screen.

Arguments

tl_xTop-left X
tl_yTop-left Y
br_xBottom-right X
br_yBottom-right y

gfx_blend_normal

void gfx_blend_normal()

Set the active blending mode to normal (src, 1-src).

Remarks

This must be used before calling gfx_quads_begin.  This is equal to glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA).

See Also

<gfx_blend_additive,gfx_blend_none>

gfx_blend_additive

void gfx_blend_additive()

Set the active blending mode to additive (src, one).

Remarks

This must be used before calling gfx_quads_begin.  This is equal to glBlendFunc(GL_SRC_ALPHA, GL_ONE).

See Also

<gfx_blend_normal,gfx_blend_none>

gfx_blend_none

void gfx_blend_none()

Disables blending

Remarks

This must be used before calling gfx_quads_begin.

See Also

<gfx_blend_normal,gfx_blend_additive>

gfx_setcolorvertex

void gfx_setcolorvertex(int i,
float r,
float g,
float b,
float a)

Sets the color of a vertex.

Arguments

iIndex to the vertex.
rRed value.
gGreen value.
bBlue value.
aAlpha value.

Remarks

The color values are from 0.0 to 1.0.  The color is reset when gfx_quads_begin is called.

gfx_setcolor

void gfx_setcolor(float r,
float g,
float b,
float a)

Sets the color of all the vertices.

Arguments

rRed value.
gGreen value.
bBlue value.
aAlpha value.

Remarks

The color values are from 0.0 to 1.0.  The color is reset when gfx_quads_begin is called.

gfx_getscreen

void gfx_getscreen(float *tl_x,
float *tl_y,
float *br_x,
float *br_y)

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

gfx_memory_usage

int gfx_memory_usage()

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

gfx_screenshot

void gfx_screenshot()

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

gfx_clip_enable

void gfx_clip_enable(int x,
int y,
int w,
int h)

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

gfx_clip_disable

void gfx_clip_disable()

TODO

Arguments

arg1desc

Returns

See Also

<other_func>

int width
Contains the width of the image
int height
Contains the height of the image
int format
Contains the format of the image.
void *data
Pointer to the image data.
void gfx_quads_begin()
Begins a quad drawing session.
void gfx_quads_end()
Ends a quad session.
void gfx_quads_setrotation(float angle)
Sets the rotation to use when drawing a quad.
void gfx_quads_setsubset(float tl_u,
float tl_v,
float br_u,
float br_v)
Sets the uv coordinates to use.
void gfx_quads_setsubset_free(float x0,
float y0,
float x1,
float y1,
float x2,
float y2,
float x3,
float y3)
TODO
void gfx_quads_drawTL(float x,
float y,
float width,
float height)
Draws a quad by specifying the top-left point.
void gfx_quads_draw(float x,
float y,
float w,
float h)
Draws a quad by specifying the center point.
void gfx_quads_draw_freeform(float x0,
float y0,
float x1,
float y1,
float x2,
float y2,
float x3,
float y3)
Draws a quad by specifying the corner points.
void gfx_quads_text(float x,
float y,
float size,
const char *text)
TODO
void gfx_lines_begin()
TODO
void gfx_lines_draw(float x0,
float y0,
float x1,
float y1)
TODO
void gfx_lines_end()
TODO
void gfx_text(void *font,
float x,
float y,
float size,
const char *text,
int max_width)
TODO
float gfx_text_width(void *font,
float size,
const char *text,
int length)
TODO
void gfx_text_color(float r,
float g,
float b,
float a)
TODO
void gfx_text_set_default_font(void *font)
TODO
int gfx_get_video_modes(VIDEO_MODE *list,
int maxcount)
Fetches a list of all the available video modes.
int gfx_load_png(IMAGE_INFO *img,
const char *filename)
Loads a PNG image from disk.
int gfx_load_texture(const char *filename,
int store_format,
int flags)
Loads a texture from a file.
int gfx_load_texture_raw(int w,
int h,
int format,
const void *data,
int store_format,
int flags)
Loads a texture from memory.
void gfx_texture_set(int id)
Sets the active texture.
int gfx_unload_texture(int id)
Unloads a texture.
void gfx_clear(float r,
float g,
float b)
Clears the screen with the specified color.
float gfx_screenaspect()
Returns the aspect ratio between width and height.
int gfx_screenwidth()
Returns the screen width.
int gfx_screenheight()
Returns the screen height.
void gfx_mapscreen(float tl_x,
float tl_y,
float br_x,
float br_y)
Specifies the coordinate system for the screen.
void gfx_blend_normal()
Set the active blending mode to normal (src, 1-src).
void gfx_blend_additive()
Set the active blending mode to additive (src, one).
void gfx_blend_none()
Disables blending
void gfx_setcolorvertex(int i,
float r,
float g,
float b,
float a)
Sets the color of a vertex.
void gfx_setcolor(float r,
float g,
float b,
float a)
Sets the color of all the vertices.
void gfx_getscreen(float *tl_x,
float *tl_y,
float *br_x,
float *br_y)
TODO
int gfx_memory_usage()
TODO
void gfx_screenshot()
TODO
void gfx_clip_enable(int x,
int y,
int w,
int h)
TODO
void gfx_clip_disable()
TODO
Close