Video drivers and modes

Video drivers and modes — Video drivers and modes

Functions

Types and Values

Includes

#include <grx-3.0.h>

Description

GRX3 uses video "driver" plugins to provide the graphics back end. For most programs using GRX3, the driver and it's parameters will be automatically selected. The driver and parameters can be manually specified using the GRX_DRIVER environment variable (see grx_set_driver() for details). The search path for the video driver plugins can also be manually specified using the GRX_PLUGIN_PATH enviornment variable (useful for development).

Each video driver can have mutiple video modes. Video modes specify the resolution (width and height in pixels) and the color depth (bits per pixel). Most programs will just call grx_set_mode_default_graphics() to automatically select the default mode of the video driver.

Each video driver also has an associated device manager for interacting with input devices such as keyboards, mice and touchscreens.

Functions

grx_set_driver ()

gboolean
grx_set_driver (const gchar *driver_spec,
                GError **error);

The driver spec is of the format "[<name>[::<flag>]] [gw <width>] [gh <height>] [gc <colors>] [dp <dpi>]".

  • "<name>" is the name of a video driver plugin.

  • "<flag>" is "fs" for fullscreen or "ww" for windowed (not supported by all drivers)

  • "<width>" is the default width

  • "<height>" is the default height

  • "<colors>" is the default color depth. "K" and "M" suffixes are recognized.

  • "<dpi>" the display resolution in dots per inch.

If driver_spec is NULL, then it will first check the GRX_DRIVER environment variable for a driver spec. If the environment variable is not present, then it will uses the driver with the highest number of modes.

Parameters

driver_spec

The driver spec.

[nullable]

error

Error pointer.

 

Returns

TRUE on success, otherwise FALSE.


grx_set_mode ()

gboolean
grx_set_mode (GrxGraphicsMode mode,
              GError **error,
              ...);

Set the graphics mode.

If a driver has not already been set, this will attempt to load the best available driver (the one with the most modes). The driver will then try to find the mode that best fits the size and color depth parameters. The exact behavior will depend on the video driver.

[skip]

Parameters

mode

The graphics mode.

 

error

Error pointer.

 

...

Extra parameters determined by mode .

 

Returns

TRUE on success, otherwise FALSE.


grx_set_mode_default_graphics ()

gboolean
grx_set_mode_default_graphics (gboolean clear,
                               GError **error);

Set the mode to the default graphics mode.

This is 640x480x16 by default but can be changed by grx_set_driver().

Parameters

clear

If TRUE, clear the screen after setting the mode.

 

error

Error pointer.

 

Returns

TRUE on success, otherwise FALSE.


grx_get_dpi ()

guint
grx_get_dpi (void);

Gets the display resolution of the current graphics mode or GRX_DEFAULT_DPI if the current driver does not support getting the resolution.

The display resolution can also be manually specified using grx_set_driver() or the GRX_DRIVER environment variable.

Returns

the resolution in dots per inch


grx_get_device_manager ()

GrxDeviceManager *
grx_get_device_manager (void);

Gets the device manager for the current video driver

Returns

the GrxDeviceManager or NULL if a video driver has not be loaded yet.

[transfer none][nullable]


grx_get_current_video_driver ()

const GrxVideoDriver *
grx_get_current_video_driver (void);

grx_get_current_video_mode ()

const GrxVideoMode *
grx_get_current_video_mode (void);

grx_get_virtual_video_mode ()

const GrxVideoMode *
grx_get_virtual_video_mode (void);

grx_get_current_frame_driver ()

const GrxFrameDriver *
grx_get_current_frame_driver (void);

grx_get_screen_frame_driver ()

const GrxFrameDriver *
grx_get_screen_frame_driver (void);

grx_get_first_video_mode ()

const GrxVideoMode *
grx_get_first_video_mode (GrxFrameMode mode);

grx_get_next_video_mode ()

const GrxVideoMode *
grx_get_next_video_mode (const GrxVideoMode *prev);

Types and Values

enum GrxGraphicsMode

available video modes (for grx_set_mode())

Members

GRX_GRAPHICS_MODE_UNKNOWN

Unknown mode / initial state

 

GRX_GRAPHICS_MODE_TEXT_DEFAULT

Default text mode

 

GRX_GRAPHICS_MODE_TEXT_80X25

Standard 80x25 text mode

 

GRX_GRAPHICS_MODE_TEXT_WIDTH_HEIGHT

Text mode with parameters int w, int h

 

GRX_GRAPHICS_MODE_TEXT_WIDTH_HEIGHT_COLOR

Text mode with parameters int w, int h, GrxColor nc

 

GRX_GRAPHICS_MODE_TEXT_WIDTH_HEIGHT_BPP

Text mode with parameters int w, int h, int bpp

 

GRX_GRAPHICS_MODE_GRAPHICS_DEFAULT

Default graphics mode

 

GRX_GRAPHICS_MODE_GRAPHICS_WIDTH_HEIGHT

Graphics mode with parameters int w, int h

 

GRX_GRAPHICS_MODE_GRAPHICS_WIDTH_HEIGHT_COLOR

Graphics mode with parameters int w, int h, GrxColor nc

 

GRX_GRAPHICS_MODE_GRAPHICS_WIDTH_HEIGHT_BPP

Graphics mode with parameters int w, int h, int bpp

 

GRX_GRAPHICS_MODE_GRAPHICS_CUSTOM

Graphics mode with parameters int w, int h, GrxColor nc, int vx, int vy

 

GRX_GRAPHICS_MODE_GRAPHICS_CUSTOM_BPP

Graphics mode with parameters int w, int h, int bpp, int vx, int vy

 

GRX_GRAPHICS_MODE_TEXT_DEFAULT_NC

Same as GRX_GRAPHICS_MODE_TEXT_DEFAULT but does not clear video memory

 

GRX_GRAPHICS_MODE_TEXT_80X25_NC

Same as GRX_GRAPHICS_MODE_TEXT_80X25 but does not clear video memory

 

GRX_GRAPHICS_MODE_TEXT_WIDTH_HEIGHT_NC

Same as GRX_GRAPHICS_MODE_TEXT_WIDTH_HEIGHT but does not clear video memory

 

GRX_GRAPHICS_MODE_TEXT_WIDTH_HEIGHT_COLOR_NC

Same as GRX_GRAPHICS_MODE_TEXT_WIDTH_HEIGHT_COLOR but does not clear video memory

 

GRX_GRAPHICS_MODE_TEXT_WIDTH_HEIGHT_BPP_NC

Same as GRX_GRAPHICS_MODE_TEXT_WIDTH_HEIGHT_BPP but does not clear video memory

 

GRX_GRAPHICS_MODE_GRAPHICS_DEFAULT_NC

Same as GRX_GRAPHICS_MODE_GRAPHICS_DEFAULT but does not clear video memory

 

GRX_GRAPHICS_MODE_GRAPHICS_WIDTH_HEIGHT_NC

Same as GRX_GRAPHICS_MODE_GRAPHICS_WIDTH_HEIGHT but does not clear video memory

 

GRX_GRAPHICS_MODE_GRAPHICS_WIDTH_HEIGHT_COLOR_NC

Same as GRX_GRAPHICS_MODE_GRAPHICS_WIDTH_HEIGHT_COLOR but does not clear video memory

 

GRX_GRAPHICS_MODE_GRAPHICS_WIDTH_HEIGHT_BPP_NC

Same as GRX_GRAPHICS_MODE_GRAPHICS_WIDTH_HEIGHT_BPP but does not clear video memory

 

GRX_GRAPHICS_MODE_GRAPHICS_CUSTOM_NC

Same as GRX_GRAPHICS_MODE_GRAPHICS_CUSTOM but does not clear video memory

 

GRX_GRAPHICS_MODE_GRAPHICS_CUSTOM_BPP_NC

Same as GRX_GRAPHICS_MODE_GRAPHICS_CUSTOM_BPP but does not clear video memory

 

enum GrxVideoDriverFlags

Flags used by GrxVideoDriver.

Members

GRX_VIDEO_DRIVER_FLAG_USER_RESOLUTION

Driver supports arbitrary user-specified resolution.

 

GrxVideoDriver

typedef struct {
} GrxVideoDriver;

The video driver descriptor structure.


GrxVideoMode

typedef struct {
} GrxVideoMode;

Video driver mode descriptor structure.


enum GrxVideoModeFlags

Video mode flag bits (in the GrxVideoModeExt structure)

Members

GRX_VIDEO_MODE_FLAG_LINEAR

Uses linear memory mapping

 

GRX_VIDEO_MODE_FLAG_ACCEL

Uses an accelerated video mode

 

GRX_VIDEO_MODE_FLAG_FAST_SVGA8

Uses faster mixed-planar access

 

GRX_VIDEO_MODE_FLAG_MEMORY

Uses memory only (virtual screen)

 

GrxVideoModeExt

typedef struct {
} GrxVideoModeExt;

Video driver mode descriptor extension structure. This is a separate structure accessed via a pointer from the main mode descriptor. The reason for this is that frequently several modes can share the same extended info.


GrxFrameDriver

typedef struct {
} GrxFrameDriver;

The frame driver descriptor structure.


GRX_DEFAULT_DPI

#define GRX_DEFAULT_DPI 100

The default screen resolution (dots per inch).

Used when graphics drivers do not support getting the actual screen resolution.