set_gfx_mode man page

set_gfx_mode — Sets a graphic video mode. Allegro game programming library.


#include <allegro.h>

int set_gfx_mode(int card, int w, int h, int v_w, int v_h);


Switches into graphics mode. The card parameter should usually be one of the Allegro magic drivers (read introduction of chapter "Graphics modes") or see the platform specific documentation for a list of the available drivers. The w and h parameters specify what screen resolution you want. The color depth of the graphic mode has to be specified before calling this function with set_color_depth().

The v_w and v_h parameters specify the minimum virtual screen size, in case you need a large virtual screen for hardware scrolling or page flipping. You should set them to zero if you don't care about the virtual screen size.

When you call set_gfx_mode(), the v_w and v_h parameters represent the minimum size of virtual screen that is acceptable for your program. The range of possible sizes is usually very restricted, and Allegro may end up creating a virtual screen much larger than the one you request. Allowed sizes are driver dependent and some drivers do not allow virtual screens that are larger than the visible screen at all: don't assume that whatever you pass will always work.

In mode-X the virtual width can be any multiple of eight greater than or equal to the physical screen width, and the virtual height will be set accordingly (the VGA has 256k of vram, so the virtual height will be 256*1024/virtual_width).

Currently, using a big virtual screen for page flipping is considered bad practice. There are platforms which don't support virtual screens bigger than the physical screen but can create different video pages to flip back and forth. This means that, if you want page flipping and aren't going to use hardware scrolling, you should call set_gfx_mode() with (0,0) as the virtual screen size and later create the different video pages with create_video_bitmap(). Otherwise your program will be limited to the platforms supporting hardware scrolling.

After you select a graphics mode, the physical and virtual screen sizes can be checked with the macros SCREEN_W, SCREEN_H, VIRTUAL_W, and VIRTUAL_H.

Return Value

Returns zero on success. On failure returns a negative number and stores a description of the problem in allegro_error.

See Also

set_color_depth(3), request_refresh_rate(3), screen(3), gfx_capabilities(3), allegro_error(3), create_video_bitmap(3), get_desktop_resolution(3), SCREEN_W(3), SCREEN_H(3), VIRTUAL_W(3), VIRTUAL_H(3)

Referenced By

allegro_error(3), desktop_color_depth(3), destroy_gfx_mode_list(3), ex12bit(3), ex3buf(3), ex3d(3), exaccel(3), exalpha(3), exbitmap(3), exblend(3), excamera(3), excolmap(3), exconfig(3), excustom(3), exdata(3), exdbuf(3), exexedat(3), exflame(3), exflip(3), exfont(3), exgui(3), exhello(3), exjoy(3), exkeys(3), exlights(3), exmem(3), exmidi(3), exmouse(3), expackf(3), expal(3), expat(3), exquat(3), exrgbhsv(3), exrotscl(3), exsample(3), exscale(3), exscn3d(3), exscroll(3), exshade(3), exspline(3), exsprite(3), exstars(3), exstream(3), exswitch(3), exsyscur(3), extimer(3), extrans(3), extrans2(3), extruec(3), exunicod(3), exupdate(3), exxfade(3), exzbuf(3), fixup_datafile(3), get_desktop_resolution(3), get_gfx_mode(3), get_gfx_mode_list(3), get_gfx_mode_type(3), gfx_mode_select(3), gfx_mode_select_ex(3), gfx_mode_select_filter(3), install_keyboard(3), is_windowed_mode(3), request_refresh_rate(3), screen(3), SCREEN_W(3), scroll_screen(3), _set_color(3), set_color_depth(3), set_palette(3), VIRTUAL_W(3).

Explore man page connections for set_gfx_mode(3).

Allegro version 4.4.2 Allegro manual