annotate src/video/photon/SDL_ph_video.c @ 266:c6abdda2f666

Added QNX cleanups by Mike Gorchak (thanks!)
author Sam Lantinga <slouken@libsdl.org>
date Fri, 18 Jan 2002 18:14:03 +0000
parents e8157fcb3114
children 04351f59b051
rev   line source
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1 /*
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2 SDL - Simple DirectMedia Layer
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
3 Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
4
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
6 modify it under the terms of the GNU Library General Public
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
8 version 2 of the License, or (at your option) any later version.
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
9
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
13 Library General Public License for more details.
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
14
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
15 You should have received a copy of the GNU Library General Public
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
16 License along with this library; if not, write to the Free
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
18
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
19 Sam Lantinga
252
e8157fcb3114 Updated the source with the correct e-mail address
Sam Lantinga <slouken@libsdl.org>
parents: 204
diff changeset
20 slouken@libsdl.org
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
21 */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
22
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
23 #ifdef SAVE_RCSID
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
24 static char rcsid =
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
25 "@(#) $Id$";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
26 #endif
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
27
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
28 #include <stdlib.h>
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
29 #include <stdio.h>
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
30 #include <unistd.h>
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
31 #include <string.h>
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
32 #include <sys/ioctl.h>
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
33
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
34 #include "SDL.h"
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
35 #include "SDL_error.h"
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
36 #include "SDL_timer.h"
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
37 #include "SDL_thread.h"
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
38 #include "SDL_video.h"
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
39 #include "SDL_mouse.h"
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
40 #include "SDL_endian.h"
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
41 #include "SDL_sysvideo.h"
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
42 #include "SDL_pixels_c.h"
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
43 #include "SDL_events_c.h"
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
44 #include "SDL_ph_video.h"
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
45 #include "SDL_ph_modes_c.h"
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
46 #include "SDL_ph_image_c.h"
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
47 #include "SDL_ph_events_c.h"
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
48 #include "SDL_ph_mouse_c.h"
19
8cc4dbfab9ab Date: Thu, 19 Apr 2001 08:36:54 +0300
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
49 #include "SDL_ph_wm_c.h"
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
50 #include "SDL_phyuv_c.h"
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
51 #include "blank_cursor.h"
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
52
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
53 static int ph_VideoInit(_THIS, SDL_PixelFormat *vformat);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
54 static SDL_Surface *ph_SetVideoMode(_THIS, SDL_Surface *current,
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
55 int width, int height, int bpp, Uint32 flags);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
56 static int ph_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
57 static void ph_VideoQuit(_THIS);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
58 static void ph_DeleteDevice(SDL_VideoDevice *device);
266
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
59 static void ph_GL_SwapBuffers(_THIS);
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
60
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
61 PdOpenGLContext_t* OGLContext=NULL;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
62
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
63 static int ph_Available(void)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
64 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
65 return 1;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
66 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
67
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
68 static SDL_VideoDevice *ph_CreateDevice(int devindex)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
69 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
70 SDL_VideoDevice *device;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
71
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
72 /* Initialize all variables that we clean on shutdown */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
73 device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice));
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
74 if ( device ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
75 memset(device, 0, (sizeof *device));
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
76 device->hidden = (struct SDL_PrivateVideoData *)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
77 malloc((sizeof *device->hidden));
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
78 device->gl_data = NULL;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
79 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
80 if ( (device == NULL) || (device->hidden == NULL) ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
81 SDL_OutOfMemory();
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
82 ph_DeleteDevice(device);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
83 return(0);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
84 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
85 memset(device->hidden, 0, (sizeof *device->hidden));
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
86
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
87 /* Set the driver flags */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
88 device->handles_any_size = 1; //JB not true for fullscreen
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
89
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
90 /* Set the function pointers */
266
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
91 device->CreateYUVOverlay = ph_CreateYUVOverlay;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
92 device->VideoInit = ph_VideoInit;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
93 device->ListModes = ph_ListModes;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
94 device->SetVideoMode = ph_SetVideoMode;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
95 device->ToggleFullScreen = ph_ToggleFullScreen;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
96 device->UpdateMouse = NULL;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
97 device->SetColors = ph_SetColors;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
98 device->UpdateRects = NULL; //set in ph_ResizeImage
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
99 device->VideoQuit = ph_VideoQuit;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
100 device->AllocHWSurface = ph_AllocHWSurface;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
101 device->CheckHWBlit = NULL;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
102 device->FillHWRect = NULL;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
103 device->SetHWColorKey = NULL;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
104 device->SetHWAlpha = NULL;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
105 device->LockHWSurface = ph_LockHWSurface;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
106 device->UnlockHWSurface = ph_UnlockHWSurface;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
107 device->FlipHWSurface = ph_FlipHWSurface;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
108 device->FreeHWSurface = ph_FreeHWSurface;
19
8cc4dbfab9ab Date: Thu, 19 Apr 2001 08:36:54 +0300
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
109 device->SetCaption = ph_SetCaption;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
110 device->SetIcon = NULL;
19
8cc4dbfab9ab Date: Thu, 19 Apr 2001 08:36:54 +0300
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
111 device->IconifyWindow = ph_IconifyWindow;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
112 device->GrabInput = NULL;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
113 device->GetWMInfo = NULL;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
114 device->FreeWMCursor = ph_FreeWMCursor;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
115 device->CreateWMCursor = ph_CreateWMCursor;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
116 device->ShowWMCursor = ph_ShowWMCursor;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
117 device->WarpWMCursor = ph_WarpWMCursor;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
118 device->CheckMouseMode = ph_CheckMouseMode;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
119 device->InitOSKeymap = ph_InitOSKeymap;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
120 device->PumpEvents = ph_PumpEvents;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
121
266
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
122 // OpenGL support.
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
123 device->GL_LoadLibrary = NULL;
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
124 device->GL_GetProcAddress = NULL;
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
125 device->GL_GetAttribute = NULL;
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
126 device->GL_MakeCurrent = NULL;
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
127 device->GL_SwapBuffers = ph_GL_SwapBuffers;
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
128
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
129 device->free = ph_DeleteDevice;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
130
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
131 return device;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
132 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
133
19
8cc4dbfab9ab Date: Thu, 19 Apr 2001 08:36:54 +0300
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
134 VideoBootStrap ph_bootstrap = {
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
135 "photon", "QNX Photon video output",
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
136 ph_Available, ph_CreateDevice
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
137 };
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
138
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
139 static void ph_DeleteDevice(SDL_VideoDevice *device)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
140 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
141
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
142 if ( device ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
143 if ( device->hidden ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
144 free(device->hidden);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
145 device->hidden = NULL;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
146 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
147 if ( device->gl_data ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
148 free(device->gl_data);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
149 device->gl_data = NULL;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
150 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
151 free(device);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
152 device = NULL;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
153 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
154 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
155
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
156 static int ph_VideoInit(_THIS, SDL_PixelFormat *vformat)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
157 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
158 PtArg_t arg[1];
266
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
159 PhDim_t dim;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
160 PgColor_t ph_palette[_Pg_MAX_PALETTE];
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
161 int i;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
162 unsigned long *tempptr;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
163 int rtnval;
266
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
164 // PgDisplaySettings_t mysettings;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
165 PgVideoModeInfo_t my_mode_info;
204
62bad9a82022 Added photon fixes submitted by Luca Barbato
Sam Lantinga <slouken@libsdl.org>
parents: 19
diff changeset
166 PgHWCaps_t my_hwcaps;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
167
266
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
168 if( NULL == ( event = malloc( EVENT_SIZE ) ) )
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
169 exit( EXIT_FAILURE );
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
170
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
171 /* Create a widget 'window' to capture events */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
172 dim.w=0; //JB test320;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
173 dim.h=0; //JB test240;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
174 //We need to return BytesPerPixel as it in used by CreateRGBsurface
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
175
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
176 PtSetArg(&arg[0], Pt_ARG_DIM, &dim,0);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
177
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
178 /*
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
179 PtSetArg(&arg[1], Pt_ARG_RESIZE_FLAGS, Pt_TRUE, Pt_RESIZE_XY_AS_REQUIRED);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
180 PtSetArg(&arg[2], Pt_ARG_WINDOW_STATE, Pt_TRUE, Ph_WM_STATE_ISFRONT |
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
181 Ph_WM_STATE_ISMAX |
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
182 Ph_WM_STATE_ISFOCUS);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
183
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
184 PtSetArg(&arg[3], Pt_ARG_WINDOW_RENDER_FLAGS,Pt_FALSE,~0);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
185 PtSetArg(&arg[4], Pt_ARG_WINDOW_MANAGED_FLAGS,Pt_TRUE,
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
186 Ph_WM_FFRONT |
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
187 Ph_WM_CLOSE |
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
188 Ph_WM_TOFRONT |
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
189 Ph_WM_CONSWITCH);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
190 */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
191
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
192
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
193 window=PtAppInit(NULL, NULL, NULL, 1, arg);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
194
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
195 if(window == NULL)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
196 {
19
8cc4dbfab9ab Date: Thu, 19 Apr 2001 08:36:54 +0300
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
197 printf("Photon application init failed, probably Photon is not running.\n");
8cc4dbfab9ab Date: Thu, 19 Apr 2001 08:36:54 +0300
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
198 exit( EXIT_FAILURE );
8cc4dbfab9ab Date: Thu, 19 Apr 2001 08:36:54 +0300
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
199 // PtExit(EXIT_FAILURE); // Got SEGFAULT.
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
200 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
201
266
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
202 //PgSetDrawBufferSize(16 *1024);
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
203 PgSetRegion(PtWidgetRid(window));
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
204 PgSetClipping(0,NULL);
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
205 PtRealizeWidget(window);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
206
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
207
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
208 /* Get the available video modes */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
209 // if(ph_GetVideoModes(this) < 0)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
210 // return -1;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
211
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
212 /* Create the blank cursor */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
213 SDL_BlankCursor = this->CreateWMCursor(this, blank_cdata, blank_cmask,
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
214 (int)BLANK_CWIDTH, (int)BLANK_CHEIGHT,
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
215 (int)BLANK_CHOTX, (int)BLANK_CHOTY);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
216
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
217 if(SDL_BlankCursor == NULL)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
218 printf("could not create blank cursor\n");
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
219 /* Get the video mode */
204
62bad9a82022 Added photon fixes submitted by Luca Barbato
Sam Lantinga <slouken@libsdl.org>
parents: 19
diff changeset
220 /*
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
221 if (PgGetVideoMode( &mysettings ) < 0)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
222 {
204
62bad9a82022 Added photon fixes submitted by Luca Barbato
Sam Lantinga <slouken@libsdl.org>
parents: 19
diff changeset
223 fprintf(stderr,"ph_VideoInit: PgGetVideoMode failed patch A?? \n");
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
224 //QNX6/Patch A always fails return code even though call succeeds. fixed Patch B
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
225 }
204
62bad9a82022 Added photon fixes submitted by Luca Barbato
Sam Lantinga <slouken@libsdl.org>
parents: 19
diff changeset
226 */
62bad9a82022 Added photon fixes submitted by Luca Barbato
Sam Lantinga <slouken@libsdl.org>
parents: 19
diff changeset
227 if (PgGetGraphicsHWCaps(&my_hwcaps) < 0)
266
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
228 {
204
62bad9a82022 Added photon fixes submitted by Luca Barbato
Sam Lantinga <slouken@libsdl.org>
parents: 19
diff changeset
229 fprintf(stderr,"ph_VideoInit: GetGraphicsHWCaps failed!! \n");
62bad9a82022 Added photon fixes submitted by Luca Barbato
Sam Lantinga <slouken@libsdl.org>
parents: 19
diff changeset
230 //that HAVE to work
266
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
231 }
204
62bad9a82022 Added photon fixes submitted by Luca Barbato
Sam Lantinga <slouken@libsdl.org>
parents: 19
diff changeset
232 if (PgGetVideoModeInfo(my_hwcaps.current_video_mode, &my_mode_info) < 0)
266
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
233 {
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
234 fprintf(stderr,"ph_VideoInit: PgGetVideoModeInfo failed\n");
266
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
235 }
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
236
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
237 //We need to return BytesPerPixel as it in used by CreateRGBsurface
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
238 vformat->BitsPerPixel = my_mode_info.bits_per_pixel;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
239 vformat->BytesPerPixel = vformat->BitsPerPixel/8;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
240
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
241 //return a palette if we are in 256 color mode
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
242 if(vformat->BitsPerPixel == 8)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
243 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
244 vformat->palette = malloc(sizeof(SDL_Palette));
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
245 memset(vformat->palette, 0, sizeof(SDL_Palette));
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
246 vformat->palette->ncolors = 256;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
247 vformat->palette->colors = (SDL_Color *)malloc(256 *sizeof(SDL_Color));
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
248
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
249 //fill the palette
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
250 rtnval = PgGetPalette(ph_palette);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
251 if(rtnval < 0)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
252 printf("ph_VideoInit: PgGetPalette failed\n");
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
253
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
254 tempptr = (unsigned long *)vformat->palette->colors;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
255
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
256 for(i=0;i<256; i++)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
257 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
258 *tempptr = (((unsigned long)ph_palette[i]) << 8);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
259 tempptr++;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
260
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
261 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
262
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
263 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
264
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
265
19
8cc4dbfab9ab Date: Thu, 19 Apr 2001 08:36:54 +0300
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
266 currently_fullscreen = 0;
8cc4dbfab9ab Date: Thu, 19 Apr 2001 08:36:54 +0300
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
267
8cc4dbfab9ab Date: Thu, 19 Apr 2001 08:36:54 +0300
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
268 this->info.wm_available = 1;
8cc4dbfab9ab Date: Thu, 19 Apr 2001 08:36:54 +0300
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
269
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
270 return 0;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
271 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
272
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
273 static SDL_Surface *ph_SetVideoMode(_THIS, SDL_Surface *current,
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
274 int width, int height, int bpp, Uint32 flags)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
275 {
266
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
276 // PhRegion_t region_info;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
277 PgDisplaySettings_t settings;
204
62bad9a82022 Added photon fixes submitted by Luca Barbato
Sam Lantinga <slouken@libsdl.org>
parents: 19
diff changeset
278 PgHWCaps_t my_hwcaps;
266
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
279 PgVideoModeInfo_t mode_info;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
280 int mode, actual_width, actual_height;
266
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
281 PtArg_t arg[5];
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
282 PhDim_t dim;
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
283 int rtnval;
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
284 PgColor_t ph_palette[_Pg_MAX_PALETTE];
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
285 int i;
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
286 unsigned long *tempptr;
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
287 uint64_t OGLAttrib[PH_OGL_MAX_ATTRIBS];
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
288
266
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
289 actual_width = width;
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
290 actual_height = height;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
291
266
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
292 dim.w=width;
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
293 dim.h=height;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
294
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
295 /* Lock the event thread, in multi-threading environments */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
296 SDL_Lock_EventThread();
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
297
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
298 /* Initialize the window */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
299 if (flags & SDL_FULLSCREEN) //Direct Context , assume SDL_HWSURFACE also set
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
300 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
301 /*
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
302 if (old_video_mode==-1)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
303 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
304 PgGetGraphicsHWCaps(&graphics_card_caps);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
305 old_video_mode=graphics_card_caps.current_video_mode;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
306 old_refresh_rate=graphics_card_caps.current_rrate;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
307 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
308 */
266
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
309
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
310 /* Get the video mode and set it */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
311 if (bpp == 0)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
312 {
204
62bad9a82022 Added photon fixes submitted by Luca Barbato
Sam Lantinga <slouken@libsdl.org>
parents: 19
diff changeset
313 /*again same issue, same solution
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
314 if (PgGetVideoMode( &settings ) < 0)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
315 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
316 fprintf(stderr,"error: PgGetVideoMode failed\n");
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
317 }
204
62bad9a82022 Added photon fixes submitted by Luca Barbato
Sam Lantinga <slouken@libsdl.org>
parents: 19
diff changeset
318 */
266
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
319 if (PgGetGraphicsHWCaps(&my_hwcaps) < 0)
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
320 {
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
321 fprintf(stderr,"ph_SetVideoMode: GetGraphicsHWCaps failed!! \n");
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
322 //that HAVE to work
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
323 }
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
324 if (PgGetVideoModeInfo(my_hwcaps.current_video_mode, &mode_info) < 0)
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
325 {
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
326 fprintf(stderr,"ph_SetVideoMode: PgGetVideoModeInfo failed\n");
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
327 }
204
62bad9a82022 Added photon fixes submitted by Luca Barbato
Sam Lantinga <slouken@libsdl.org>
parents: 19
diff changeset
328 bpp = mode_info.bits_per_pixel;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
329 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
330 if (flags & SDL_ANYFORMAT)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
331 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
332 if ((mode = get_mode_any_format(width, height, bpp)) == 0)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
333 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
334 fprintf(stderr,"error: get_mode_any_format failed\n");
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
335 exit(1);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
336 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
337 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
338 else
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
339 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
340 if ((mode = get_mode(width, height, bpp)) == 0)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
341 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
342 fprintf(stderr,"error: get_mode failed\n");
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
343 exit(1);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
344 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
345
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
346
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
347 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
348 settings.mode = mode;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
349 settings.refresh = 0;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
350 settings.flags = 0;
266
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
351
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
352 if (PgSetVideoMode( &settings ) < 0)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
353 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
354 fprintf(stderr,"error: PgSetVideoMode failed\n");
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
355 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
356
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
357 /* Get the true height and width */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
358
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
359 current->flags = (flags|(~SDL_RESIZABLE)); //no resize for Direct Context
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
360
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
361 /* Begin direct mode */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
362 ph_EnterFullScreen(this);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
363
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
364
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
365
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
366 } //end fullscreen flag
266
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
367 else
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
368 {
266
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
369 if (flags & SDL_HWSURFACE) /* Use offscreen memory iff SDL_HWSURFACE flag is set */
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
370 {
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
371 // Hardware surface is Offsceen Context. ph_ResizeImage handles the switch
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
372 current->flags = (flags|(~SDL_RESIZABLE)); //no stretch blit in offscreen context
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
373 }
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
374 else // must be SDL_SWSURFACE
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
375 {
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
376 current->flags = (flags|SDL_RESIZABLE); //yes we can resize as this is a software surface
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
377 }
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
378
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
379 if (flags & SDL_OPENGL) // for now support OpenGL in window mode only
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
380 {
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
381 OGLAttrib[0]=PHOGL_ATTRIB_DEPTH_BITS;
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
382 OGLAttrib[1]=bpp;
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
383 OGLAttrib[2]=PHOGL_ATTRIB_NONE;
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
384 OGLContext=PdCreateOpenGLContext(2, &dim, 0, OGLAttrib);
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
385 if (OGLContext==NULL)
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
386 {
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
387 fprintf(stderr,"error: cannot create OpenGL context\n");
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
388 exit(1);
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
389 }
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
390 PhDCSetCurrent(OGLContext);
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
391 }
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
392
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
393 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
394
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
395 //If we are setting video to use the palette make sure we have allocated memory for it
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
396 if(bpp == 8)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
397 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
398 current->format->palette = malloc(sizeof(SDL_Palette));
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
399 memset(current->format->palette, 0, sizeof(SDL_Palette));
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
400 current->format->palette->ncolors = 256;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
401 current->format->palette->colors = (SDL_Color *)malloc(256 *sizeof(SDL_Color));
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
402 //fill the palette
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
403 rtnval = PgGetPalette(ph_palette);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
404
266
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
405 tempptr = (unsigned long *)current->format->palette->colors;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
406
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
407 for(i=0;i<256; i++)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
408 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
409 *tempptr = (((unsigned long)ph_palette[i]) << 8);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
410 tempptr++;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
411
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
412 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
413 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
414
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
415
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
416 //Current window dimensions
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
417 PtGetResource( window, Pt_ARG_DIM, &dim, 0 );
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
418
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
419 //If we need to resize the window
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
420 if((dim.w != width)||(dim.h != height))
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
421 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
422 dim.w=width;
266
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
423 dim.h=height;
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
424 PtSetArg(&arg[0], Pt_ARG_DIM, &dim,0);
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
425 PtSetResources( window, 1, arg );
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
426 current->w = width;
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
427 current->h = height;
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
428 current->format->BitsPerPixel = bpp;
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
429 current->format->BytesPerPixel = bpp/8;
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
430 current->pitch = SDL_CalculatePitch(current);
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
431 //Must call at least once it setup image planes
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
432 ph_ResizeImage(this, current, flags);
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
433 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
434
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
435
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
436 SDL_Unlock_EventThread();
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
437
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
438 /* We're done! */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
439 return(current);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
440 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
441
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
442 static void ph_VideoQuit(_THIS)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
443 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
444
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
445 if(SDL_Image != NULL)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
446 {
266
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
447 ph_DestroyImage(this, SDL_VideoSurface);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
448 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
449
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
450 if (currently_fullscreen)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
451 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
452 PdDirectStop( directContext );
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
453 PdReleaseDirectContext( directContext );
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
454 directContext=0;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
455 currently_fullscreen = 0;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
456 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
457
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
458 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
459
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
460
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
461 static int ph_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
462 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
463 PgColor_t *in, *out;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
464 int i, j;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
465 int alloct_all = 1;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
466
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
467 colors = this->screen->format->palette->colors;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
468
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
469 in = alloca( ncolors*sizeof(PgColor_t) );
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
470 if ( in == NULL ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
471 return 0;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
472 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
473 memset(in,0,ncolors*sizeof(PgColor_t));
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
474
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
475 out = alloca( ncolors*sizeof(PgColor_t) );
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
476 if ( out == NULL ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
477 return 0;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
478 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
479
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
480 for (i=0,j=firstcolor;i<ncolors;i++,j++)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
481 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
482 in[i] |= colors[j].r<<16 ;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
483 in[i] |= colors[j].g<<8 ;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
484 in[i] |= colors[j].b ;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
485 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
486
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
487 if ( (this->screen->flags & SDL_HWPALETTE) == SDL_HWPALETTE )
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
488 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
489 if( PgSetPalette( in, 0, 0, ncolors, Pg_PALSET_HARD, 0) < 0 )
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
490 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
491 fprintf(stderr,"error: PgSetPalette(..,Pg_PALSET_HARD) failed\n");
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
492 return 0;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
493 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
494 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
495 else
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
496 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
497 if ( PgColorMatch(ncolors, in, out) < 0 )
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
498 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
499 fprintf(stderr,"error: PgColorMatch failed\n");
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
500 return 0;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
501 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
502 for (i=0;i<ncolors;i++)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
503 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
504 if (memcmp(&in[i],&out[i],sizeof(PgColor_t)))
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
505 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
506 alloct_all = 0;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
507 break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
508 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
509 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
510 if( PgSetPalette( out, 0, 0, ncolors, Pg_PALSET_SOFT, 0) < 0 )
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
511 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
512 fprintf(stderr,"error: PgSetPalette(..,Pg_PALSET_SOFT) failed\n");
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
513 return 0;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
514 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
515 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
516 return alloct_all;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
517 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
518
266
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
519 void ph_GL_SwapBuffers(_THIS)
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
520 {
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
521 PgSetRegion(PtWidgetRid(window));
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
522 PdOpenGLContextSwapBuffers(OGLContext);
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
523 }
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
524
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
525 /*
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
526 static int ph_ResizeWindow(_THIS,
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
527 SDL_Surface *screen, int w, int h, Uint32 flags)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
528 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
529 PhWindowEvent_t winevent;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
530
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
531 memset( &winevent, 0, sizeof(winevent) );
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
532 winevent.event_f = Ph_WM_RESIZE;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
533 winevent.size.w = w;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
534 winevent.size.h = h;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
535 winevent.rid = PtWidgetRid( window );
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
536 if (PtForwardWindowEvent( &winevent ) < 0)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
537 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
538 fprintf(stderr,"error: PtForwardWindowEvent failed.\n");
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
539 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
540 current_w = w;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
541 current_h = h;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
542 return(0);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
543 }
266
c6abdda2f666 Added QNX cleanups by Mike Gorchak (thanks!)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
544 */