📄 whatsnew
字号:
This is a list of API changes in SDL's version history.Version 1.0:1.2.5: Added SDL_BUTTON_WHEELUP (4) and SDL_BUTTON_WHEELDOWN (5) Added SDL_GL_STEREO for stereoscopic OpenGL contexts1.2.0: Added SDL_VIDEOEXPOSE event to signal that the screen needs to be redrawn. This is currently only delivered to OpenGL windows on X11, though it may be delivered in the future when the video memory is lost under DirectX.1.1.8: You can pass SDL_NOFRAME to SDL_VideoMode() to create a window that has no title bar or frame decoration. Fullscreen video modes automatically have this flag set. Added a function to query the clipping rectangle for a surface: void SDL_GetClipRect(SDL_Surface *surface, SDL_Rect *rect) Added a function to query the current event filter: SDL_EventFilter SDL_GetEventFilter(void) If you pass -1 to SDL_ShowCursor(), it won't change the current cursor visibility state, but will still return it. SDL_LockSurface() and SDL_UnlockSurface() are recursive, meaning you can nest them as deep as you want, as long as each lock call has a matching unlock call. The surface remains locked until the last matching unlock call. Note that you may not blit to or from a locked surface.1.1.7: The SDL_SetGammaRamp() and SDL_GetGammaRamp() functions now take arrays of Uint16 values instead of Uint8 values. For the most part, you can just take your old values and shift them up 8 bits to get new correct values for your gamma ramps. You can pass SDL_RLEACCEL in flags passed to SDL_ConvertSurface() and SDL will try to RLE accelerate colorkey and alpha blits in the resulting surface.1.1.6: Added a function to return the thread ID of a specific thread: Uint32 SDL_GetThreadID(SDL_Thread *thread) If 'thread' is NULL, this function returns the id for this thread.1.1.5: The YUV overlay structure has been changed to use an array of pitches and pixels representing the planes of a YUV image, to better enable hardware acceleration. The YV12 and IYUV formats each have three planes, corresponding to the Y, U, and V portions of the image, while packed pixel YUV formats just have one plane. For palettized mode (8bpp), the screen colormap is now split in a physical and a logical palette. The physical palette determines what colours the screen pixels will get when displayed, and the logical palette controls the mapping from blits to/from the screen. A new function, SDL_SetPalette() has been added to change logical and physical palettes separately. SDL_SetColors() works just as before, and is equivalent to calling SDL_SetPalette() with a flag argument of (SDL_LOGPAL|SDL_PHYSPAL). SDL_BlitSurface() no longer modifies the source rectangle, only the destination rectangle. The width/height members of the destination rectangle are ignored, only the position is used. The old source clipping function SDL_SetClipping() has been replaced with a more useful function to set the destination clipping rectangle: SDL_bool SDL_SetClipRect(SDL_Surface *surface, SDL_Rect *rect) Added a function to see what subsystems have been initialized: Uint32 SDL_WasInit(Uint32 flags) The Big Alpha Flip: SDL now treats alpha as opacity like everybody else, and not as transparency: A new cpp symbol: SDL_ALPHA_OPAQUE is defined as 255 A new cpp symbol: SDL_ALPHA_TRANSPARENT is defined as 0 Values between 0 and 255 vary from fully transparent to fully opaque. New functions: SDL_DisplayFormatAlpha() Returns a surface converted to a format with alpha-channel that can be blit efficiently to the screen. (In other words, like SDL_DisplayFormat() but the resulting surface has an alpha channel.) This is useful for surfaces with alpha. SDL_MapRGBA() Works as SDL_MapRGB() but takes an additional alpha parameter. SDL_GetRGBA() Works as SDL_GetRGB() but also returns the alpha value (SDL_ALPHA_OPAQUE for formats without an alpha channel) Both SDL_GetRGB() and SDL_GetRGBA() now always return values in the [0..255] interval. Previously, SDL_GetRGB() would return (0xf8, 0xfc, 0xf8) for a completely white pixel in RGB565 format. (N.B.: This is broken for bit fields < 3 bits.) SDL_MapRGB() returns pixels in which the alpha channel is set opaque. SDL_SetAlpha() can now be used for both setting the per-surface alpha, using the new way of thinking of alpha, and also to enable and disable per-pixel alpha blending for surfaces with an alpha channel: To disable alpha blending: SDL_SetAlpha(surface, 0, 0); To re-enable alpha blending: SDL_SetAlpha(surface, SDL_SRCALPHA, 0); Surfaces with an alpha channel have blending enabled by default. SDL_SetAlpha() now accepts SDL_RLEACCEL as a flag, which requests RLE acceleration of blits, just as like with SDL_SetColorKey(). This flag can be set for both surfaces with an alpha channel and surfaces with an alpha value set by SDL_SetAlpha(). As always, RLE surfaces must be locked before pixel access is allowed, and unlocked before any other SDL operations are done on it. The blit semantics for surfaces with and without alpha and colorkey have now been defined: RGBA->RGB: SDL_SRCALPHA set: alpha-blend (using alpha-channel). SDL_SRCCOLORKEY ignored. SDL_SRCALPHA not set: copy RGB. if SDL_SRCCOLORKEY set, only copy the pixels matching the RGB values of the source colour key, ignoring alpha in the comparison. RGB->RGBA: SDL_SRCALPHA set: alpha-blend (using the source per-surface alpha value); set destination alpha to opaque. SDL_SRCALPHA not set: copy RGB, set destination alpha to opaque. both: if SDL_SRCCOLORKEY set, only copy the pixels matching the source colour key. RGBA->RGBA: SDL_SRCALPHA set: alpha-blend (using the source alpha channel) the RGB values; leave destination alpha untouched. [Note: is this correct?] SDL_SRCCOLORKEY ignored. SDL_SRCALPHA not set: copy all of RGBA to the destination. if SDL_SRCCOLORKEY set, only copy the pixels matching the RGB values of the source colour key, ignoring alpha in the comparison. RGB->RGB: SDL_SRCALPHA set: alpha-blend (using the source per-surface alpha value). SDL_SRCALPHA not set: copy RGB. both: if SDL_SRCCOLORKEY set, only copy the pixels matching the source colour key. As a special case, blits from surfaces with per-surface alpha value of 128 (50% transparency) are optimised and much faster than other alpha values. This does not apply to surfaces with alpha channels (per-pixel alpha). New functions for manipulating the gamma of the display have been added: int SDL_SetGamma(float red, float green, float blue); int SDL_SetGammaRamp(Uint8 *red, Uint8 *green, Uint8 *blue); int SDL_GetGammaRamp(Uint8 *red, Uint8 *green, Uint8 *blue); Gamma ramps are tables with 256 entries which map the screen color components into actually displayed colors. For an example of implementing gamma correction and gamma fades, see test/testgamma.c Gamma control is not supported on all hardware.1.1.4: The size of the SDL_CDtrack structure changed from 8 to 12 bytes as the size of the length member was extended to 32 bits. You can now use SDL for 2D blitting with a GL mode by passing the SDL_OPENGLBLIT flag to SDL_SetVideoMode(). You can specify 16 or 32 bpp, and the data in the framebuffer is put into the GL scene when you call SDL_UpdateRects(), and the scene will be visible when you call SDL_GL_SwapBuffers(). Run the "testgl" test program with the -logo command line option to see an example of this blending of 2D and 3D in SDL.1.1.3: Added SDL_FreeRW() to the API, to complement SDL_AllocRW() Added resizable window support - just add SDL_RESIZABLE to the SDL_SetVideoMode() flags, and then wait for SDL_VIDEORESIZE events. See SDL_events.h for details on the new SDL_ResizeEvent structure. Added condition variable support, based on mutexes and semaphores. SDL_CreateCond() SDL_DestroyCond() SDL_CondSignal() SDL_CondBroadcast() SDL_CondWait() SDL_CondTimedWait() The new function prototypes are in SDL_mutex.h Added counting semaphore support, based on the mutex primitive. SDL_CreateSemaphore() SDL_DestroySemaphore() SDL_SemWait() SDL_SemTryWait() SDL_SemWaitTimeout() SDL_SemPost() SDL_SemValue() The new function prototypes are in SDL_mutex.h Added support for asynchronous blitting. To take advantage of this, you must set the SDL_ASYNCBLIT flag when setting the video mode and creating surfaces that you want accelerated in this way. You must lock surfaces that have this flag set, and the lock will block until any queued blits have completed. Added YUV video overlay support. The supported YUV formats are: YV12, IYUV, YUY2, UYVY, and YVYU. This function creates an overlay surface: SDL_CreateYUVOverlay() You must lock and unlock the overlay to get access to the data: SDL_LockYUVOverlay() SDL_UnlockYUVOverlay() You can then display the overlay: SDL_DisplayYUVOverlay() You must free the overlay when you are done using it: SDL_FreeYUVOverlay() See SDL_video.h for the full function prototypes. The joystick hat position constants have been changed: Old constant New constant ------------ ------------ 0 SDL_HAT_CENTERED 1 SDL_HAT_UP 2 SDL_HAT_RIGHTUP 3 SDL_HAT_RIGHT 4 SDL_HAT_RIGHTDOWN 5 SDL_HAT_DOWN 6 SDL_HAT_LEFTDOWN 7 SDL_HAT_LEFT 8 SDL_HAT_LEFTUP The new constants are bitmasks, so you can check for the individual axes like this: if ( hat_position & SDL_HAT_UP ) { } and you'll catch left-up, up, and right-up.1.1.2: Added multiple timer support: SDL_AddTimer() and SDL_RemoveTimer() SDL_WM_SetIcon() now respects the icon colorkey if mask is NULL.1.1.0: Added initial OpenGL support. First set GL attributes (such as RGB depth, alpha depth, etc.) SDL_GL_SetAttribute() Then call SDL_SetVideoMode() with the SDL_OPENGL flag. Perform all of your normal GL drawing. Finally swap the buffers with the new SDL function: SDL_GL_SwapBuffers() See the new 'testgl' test program for an example of using GL with SDL. You can load GL extension functions by using the function: SDL_GL_LoadProcAddress() Added functions to initialize and cleanup specific SDL subsystems: SDL_InitSubSystem() and SDL_QuitSubSystem() Added user-defined event type: typedef struct { Uint8 type; int code; void *data1; void *data2; } SDL_UserEvent; This structure is in the "user" member of an SDL_Event. Added a function to push events into the event queue: SDL_PushEvent() Example of using the new SDL user-defined events: { SDL_Event event; event.type = SDL_USEREVENT; event.user.code = my_event_code; event.user.data1 = significant_data; event.user.data2 = 0; SDL_PushEvent(&event); } Added a function to get mouse deltas since last query: SDL_GetRelativeMouseState() Added a boolean datatype to SDL_types.h: SDL_bool = { SDL_TRUE, SDL_FALSE } Added a function to get the current audio status: SDL_GetAudioState(); It returns one of: SDL_AUDIO_STOPPED, SDL_AUDIO_PLAYING, SDL_AUDIO_PAUSED Added an AAlib driver (ASCII Art) - by Stephane Peter.1.0.6: The input grab state is reset after each call to SDL_SetVideoMode(). The input is grabbed by default in fullscreen mode, and ungrabbed in windowed mode. If you want to set input grab to a particular value, you should set it after each call to SDL_SetVideoMode().1.0.5: Exposed SDL_AudioInit(), SDL_VideoInit() Added SDL_AudioDriverName() and SDL_VideoDriverName() Added new window manager function: SDL_WM_ToggleFullScreen() This is currently implemented only on Linux The ALT-ENTER code has been removed - it's not appropriate for a lib to bind keys when they aren't even emergency escape sequences. ALT-ENTER functionality can be implemented with the following code:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -