zenilib: zenilib/jni/external/sdl/src/video/dummy/SDL_nullvideo.c Source File

zenilib 0.5.3.0

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SDL_nullvideo.c
Go to the documentation of this file.
1 /*
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
4
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any damages
7 arising from the use of this software.
8
9 Permission is granted to anyone to use this software for any purpose,
10 including commercial applications, and to alter it and redistribute it
11 freely, subject to the following restrictions:
12
13 1. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must not be
18 misrepresented as being the original software.
19 3. This notice may not be removed or altered from any source distribution.
20 */
21 #include "SDL_config.h"
22
23 #if SDL_VIDEO_DRIVER_DUMMY
24
25 /* Dummy SDL video driver implementation; this is just enough to make an
26 * SDL-based application THINK it's got a working video driver, for
27 * applications that call SDL_Init(SDL_INIT_VIDEO) when they don't need it,
28 * and also for use as a collection of stubs when porting SDL to a new
29 * platform for which you haven't yet written a valid video driver.
30 *
31 * This is also a great way to determine bottlenecks: if you think that SDL
32 * is a performance problem for a given platform, enable this driver, and
33 * then see if your application runs faster without video overhead.
34 *
35 * Initial work by Ryan C. Gordon (icculus@icculus.org). A good portion
36 * of this was cut-and-pasted from Stephane Peter's work in the AAlib
37 * SDL video driver. Renamed to "DUMMY" by Sam Lantinga.
38 */
39
40 #include "SDL_video.h"
41 #include "SDL_mouse.h"
42 #include "../SDL_sysvideo.h"
43 #include "../SDL_pixels_c.h"
44 #include "../../events/SDL_events_c.h"
45
46 #include "SDL_nullvideo.h"
47 #include "SDL_nullevents_c.h"
48 #include "SDL_nullframebuffer_c.h"
49
50 #define DUMMYVID_DRIVER_NAME "dummy"
51
52 /* Initialization/Query functions */
53 static int DUMMY_VideoInit(_THIS);
54 static int DUMMY_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
55 static void DUMMY_VideoQuit(_THIS);
56
57 /* DUMMY driver bootstrap functions */
58
59 static int
60 DUMMY_Available(void)
61 {
62 const char *envr = SDL_getenv("SDL_VIDEODRIVER");
63 if ((envr) && (SDL_strcmp(envr, DUMMYVID_DRIVER_NAME) == 0)) {
64 return (1);
65 }
66
67 return (0);
68 }
69
70 static void
71 DUMMY_DeleteDevice(SDL_VideoDevice * device)
72 {
73 SDL_free(device);
74 }
75
76 static SDL_VideoDevice *
77 DUMMY_CreateDevice(int devindex)
78 {
79 SDL_VideoDevice *device;
80
81 /* Initialize all variables that we clean on shutdown */
82 device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
83 if (!device) {
84 SDL_OutOfMemory();
85 SDL_free(device);
86 return (0);
87 }
88
89 /* Set the function pointers */
90 device->VideoInit = DUMMY_VideoInit;
91 device->VideoQuit = DUMMY_VideoQuit;
92 device->SetDisplayMode = DUMMY_SetDisplayMode;
93 device->PumpEvents = DUMMY_PumpEvents;
94 device->CreateWindowFramebuffer = SDL_DUMMY_CreateWindowFramebuffer;
95 device->UpdateWindowFramebuffer = SDL_DUMMY_UpdateWindowFramebuffer;
96 device->DestroyWindowFramebuffer = SDL_DUMMY_DestroyWindowFramebuffer;
97
98 device->free = DUMMY_DeleteDevice;
99
100 return device;
101 }
102
103 VideoBootStrap DUMMY_bootstrap = {
104 DUMMYVID_DRIVER_NAME, "SDL dummy video driver",
105 DUMMY_Available, DUMMY_CreateDevice
106 };
107
108
109 int
110 DUMMY_VideoInit(_THIS)
111 {
112 SDL_DisplayMode mode;
113
114 /* Use a fake 32-bpp desktop mode */
115 mode.format = SDL_PIXELFORMAT_RGB888;
116 mode.w = 1024;
117 mode.h = 768;
118 mode.refresh_rate = 0;
119 mode.driverdata = NULL;
120 if (SDL_AddBasicVideoDisplay(&mode) < 0) {
121 return -1;
122 }
123
124 SDL_zero(mode);
125 SDL_AddDisplayMode(&_this->displays[0], &mode);
126
127 /* We're done! */
128 return 0;
129 }
130
131 static int
132 DUMMY_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
133 {
134 return 0;
135 }
136
137 void
138 DUMMY_VideoQuit(_THIS)
139 {
140 }
141
142 #endif /* SDL_VIDEO_DRIVER_DUMMY */
143
144 /* vi: set ts=4 sw=4 expandtab: */
SDL_VideoDevice::UpdateWindowFramebuffer
int(* UpdateWindowFramebuffer)(_THIS, SDL_Window *window, const SDL_Rect *rects, int numrects)
Definition: SDL_sysvideo.h:204
SDL_calloc
DECLSPEC void *SDLCALL SDL_calloc(size_t nmemb, size_t size)
NULL
#define NULL
Definition: ftobjs.h:61
SDL_DisplayMode::w
int w
Definition: SDL_video.h:56
SDL_AddBasicVideoDisplay
int SDL_AddBasicVideoDisplay(const SDL_DisplayMode *desktop_mode)
Definition: SDL_video.c:554
SDL_free
DECLSPEC void SDLCALL SDL_free(void *mem)
SDL_DisplayMode
The structure that defines a display mode.
Definition: SDL_video.h:53
SDL_DisplayMode::refresh_rate
int refresh_rate
Definition: SDL_video.h:58
display
char * display
Definition: visualinfo.c:85
SDL_config.h
SDL_VideoDevice::free
void(* free)(_THIS)
Definition: SDL_sysvideo.h:327
_this
static SDL_VideoDevice * _this
Definition: SDL_video.c:92
SDL_VideoDevice::DestroyWindowFramebuffer
void(* DestroyWindowFramebuffer)(_THIS, SDL_Window *window)
Definition: SDL_sysvideo.h:205
SDL_nullframebuffer_c.h
SDL_video.h
SDL_DUMMY_DestroyWindowFramebuffer
void SDL_DUMMY_DestroyWindowFramebuffer(_THIS, SDL_Window *window)
SDL_DUMMY_UpdateWindowFramebuffer
int SDL_DUMMY_UpdateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_Rect *rects, int numrects)
SDL_VideoDevice::VideoInit
int(* VideoInit)(_THIS)
Definition: SDL_sysvideo.h:148
_THIS
#define _THIS
Definition: SDL_alsa_audio.h:31
SDL_DisplayMode::driverdata
void * driverdata
Definition: SDL_video.h:59
SDL_mouse.h
VideoBootStrap
Definition: SDL_sysvideo.h:330
SDL_VideoDevice::displays
SDL_VideoDisplay * displays
Definition: SDL_sysvideo.h:265
SDL_DisplayMode::h
int h
Definition: SDL_video.h:57
SDL_strcmp
DECLSPEC int SDLCALL SDL_strcmp(const char *str1, const char *str2)
Definition: SDL_string.c:910
SDL_VideoDevice::PumpEvents
void(* PumpEvents)(_THIS)
Definition: SDL_sysvideo.h:237
DUMMY_PumpEvents
void DUMMY_PumpEvents(_THIS)
SDL_nullvideo.h
SDL_nullevents_c.h
SDL_VideoDisplay
Definition: SDL_sysvideo.h:113
SDL_OutOfMemory
#define SDL_OutOfMemory()
Definition: SDL_error.h:52
SDL_VideoDevice::SetDisplayMode
int(* SetDisplayMode)(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode)
Definition: SDL_sysvideo.h:177
SDL_VideoDevice
Definition: SDL_sysvideo.h:135
SDL_VideoDevice::VideoQuit
void(* VideoQuit)(_THIS)
Definition: SDL_sysvideo.h:154
SDL_AddDisplayMode
SDL_bool SDL_AddDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode *mode)
Definition: SDL_video.c:666
SDL_VideoDevice::CreateWindowFramebuffer
int(* CreateWindowFramebuffer)(_THIS, SDL_Window *window, Uint32 *format, void **pixels, int *pitch)
Definition: SDL_sysvideo.h:203
SDL_PIXELFORMAT_RGB888
Definition: SDL_pixels.h:212
SDL_getenv
DECLSPEC char *SDLCALL SDL_getenv(const char *name)
Definition: SDL_getenv.c:179
SDL_zero
#define SDL_zero(x)
Definition: SDL_stdinc.h:254
SDL_DisplayMode::format
Uint32 format
Definition: SDL_video.h:55
mode
GLenum mode
Definition: glew.h:2394
SDL_DUMMY_CreateWindowFramebuffer
int SDL_DUMMY_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format, void **pixels, int *pitch)