Linux there is no TurboC2.0 like the drawing point, line, circle graphics function library, there is no grapihcs.h, or the corresponding or similar function library is what? Is there a game development library like DirectX? SDL is one of them.
The SDL (Simple DirectMedia Layer) is a platform-based multimedia game support library that includes support for graphics, sound, joystick, threading, and so on, which can now run on many platforms, including Linux framebuffer consoles, Svgalib, X window environments, and Windows DirectX, BeOS, and more. SDL is an excellent platform for authoring platform-based gaming and multimedia applications, with a ratio of DirectX to Windows. Home: http://www.libsdl.org.
The SDL Library has almost become the standard multimedia library for Linux as it is now popular, and it is usually installed by default when the system is installed. Using the SDL library to develop an application, first of all, to declare the appropriate header file to be used in the program, such as: #include <sdl/sdl.h>, and then, at compile time, point to the SDL library to be connected, such as: gcc-lsdl test.c-o test. The SDL library is generally located in the system's standard header file directory/usr/include, the compiler will find the corresponding header file in this directory, if you want to further omit "sdl/", you must specify the location of the header file at compile time, for example: Gcc-i/usr/include/sdl- LSDL test.c-o test. You can also: gcc ' sdl-config-libs-cflags ' test.c-o test. "'" is not a single quotation mark, but an anti-quote at the top left of the keyboard.
to develop graphics in the context of the Linux console character interface, open the Framebuffer feature by modifying the/boot/grub/grub.conf configuration file in kernel ... Add vga=0x317 after a row. as follows:
title Fedora Core (2.6.15-1.2054_FC5)
root (hd0,5)
kernel/vmlinuz-2.6.15-1.2054_fc5 ro root=label=/rhgb quiet vga=0x0317
initrd/initrd-2.6.15-1.2054_fc5.img
about the relationship between the VGA value and the display resolution, such as table:
640x480 800x600 1024x768 1280x1024
8-bit color 0x301 0x303 0x305 0x307
16-bit color 0x311 0x314 0x317 0x31a
24-bit color 0x312 0x315 0x318 0x31b
Initializing graphics Mode
to load and initialize the SDL library you need to call the Sdl_init () function, which passes a parameter to the token of the subsystem to be activated, and returns 1 to indicate that the initialization failed.
The following table lists the various subsystems for SDL:
Token representation
Sdl_init_video Video Subsystem
Sdl_init_audio Audio Subsystem
Sdl_init_cdrom Optical Drive Subsystem
Sdl_init_timer Timer Subsystem
sdl_init_joystick Game Pole System
sdl_init_everything All subsystems
to activate multiple subsystems at the same time, the corresponding tag can be bitwise OR, for example: Sdl_init (sdl_init_video| Sdl_init_audio);
after initializing the SDL library, you also need to set up the video mode by calling Sdl_setvideomode () to complete:
sdl_surface *screen;
Screen=sdl_etvideomode (640,480,16,sdl_swsurface);/*640 x 480 x 16-bit color */
sdl_surface is defined in Sdl_video.h, which is a drawing plane in which all the drawing operations are done. Automatically processed by SDL when exiting graphics mode. Release to display when not required: sdl_freesurface (surface);
Let's take a look at a complete example:
//ex_sdl.c
#include <stdlib.h>
#include <SDL.h>
int main ()
{
sdl_surface *screen;
Uint32 color;
if (Sdl_init (Sdl_init_video) < 0) {
fprintf (stderr, "Unable to initialize SDL:%s\n", Sdl_geterror ());
exit (1);
}
sdl_showcursor (0);
Screen = Sdl_setvideomode (640, 480, sdl_swsurface); /*640 x 480 x 16-bit color * /
if (screen = = NULL) {
fprintf (stderr, "Unable to set the video mode of 640x480x16 bit color:%s\n", Sdl_geterror ());
exit (1);
}
atexit (sdl_quit);
color = Sdl_maprgb (screen->format,0,0,255); /* Blue * /
Sdl_fillrect (Screen,&screen->clip_rect,color); /* Full Screen Fill color * /
Sdl_updaterect (screen,0,0,0,0); /* Update entire screen * /
Sdl_delay (5000); /* Delay 5 seconds * /
}
the function of atexit (Sdl_quit) is to invoke the Sdl_quit () function when the program exits, so that you do not have to call Sdl_quit () at each point where you want to exit.
Linux x86 clipping Migration---Character interface introduction to SDL development