MTek-GDL 0.100.4-muffintrap
Loading...
Searching...
No Matches
Namespaces | Enumerations | Functions
Main Library Module

Functions for setting up the system, debug environments and some screen and video related functions. More...

Collaboration diagram for Main Library Module:

Namespaces

namespace  gdl::wii
 Wii specific functions, structs and global variables.
 

Enumerations

enum  gdl::InitVideoMode {
  gdl::ModeAuto = 0 , gdl::ModeNTSC , gdl::ModePAL , gdl::ModeMPAL ,
  gdl::ModePAL60
}
 
enum  gdl::InitAspectMode { gdl::AspectAuto = 0 , gdl::Aspect4x3 , gdl::Aspect16x9 }
 
enum  gdl::InitResolution { gdl::HiRes = 0 , gdl::LowRes }
 
enum  gdl::InitFlags { gdl::DontMask = 1<<0 , gdl::ForceNonInt = 1<<1 , gdl::AntiAliased = 1<<2 , gdl::OpenGX = 1<<3 }
 

Functions

void gdl::InitSystem (gdl::InitVideoMode videoMode=gdl::ModeAuto, gdl::InitAspectMode aspectMode=gdl::AspectAuto, gdl::InitResolution resolution=gdl::HiRes, u_int flags=0)
 Initializes the system.
 
void gdl::ConsoleMode ()
 Sets the screen to console mode.
 
void gdl::Set2DMatrixRes (short xres, short yres)
 Sets the resolution of the 2D projection matrix.
 
void gdl::Set2DMode (float farClip=100.f)
 Sets the current projection matrix into an orthographic 2D projection matrix.
 
void gdl::Set3DMode (float farClip=1000.f)
 Sets the current projection matrix into a 3D projection matrix.
 
void gdl::SetClearColor (u_char red, u_char grn, u_char blu, u_char alp)
 Sets the clear color.
 
void gdl::SetClearColor (u_int color)
 Sets the clear color.
 
void gdl::SetClipBox (short x1, short y1, short x2, short y2)
 Sets the clip box.
 
void gdl::ResetClipBox ()
 Resets the clip box.
 
void gdl::PrepDisplay ()
 Prepares the display for drawing graphics.
 
void gdl::Display ()
 Display graphics.
 
gdl::ErrorCallback gdl::SetErrorCallback (gdl::ErrorCallback func)
 Sets an error callback function.
 
void gdl::CallErrorCallback (const char *message,...)
 Calls the currently set error callback function.
 

Detailed Description

Functions for setting up the system, debug environments and some screen and video related functions.

Enumeration Type Documentation

◆ InitAspectMode

Aspect ratio options

Aspect ratio mode options for the gdl::InitSystem() function.

Note
In hi-res mode, widescreen is emulated through anamorphic means (2D/3D projection matrix is wide but actual screen resolution isn't). In low-res mode however, the actual screen resolution is proper wide.
Enumerator
AspectAuto 

Aspect ratio selected automatically (based on console settings).

Aspect4x3 

Initialize in 4:3 aspect ratio mode (640x480/320x240 in NTSC or MPAL mode, 640x528/320x264 in PAL mode).

Aspect16x9 

Initialize in 16:9 widescreen aspect ratio mode (854x480/432x240 in NTSC or MPAL mode, 854x528/432x264 in PAL mode).

◆ InitFlags

Initialization flag options

Special initialization flags for the for the gdl::InitSystem() function.

Enumerator
DontMask 

Disable screen masking which is used to hide garbage in the FrameBuffer during initialization.

ForceNonInt 

Force non-interlaced mode for low resolution modes regardless whether or not a component cable is used.

AntiAliased 

Enable anti-aliasing mode (ignored when resolution is set to gdl::LowRes).

OpenGX 

OpenGX will be used for drawing and is expected to handle rendering state.

◆ InitResolution

Screen resolution options

Screen resolution mode options for the gdl::InitSystem() function.

Enumerator
HiRes 

Standard hi-res mode (640x480 for NTSC and MPAL, 640x528 for PAL).

LowRes 

OldSchool low-res mode (320x240/432x240) for NTSC and MPAL, 320x264/432x264 for PAL).

◆ InitVideoMode

Video system options

Video system mode options for the gdl::InitSystem() function.

Note
It is recommended to use gdl::ModeAuto by default so that the library will choose an appropriate video system according to the console's settings and region. If you're using a specific video system mode, make sure that your TV supports it (though most modern TVs pretty much support all modes).
S-Video output strangely does not work in PAL mode (there's no workaround as it has something to do with the console's video encoder).
Enumerator
ModeAuto 

Auto selects a video mode according to the system's video settings.

ModeNTSC 

Initialize in NTSC video mode (480 lines, 60Hz).

ModePAL 

Initialize in PAL video mode (524 lines, 50Hz).

ModeMPAL 

Initialize in MPAL/PAL60 video mode (similar to NTSC: 480 lines, 60Hz).

ModePAL60 

initialize in PAL 60Hz mode, similar to NTSC

Function Documentation

◆ CallErrorCallback()

void gdl::CallErrorCallback ( const char *  message,
  ... 
)

Calls the currently set error callback function.

This function calls the currently set error handler function usually displaying the error message. The default error callback function will set the screen to high-res mode and then prints out the specified error message.

Note
The overall message length must be no longer than 255 characters.
Parameters
[in]messageString of print message (supports printf() style formatting codes).
[in]...Print arguments.

◆ ConsoleMode()

void gdl::ConsoleMode ( )

Sets the screen to console mode.

This function sets the screen into a simple TTY console for printing out debug messages through printf(). Use the global variable gdl::ConsoleActive to tell whether or not console mode is set or not. Since v0.65 and onwards of this library, this function will allocate its own framebuffer and rmode settings so that the console screen will always be hi-res even when low-res mode is set but calling gdl::Display() will revert it back to the mode you specified.

Note
This mode is cleared automatically once gdl::Display() is called. However, console text is preserved.

◆ Display()

void gdl::Display ( )

Display graphics.

Finishes GX rendering, waits for it to finish processing, and then switches framebuffers after a VSync, displaying the rendered graphics. It also calculates the delta value for gdl::Delta based on the amount of CPU cycles passed since gdl::PrepDisplay() was called.

Note
Always call this function after drawing any graphics to display it.
In order for this function to properly calculate a value for gdl::Delta if you take into account frame skipping, intensive routines must be written within a gdl::PrepDisplay() and gdl::Display() pair.

◆ InitSystem()

void gdl::InitSystem ( gdl::InitVideoMode  videoMode = gdl::ModeAuto,
gdl::InitAspectMode  aspectMode = gdl::AspectAuto,
gdl::InitResolution  resolution = gdl::HiRes,
u_int  flags = 0 
)

Initializes the system.

This function must be called before using most library functions (usually graphics drawing and sound related). What this function does is that it initializes the system's video, graphics, and audio subsystems as well as automatically setting up anamorphic widescreen and progressive scan based on the system's configuration by default.

Note
Even though this function initializes most of the important console subsystems, it does not initialize the file and Wiimote subsystems but they are pretty easy to initialize them yourself anyway (see the included Wii examples).
When low-resolution mode is set, the video mode is set to non-interlaced (like a VC title) when the console is set to Standard 480i mode. If a component video cable is used but the console is not set to progressive scan mode, interlacing is enabled by default for compatibility with HDTVs that may not support non-interlaced video through component. If progressive scan mode is set, low-resolution is emulated in which the library allocates a full 480/528 line framebuffer but drawing is allowed only at the top-half of it. When gdl::Display() is called, the top half is expanded vertically to fill the entire framebuffer.
When anti-aliased mode is set, the actual screen resolution is reduced vertically by (y/2)-4 to make way for multi-sample anti-aliasing in the EFB and it also makes pixels of textures look like they were rendered at half the vertical resolution as MSAA is only done on the edges of polygons. Color depth and z-buffer are also reduced to 16-bit as well (RGB565 Z16 to be exact).
Parameters
[in]videoModeVideo system mode (see gdl::InitVideoMode)
[in]aspectModeAspect ratio mode (see gdl::InitAspectMode)
[in]resolutionDisplay resolution mode (see gdl::InitResolution)
[in]flagsInit flags (see gdl::InitFlags)

◆ PrepDisplay()

void gdl::PrepDisplay ( )

Prepares the display for drawing graphics.

Always call this function before calling any of the graphics functions. This function also begins calculation for the gdl::Delta variable based on the amount of time it took for a gdl::PrepDisplay() and gdl::Display() pair to complete.

Note
This function resets the projection matrix to 2D, model matrix and the clip box.

◆ Set2DMatrixRes()

void gdl::Set2DMatrixRes ( short  xres,
short  yres 
)

Sets the resolution of the 2D projection matrix.

This function changes the resolution of the 2D projection matrix useful if you want to override the default screen matrix resolution when gdl::Set2Dmode() is called.

Note
Changing the 2D projection matrix resolution does not actually change the current screen resolution, just the 2D projection matrix and thus, it is not advisable to use this function in low-resolution mode if you want to maintain pixel perfect rendering.
Parameters
[in]xresX resolution of 2D projection matrix.
[in]yresY resolution of 2D projection matrix.

◆ Set2DMode()

void gdl::Set2DMode ( float  farClip = 100.f)

Sets the current projection matrix into an orthographic 2D projection matrix.

This is the default projection mode set whenever gdl::PrepDisplay() is called. Use this projection mode for drawing 2D graphics. You can still do 3D graphics in this mode but it'll be rendered orthographically (no depth).

Note
Calling this function also resets the current model matrix and disables depth testing.
Parameters
[in]farClipDepth clip range (also mirrored for the negative clip range).

◆ Set3DMode()

void gdl::Set3DMode ( float  farClip = 1000.f)

Sets the current projection matrix into a 3D projection matrix.

This projection mode is most ideal for rendering 3D graphics.

Note
Calling this function also resets the current model matrix and enables depth testing. However, it does not set vertex format descriptors for rendering 3D geometry so you'll have to set your own. Whilst setting up your own vertex format descriptor, do not use GX_VTXFMT0 as that is reserved for the library's 2D graphics functions.
Parameters
[in]farClipFar distance clip range.

◆ SetClearColor() [1/2]

void gdl::SetClearColor ( u_char  red,
u_char  grn,
u_char  blu,
u_char  alp 
)

Sets the clear color.

Sets the color used when the screen gets cleared.

Note
This function does not affect the background color in console mode.
Parameters
[in]redRed component value.
[in]grnGreen component value.
[in]bluBlue component value.
[in]alpAlpha component value.

◆ SetClearColor() [2/2]

void gdl::SetClearColor ( u_int  color)

Sets the clear color.

Sets the color used when the screen gets cleared.

Note
This function does not affect the background color in console mode.
Parameters
[in]color

◆ SetClipBox()

void gdl::SetClipBox ( short  x1,
short  y1,
short  x2,
short  y2 
)

Sets the clip box.

Sets the position of the clip box. It uses the scissor box functions of the GX to achieve clipping.

Note
If the box range is outside the screen, it is automatically clipped. Also, the clip box is reset whenever gdl::PrepDisplay() is called.
This function also affects 3D rendering which means graphics will only be drawn within the specified clip box range.
Parameters
[in]x1,y12D screen coordinate of the top-left position of the box.
[in]x2,y22D screen coordinate of the bottom-right position of the box.

◆ SetErrorCallback()

gdl::ErrorCallback gdl::SetErrorCallback ( gdl::ErrorCallback  func)

Sets an error callback function.

Sets a function which will be called when an error occurs in the library. To properly define an error callback function, specify parameters myFunc(const char *message) where *message points to a string of the error message.

Parameters
[in]funcFunction to set as the error handler.
Returns
Pointer to previous error callback function.