SDL Library
Embed:
(wiki syntax)
Show/hide line numbers
SDL_shape.h
Go to the documentation of this file.
00001 /* 00002 Simple DirectMedia Layer 00003 Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org> 00004 00005 This software is provided 'as-is', without any express or implied 00006 warranty. In no event will the authors be held liable for any damages 00007 arising from the use of this software. 00008 00009 Permission is granted to anyone to use this software for any purpose, 00010 including commercial applications, and to alter it and redistribute it 00011 freely, subject to the following restrictions: 00012 00013 1. The origin of this software must not be misrepresented; you must not 00014 claim that you wrote the original software. If you use this software 00015 in a product, an acknowledgment in the product documentation would be 00016 appreciated but is not required. 00017 2. Altered source versions must be plainly marked as such, and must not be 00018 misrepresented as being the original software. 00019 3. This notice may not be removed or altered from any source distribution. 00020 */ 00021 00022 #ifndef _SDL_shape_h 00023 #define _SDL_shape_h 00024 00025 #include "SDL_stdinc.h" 00026 #include "SDL_pixels.h" 00027 #include "SDL_rect.h" 00028 #include "SDL_surface.h" 00029 #include "SDL_video.h" 00030 00031 #include "begin_code.h" 00032 /* Set up for C function definitions, even when using C++ */ 00033 #ifdef __cplusplus 00034 extern "C" { 00035 #endif 00036 00037 /** \file SDL_shape.h 00038 * 00039 * Header file for the shaped window API. 00040 */ 00041 00042 #define SDL_NONSHAPEABLE_WINDOW -1 00043 #define SDL_INVALID_SHAPE_ARGUMENT -2 00044 #define SDL_WINDOW_LACKS_SHAPE -3 00045 00046 /** 00047 * \brief Create a window that can be shaped with the specified position, dimensions, and flags. 00048 * 00049 * \param title The title of the window, in UTF-8 encoding. 00050 * \param x The x position of the window, ::SDL_WINDOWPOS_CENTERED, or 00051 * ::SDL_WINDOWPOS_UNDEFINED. 00052 * \param y The y position of the window, ::SDL_WINDOWPOS_CENTERED, or 00053 * ::SDL_WINDOWPOS_UNDEFINED. 00054 * \param w The width of the window. 00055 * \param h The height of the window. 00056 * \param flags The flags for the window, a mask of SDL_WINDOW_BORDERLESS with any of the following: 00057 * ::SDL_WINDOW_OPENGL, ::SDL_WINDOW_INPUT_GRABBED, 00058 * ::SDL_WINDOW_HIDDEN, ::SDL_WINDOW_RESIZABLE, 00059 * ::SDL_WINDOW_MAXIMIZED, ::SDL_WINDOW_MINIMIZED, 00060 * ::SDL_WINDOW_BORDERLESS is always set, and ::SDL_WINDOW_FULLSCREEN is always unset. 00061 * 00062 * \return The window created, or NULL if window creation failed. 00063 * 00064 * \sa SDL_DestroyWindow() 00065 */ 00066 extern DECLSPEC SDL_Window * SDLCALL SDL_CreateShapedWindow(const char *title,unsigned int x,unsigned int y,unsigned int w,unsigned int h,Uint32 flags); 00067 00068 /** 00069 * \brief Return whether the given window is a shaped window. 00070 * 00071 * \param window The window to query for being shaped. 00072 * 00073 * \return SDL_TRUE if the window is a window that can be shaped, SDL_FALSE if the window is unshaped or NULL. 00074 * \sa SDL_CreateShapedWindow 00075 */ 00076 extern DECLSPEC SDL_bool SDLCALL SDL_IsShapedWindow(const SDL_Window *window); 00077 00078 /** \brief An enum denoting the specific type of contents present in an SDL_WindowShapeParams union. */ 00079 typedef enum { 00080 /** \brief The default mode, a binarized alpha cutoff of 1. */ 00081 ShapeModeDefault, 00082 /** \brief A binarized alpha cutoff with a given integer value. */ 00083 ShapeModeBinarizeAlpha, 00084 /** \brief A binarized alpha cutoff with a given integer value, but with the opposite comparison. */ 00085 ShapeModeReverseBinarizeAlpha, 00086 /** \brief A color key is applied. */ 00087 ShapeModeColorKey 00088 } WindowShapeMode; 00089 00090 #define SDL_SHAPEMODEALPHA(mode) (mode == ShapeModeDefault || mode == ShapeModeBinarizeAlpha || mode == ShapeModeReverseBinarizeAlpha) 00091 00092 /** \brief A union containing parameters for shaped windows. */ 00093 typedef union { 00094 /** \brief a cutoff alpha value for binarization of the window shape's alpha channel. */ 00095 Uint8 binarizationCutoff; 00096 SDL_Color colorKey; 00097 } SDL_WindowShapeParams; 00098 00099 /** \brief A struct that tags the SDL_WindowShapeParams union with an enum describing the type of its contents. */ 00100 typedef struct SDL_WindowShapeMode { 00101 /** \brief The mode of these window-shape parameters. */ 00102 WindowShapeMode mode; 00103 /** \brief Window-shape parameters. */ 00104 SDL_WindowShapeParams parameters; 00105 } SDL_WindowShapeMode; 00106 00107 /** 00108 * \brief Set the shape and parameters of a shaped window. 00109 * 00110 * \param window The shaped window whose parameters should be set. 00111 * \param shape A surface encoding the desired shape for the window. 00112 * \param shape_mode The parameters to set for the shaped window. 00113 * 00114 * \return 0 on success, SDL_INVALID_SHAPE_ARGUMENT on invalid an invalid shape argument, or SDL_NONSHAPEABLE_WINDOW 00115 * if the SDL_Window* given does not reference a valid shaped window. 00116 * 00117 * \sa SDL_WindowShapeMode 00118 * \sa SDL_GetShapedWindowMode. 00119 */ 00120 extern DECLSPEC int SDLCALL SDL_SetWindowShape(SDL_Window *window,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode); 00121 00122 /** 00123 * \brief Get the shape parameters of a shaped window. 00124 * 00125 * \param window The shaped window whose parameters should be retrieved. 00126 * \param shape_mode An empty shape-mode structure to fill, or NULL to check whether the window has a shape. 00127 * 00128 * \return 0 if the window has a shape and, provided shape_mode was not NULL, shape_mode has been filled with the mode 00129 * data, SDL_NONSHAPEABLE_WINDOW if the SDL_Window given is not a shaped window, or SDL_WINDOW_LACKS_SHAPE if 00130 * the SDL_Window* given is a shapeable window currently lacking a shape. 00131 * 00132 * \sa SDL_WindowShapeMode 00133 * \sa SDL_SetWindowShape 00134 */ 00135 extern DECLSPEC int SDLCALL SDL_GetShapedWindowMode(SDL_Window *window,SDL_WindowShapeMode *shape_mode); 00136 00137 /* Ends C function definitions when using C++ */ 00138 #ifdef __cplusplus 00139 } 00140 #endif 00141 #include "close_code.h" 00142 00143 #endif /* _SDL_shape_h */
Generated on Tue Jul 12 2022 15:10:20 by 1.7.2