SDL tutorial (1)
Author: akinggw
After half a year, I came back again. This time, first you have to ask you, then continue our game development journey. In the previous days, I mainly translate some articles in some game development, and now I decide yourself. From today, I want to introduce you a very famous game development library - SDL.
What is SDL (Simple DirectMedia Layer)? According to his surface, translation is a simple guidance media layer. Its official website please visit http://www.libsdl.org.
SDL logo
The SDL's author is the main programmer of Sam Lantinga, Loki Entertainment Software (LEAD Programmer). Loki Entertainment is a company dedicated to grading top games to Linux. For more information, please visit http://www.lokigames.com/
SDL is a 3D hardware, and 2D image frame buffers that are used to access audio, keyboard, mouse, joystick, OpenGL (a 3D image development function library) on low-level. It is widely used in MPEG-based media playing software, simulators, and many famous games. The most famous game is the civilization of the LIUNX group game development award: CIVilization: Call to Power.
Civilization: Call of Rights (CIVilization: Call to Power)
SDL is a cross-platform library, almost all platforms today: Linux, Windows, Windows CE, BEOS, MACOS, Mac OS X, FreeBSD, NetBSD, OpenBSD, BSD / OS, Solaris, Irix, and QNX.
SDL is written in C language, but it can be easily working under C , and SDL is bound to many other languages, including Ada, C #, Eiffel, Erlang, Euphoria, Guile, Haskell, Java, Lisp, Lua, ML , Objective C, Pascal, Perl, PHP, Pike, Pliant, Python, Ruby, And Smalltalk.
Finally, let's take a look at the copyright issues of SDL, and SDL is released under GNU LGPL 2 (an international open source organization). This version allows you to use SDL for free for commercial software development.
Below, let's learn more about the function of SDL, which is conducive to our future explanation.
What are the functions of SDL?
video
• Set video modes for any color depth of 8bpp or higher. If a mode hardware is not supported, you can choose to convert to another mode.
· Directly write a linear image frame buffer (FrameBuffer).
· Create Surface with color key (colorKey) or Alpha mixed attribute.
· Surface's BlI can automatically convert to the target format.
Blit is optimized and can use hardware acceleration. There is a Blit optimized for MMX on the X86 platform.
· Hardware accelerated Blit and Fill (padding) operations if hardware support.
event
· Provide the following event: o Apps Visibility Event Change O Keyboard Enter O Mouse Enter O User Requirements
· Each event can be turned off or turned on by SDL_EventState (). • The event is added to the internal event queue by the filter function specified by the user.
· Thread security event queue.
Audio
• Set 8-bit and 16-bit audio, mono or stereo, if the format hardware does not support, you can select the conversion.
• Execute the audio portion by a standalone thread and provide a Callback mechanism.
· Designing the customer-customized soft miscope, but in practice, a complete audio / music output library is included in the routine. CD audio · Complete CD audio control API thread
· Simple thread creation API
· Simple binary semaphore for synchronization (Semaphores Timer
· Read the number of milliseconds that have passed.
· Waiting for the specified millisecond.
· Set a periodic timer that is 10 millisecond accuracy. Nothing
· Detect the word sequence of the current system
· Function of fast conversion data
· Read and write data for specified word sequence
The above is the rough function introduction of SDL, the above introduction comes from the SDL Chinese introduction document. But many subsequent developers are constantly improving SDL. So, now SDL is not light energy to implement the above basic functions.
There is also the features listed below:
A. Support for MPG, PNG, GIF and other compressed image file formats;
B. Supports the display of TrueType fonts;
C. With SDL_NET, the network can be implemented;
I will introduce SDL's content in detail in the future. I plan to introduce the basic functions of SDL first, which is the functions listed above and implementation, and give a complete code. Then I will introduce the features and methods of using SDL_NET and write a complete instance in the future.
I hope everyone will pay more, support!
For more information, please visit the Golden Bridge Science website (http://popul.jqcq.com) Game development section, if you need a book development, please refer to Jinqiao Book City Game Channel (http://book.jqcq.com/category /1_70_740.html). If you have any good suggestions when you read this article, please let me, my e_mail: akinggw@126.com. If you have any questions when using SDL, please go to the Jinqiao Scot website (http: // popul. JQCQ.com) Game Development section, I will answer your questions in detail.
In the next article, we will enter the development of SDL, I will explain how to configure SDL in VC 6.0, and write our first programs.
Really been waiting! ! ! ! ! ! ! ! ! !