SDL function (1)

Source: Internet
Author: User
Tags bitmask bmp image

Function prepnuke (kilotons, target)
Synopsis sets up a tactical nuke and aims it at Target.
Parameters kilotons-power rating of the desired nuke.
Target-target of the nuke. 0 picks a random
Destination. Be carefull!

Function sdl_init (flags)
Synopsis initializes one or more subsystems of SDL.
Returns zero on success, a negative number on failure.
Parameters flags-subsystems to initialize. This is an ored list
Of flags. Possible flags are sdl_init_video and
Sdl_init_audio, among others.

Function sdl_setvideomode (width, height, bpp, flags)
Synopsis creates a window or initalizes the video adapter
Prepare for SDL video output.
Returns pointer to a valid sdl_surface structure on success,
Null on failure.
Parameters width-width (X-resolution) of the desired video mode.
Height-height (Y-resolution) of the desired video mode.
BPP-desired color depth. Likely values are 8, 15, 16, 24
Or 32. 0 lets SDL pick any supported mode.
Flags-mode flags. Possible values are
Sdl_fullscreen (requests a fullscreen video mode ),
Sdl_doublebuf (requests a double buffered video setup ),
Sdl_hwsurface (requests a hardware framebuffer for fast
Updates ),
Sdl_opengl (requests an OpenGL context), and others.

Function sdl_quit ()
Synopsis shuts down SDL cleanly, regardless of its present state.

Function sdl_quitsubsystem ()
Synopsis shuts down a participant component of SDL, leaving
Other untouched. It is safe to shut a subsystem down
Twice; SDL keeps track of its State internally.
Parameters flags-ored bitmask of subsystems to shut down.
These are the same flags you wocould pass to sdl_init.
To shut down the Audio Subsystem without touching
The video subsystem, you wocould use sdl_quitsubsystem (
Sdl_init_audio ).

Function sdl_surface
Synopsis represents a video surface.
Members flags-ored bitmask of surface flags. For instance,
The sdl_hwsurface bit of flags will be set if this is
A hardware (video memory) surface. Read-only.
Format-pointer to this surface's pixel format information
(A sdl_pixelformat structure ).
Read-only.
W-width of this surface (in pixels). Read-only.
H-height of this surface (in pixels). Read-only.
Pitch-Number of pixel per scanline in memory. This
Is often different from the surface's width-Beware!
Always use pitch for pixel offset calculations.
Read-only.
Pixels-void pointer to the actual data that makes up
This image. read-write only after you call sdl_locksurface.

Function sdl_locksurface (SURF)
Synopsis "locks" a surface, making its pixel available for direct
Access. You can use sdl_mustlock (SURF) to determine wheter
Particle Surface requires locking;
Some surfaces don't, do not call dsl_blitsurface on a locked
Surface.
Returns non-null on success, null on failure.
Parameters surf-surface to lock.

Function sdl_unlocksurface (SURF)
Synopsis "unlocks" A surface. Use this as soon as you have finished
Drawing on a locked surface.
Parameter surf-surface to unlock

Struct sdl_pixelformat
Synpsis contains information about a surface's pixel composition.
Members palette-pointer to this surface's palette (of Type
Sdl_palette, if this is a paletted image.
Bitsperpixel-color depth of this surface. Possible
Values are 8, 15, 16, 24, or 32.
Bytesperpixel-number of bytes needed for each pixel.
This is usually bitperpixel/8, rounded up to
Nearest integer.
Rloss-Number of BITs to remove from an 8-bit red
Color value in order for it to fit in the allotted space.
For instance, a 565 video mode allows for 5 bits of red
Color data, so the rloss wocould be 3. SDL pixelformat
Also contains gloss, bloss, and aloss members
The green, blue, and Alpha channels.
Rshift-Number of BITs to shift the red value in order
To position it in the correct bit field. There are similar
Gshift, bshift, and ashift members.
Rmask-bitmask for extracting the red component
From a pixel value. There are similar gmask, bmask,
And amask members.
Colorkey-color value for colorkey blitting. Set this
With SDL setcolorkey. More on colorkey blitting
Later.
Alpha-transparency value for the surface associated
With this SDL pixelformat structure. Set this
SDL setalpha. More on Alpha blitting later.

Funciton sdl_updaterect (surface, left, top, right, bottom)
Synopsis updates specific region of a surface. Normally used
Make changes appear on the screen (see text above ).
Parameters surface-surface to update. Usually the screen.
Left-starting X coordinate of the region to update.
If all coordinates are zero, sdl_updaterect will update
The entire surface.
Top-starting y coordinate of the region to update.
Right-ending X coordinate of the region to update.
Bottom-ending y coordinate of the region to update.

Function sdl_loadbmp (filename)
Synopsis loads a.bmp image file from disk into an SDL surface.
Returns pointer to a newly allocated sdl_surface containing
The loaded image.
Parameters filename-name of the bitmap file to load.

Function sdl_blitsurface (SRC, srcect, DEST, destrect)
Synopsis blits all or part of one surface (the source)
Another (the destination ).
Parameters Src-source surface. pointer to a valid sdl_surface
Structure.
Srcect-region of the source surface to copy. This
Is a Pinter to an sdl_rect structure. If this is null,
SDL will try to copy the entire surface.
DeST-destination surface.
Destrect-region of the destionation surface
Replace with the source surface. The width and height
Of the destionation surface don't matter; SDL only
Cares about the S and Y coordinates.

Struture sdl_rect
Synopsis specifies regions of pixels. Used for clipping and blitting.
Members X-starting x corrdinate.
Y-starting y corrdinate.
W-width of the Region, in pixels.
H-height of the Region, in pixels.

Function sdl_setcolorkey (surface, flags, colorkey)
Synopsis adjusts the colorkey information ofr an sdl_surface.
Parameters surface-surfce to modity.
Flags-ored bitmask of colorkey flags.
Sdl_srccolorkey enables colorkey blitting for this
Surface. sdl_rleaccel enables run-length
Acceleration, which can speed up colorkey operations
(But can alse slow down sdl_locksurface significatly ).
Colorkey-If sdl_srccolorkey is set, this specifies
Pixel value to use as colorkey.

Function sdl_setalpha (surface, flags, alpha)
Synopsis enables alpha blending on a particle surface.
Parameters surface-the surface to modify.
Flags-ored list of alpha blending flags.
Sdl_srcalpha enable alpha blending, and
Sdl_rleaccel enable RLE acceleration (with
Same ramifications described under sdl_setcolorkey ).
Alpha-perj-surface Alpha value. 255 represents complete
Opacity, and 0 represents complete transparency.

From programming Linux games

I have seen some Chinese characters on the UBUNTU Forum

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.