annotate src/video/nanox/SDL_nximage.c @ 1050:8e1815fd9777

Holding down shift while moving the mouse's scrollwheel on MacOS X makes the OS report these are "horizontal scrollwheel" events, which confuses gaming apps in several legitimate conditions. Now all scrollwheel events are made to look vertical when passed to the app. Patch by John Knottenbelt. http://www.libsdl.org/pipermail/sdl/2005-March/067978.html
author Ryan C. Gordon <icculus@icculus.org>
date Sun, 17 Apr 2005 10:32:41 +0000
parents b8d311d90021
children 604d73db6802
rev   line source
30
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1 /*
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2 SDL - Simple DirectMedia Layer
769
b8d311d90021 Updated copyright information for 2004 (Happy New Year!)
Sam Lantinga <slouken@libsdl.org>
parents: 700
diff changeset
3 Copyright (C) 1997-2004 Sam Lantinga
30
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
4 Copyright (C) 2001 Hsieh-Fu Tsai
471
26dafefeebb2 Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
5 Copyright (C) 2002 Greg Haerr <greg@censoft.com>
30
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
6
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
7 This library is free software; you can redistribute it and/or
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
8 modify it under the terms of the GNU Library General Public
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
9 License as published by the Free Software Foundation; either
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
10 version 2 of the License, or (at your option) any later version.
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
11
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
12 This library is distributed in the hope that it will be useful,
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
15 Library General Public License for more details.
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
16
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
17 You should have received a copy of the GNU Library General Public
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
18 License along with this library; if not, write to the Free
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
20
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
21 Sam Lantinga
252
e8157fcb3114 Updated the source with the correct e-mail address
Sam Lantinga <slouken@libsdl.org>
parents: 30
diff changeset
22 slouken@libsdl.org
30
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
23
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
24 Hsieh-Fu Tsai
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
25 clare@setabox.com
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
26 */
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
27
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
28 #include <stdlib.h>
698
31d9be995d5c *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 471
diff changeset
29 #include <string.h>
30
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
30
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
31 #include "SDL_error.h"
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
32
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
33 #include "SDL_nximage_c.h"
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
34
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
35 void NX_NormalUpdate (_THIS, int numrects, SDL_Rect * rects)
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
36 {
471
26dafefeebb2 Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
37 int i, j, xinc, yinc, destinc, rowinc ;
30
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
38 int x, y, w, h ;
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
39 unsigned char * src = NULL, * dest = NULL ;
471
26dafefeebb2 Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
40
30
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
41 Dprintf ("enter NX_NormalUpdate\n") ;
471
26dafefeebb2 Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
42
26dafefeebb2 Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
43 /* These are the values for the incoming image */
30
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
44 xinc = this -> screen -> format -> BytesPerPixel ;
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
45 yinc = this -> screen -> pitch ;
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
46
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
47 for (i = 0; i < numrects; ++ i) {
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
48 x = rects [i].x, y = rects [i].y ;
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
49 w = rects [i].w, h = rects [i].h ;
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
50 src = SDL_Image + y * yinc + x * xinc ;
471
26dafefeebb2 Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
51 #ifdef ENABLE_NANOX_DIRECT_FB
699
d3b2e93629eb Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents: 698
diff changeset
52 if (Clientfb) {
d3b2e93629eb Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents: 698
diff changeset
53 if (currently_fullscreen)
d3b2e93629eb Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents: 698
diff changeset
54 dest = fbinfo.winpixels + (((y+OffsetY) * fbinfo.pitch) +
d3b2e93629eb Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents: 698
diff changeset
55 ((x+OffsetX) * fbinfo.bytespp));
d3b2e93629eb Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents: 698
diff changeset
56 else
d3b2e93629eb Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents: 698
diff changeset
57 dest = fbinfo.winpixels + ((y * fbinfo.pitch) + (x * fbinfo.bytespp));
d3b2e93629eb Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents: 698
diff changeset
58 destinc = fbinfo.pitch;
d3b2e93629eb Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents: 698
diff changeset
59 }
d3b2e93629eb Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents: 698
diff changeset
60 else
471
26dafefeebb2 Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
61 #endif
699
d3b2e93629eb Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents: 698
diff changeset
62 {
471
26dafefeebb2 Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
63 dest = Image_buff ;
26dafefeebb2 Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
64 destinc = w * xinc ;
699
d3b2e93629eb Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents: 698
diff changeset
65 }
d3b2e93629eb Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents: 698
diff changeset
66 rowinc = w * xinc;
30
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
67
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
68 // apply GammaRamp table
471
26dafefeebb2 Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
69 if ((pixel_type == MWPF_TRUECOLOR0888 || pixel_type == MWPF_TRUECOLOR888)
699
d3b2e93629eb Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents: 698
diff changeset
70 && GammaRamp_R && GammaRamp_G && GammaRamp_B) {
d3b2e93629eb Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents: 698
diff changeset
71 Uint8 * ptrsrc ;
d3b2e93629eb Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents: 698
diff changeset
72 Uint8 * ptrdst ;
30
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
73 int k ;
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
74
699
d3b2e93629eb Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents: 698
diff changeset
75 for (j = h; j > 0; -- j, src += yinc, dest += destinc) {
d3b2e93629eb Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents: 698
diff changeset
76 ptrsrc = src ;
d3b2e93629eb Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents: 698
diff changeset
77 ptrdst = dest ;
30
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
78 for (k = w; k > 0; -- k) {
699
d3b2e93629eb Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents: 698
diff changeset
79 *ptrdst++ = GammaRamp_B [*ptrsrc++] >> 8;
d3b2e93629eb Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents: 698
diff changeset
80 *ptrdst++ = GammaRamp_G [*ptrsrc++] >> 8;
d3b2e93629eb Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents: 698
diff changeset
81 *ptrdst++ = GammaRamp_R [*ptrsrc++] >> 8;
d3b2e93629eb Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents: 698
diff changeset
82 *ptrdst++ = 0;
d3b2e93629eb Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents: 698
diff changeset
83 ++ptrsrc;
30
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
84 }
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
85 }
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
86 }
700
c35edafc84d1 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 699
diff changeset
87 #if 1 /* This is needed for microwindows 0.90 or older */
699
d3b2e93629eb Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents: 698
diff changeset
88 else if (pixel_type == MWPF_TRUECOLOR0888 || pixel_type == MWPF_TRUECOLOR888) {
d3b2e93629eb Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents: 698
diff changeset
89 Uint8 * ptrsrc ;
d3b2e93629eb Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents: 698
diff changeset
90 Uint8 * ptrdst ;
d3b2e93629eb Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents: 698
diff changeset
91 int k ;
30
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
92
699
d3b2e93629eb Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents: 698
diff changeset
93 for (j = h; j > 0; -- j, src += yinc, dest += destinc) {
d3b2e93629eb Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents: 698
diff changeset
94 ptrsrc = src ;
d3b2e93629eb Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents: 698
diff changeset
95 ptrdst = dest ;
d3b2e93629eb Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents: 698
diff changeset
96 for (k = w; k > 0; -- k) {
d3b2e93629eb Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents: 698
diff changeset
97 *ptrdst++ = *ptrsrc++;
d3b2e93629eb Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents: 698
diff changeset
98 *ptrdst++ = *ptrsrc++;
d3b2e93629eb Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents: 698
diff changeset
99 *ptrdst++ = *ptrsrc++;
d3b2e93629eb Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents: 698
diff changeset
100 *ptrdst++ = 0;
d3b2e93629eb Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents: 698
diff changeset
101 ++ptrsrc;
d3b2e93629eb Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents: 698
diff changeset
102 }
d3b2e93629eb Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents: 698
diff changeset
103 }
d3b2e93629eb Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents: 698
diff changeset
104 }
d3b2e93629eb Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents: 698
diff changeset
105 #endif
d3b2e93629eb Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents: 698
diff changeset
106 else
d3b2e93629eb Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents: 698
diff changeset
107 {
d3b2e93629eb Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents: 698
diff changeset
108 for (j = h; j > 0; -- j, src += yinc, dest += destinc)
d3b2e93629eb Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents: 698
diff changeset
109 memcpy (dest, src, rowinc) ;
d3b2e93629eb Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents: 698
diff changeset
110 }
d3b2e93629eb Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents: 698
diff changeset
111 if (!Clientfb) {
471
26dafefeebb2 Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
112 if (currently_fullscreen) {
26dafefeebb2 Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
113 GrArea (FSwindow, SDL_GC, x + OffsetX, y + OffsetY, w, h, Image_buff,
26dafefeebb2 Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
114 pixel_type) ;
26dafefeebb2 Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
115 } else {
26dafefeebb2 Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
116 GrArea (SDL_Window, SDL_GC, x, y, w, h, Image_buff, pixel_type) ;
26dafefeebb2 Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
117 }
699
d3b2e93629eb Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents: 698
diff changeset
118 }
30
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
119 }
471
26dafefeebb2 Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
120 GrFlush();
30
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
121
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
122 Dprintf ("leave NX_NormalUpdate\n") ;
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
123 }
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
124
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
125 int NX_SetupImage (_THIS, SDL_Surface * screen)
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
126 {
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
127 int size = screen -> h * screen -> pitch ;
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
128
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
129 Dprintf ("enter NX_SetupImage\n") ;
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
130
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
131 screen -> pixels = (void *) malloc (size) ;
471
26dafefeebb2 Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
132
26dafefeebb2 Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
133 if (!Clientfb) {
26dafefeebb2 Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
134 Image_buff = (unsigned char *) malloc (size) ;
26dafefeebb2 Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
135 if (screen -> pixels == NULL || Image_buff == NULL) {
26dafefeebb2 Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
136 free (screen -> pixels) ;
26dafefeebb2 Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
137 free (Image_buff) ;
26dafefeebb2 Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
138 SDL_OutOfMemory () ;
26dafefeebb2 Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
139 return -1 ;
26dafefeebb2 Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
140 }
30
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
141 }
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
142
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
143 SDL_Image = (unsigned char *) screen -> pixels ;
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
144
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
145 this -> UpdateRects = NX_NormalUpdate ;
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
146
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
147 Dprintf ("leave NX_SetupImage\n") ;
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
148 return 0 ;
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
149 }
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
150
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
151 void NX_DestroyImage (_THIS, SDL_Surface * screen)
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
152 {
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
153 Dprintf ("enter NX_DestroyImage\n") ;
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
154
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
155 if (SDL_Image) free (SDL_Image) ;
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
156 if (Image_buff) free (Image_buff) ;
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
157 if (screen) screen -> pixels = NULL ;
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
158
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
159 Dprintf ("leave NX_DestroyImage\n") ;
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
160 }
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
161
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
162 int NX_ResizeImage (_THIS, SDL_Surface * screen, Uint32 flags)
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
163 {
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
164 int retval ;
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
165 GR_SCREEN_INFO si ;
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
166
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
167 Dprintf ("enter NX_ResizeImage\n") ;
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
168
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
169 NX_DestroyImage (this, screen) ;
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
170 retval = NX_SetupImage (this, screen) ;
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
171
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
172 GrGetScreenInfo (& si) ;
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
173 OffsetX = (si.cols - screen -> w) / 2 ;
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
174 OffsetY = (si.rows - screen -> h) / 2 ;
471
26dafefeebb2 Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
175
26dafefeebb2 Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
176 #ifdef ENABLE_NANOX_DIRECT_FB
26dafefeebb2 Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
177 if (Clientfb) {
26dafefeebb2 Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
178 /* Get current window position and fb pointer*/
26dafefeebb2 Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
179 if (currently_fullscreen)
26dafefeebb2 Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
180 GrGetWindowFBInfo(FSwindow, &fbinfo);
26dafefeebb2 Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
181 else
26dafefeebb2 Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
182 GrGetWindowFBInfo(SDL_Window, &fbinfo);
26dafefeebb2 Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
183 }
26dafefeebb2 Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
184 #endif
30
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
185 Dprintf ("leave NX_ResizeImage\n") ;
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
186 return retval ;
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
187 }
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
188
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
189 void NX_RefreshDisplay (_THIS)
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
190 {
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
191 Dprintf ("enter NX_RefreshDisplay\n") ;
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
192
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
193 // Don't refresh a display that doesn't have an image (like GL)
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
194 if (! SDL_Image) {
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
195 return;
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
196 }
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
197
471
26dafefeebb2 Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
198 #ifdef ENABLE_NANOX_DIRECT_FB
26dafefeebb2 Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
199 if (Clientfb) {
26dafefeebb2 Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
200 int j;
26dafefeebb2 Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
201 char *src, *dest = NULL;
26dafefeebb2 Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
202 int xinc, yinc, rowinc;
26dafefeebb2 Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
203
699
d3b2e93629eb Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents: 698
diff changeset
204 GrGetWindowFBInfo(SDL_Window, &fbinfo);
471
26dafefeebb2 Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
205
699
d3b2e93629eb Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents: 698
diff changeset
206 xinc = this -> screen -> format -> BytesPerPixel ;
d3b2e93629eb Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents: 698
diff changeset
207 yinc = this -> screen -> pitch ;
471
26dafefeebb2 Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
208
699
d3b2e93629eb Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents: 698
diff changeset
209 src = SDL_Image;
d3b2e93629eb Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents: 698
diff changeset
210 if (currently_fullscreen)
d3b2e93629eb Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents: 698
diff changeset
211 dest = fbinfo.winpixels + ((OffsetY * fbinfo.pitch) +
d3b2e93629eb Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents: 698
diff changeset
212 (OffsetX * fbinfo.bytespp));
d3b2e93629eb Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents: 698
diff changeset
213 else
d3b2e93629eb Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents: 698
diff changeset
214 dest = fbinfo.winpixels;
d3b2e93629eb Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents: 698
diff changeset
215 rowinc = xinc * this -> screen -> w;
471
26dafefeebb2 Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
216
699
d3b2e93629eb Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents: 698
diff changeset
217 for (j = this -> screen -> h; j > 0; -- j, src += yinc, dest += fbinfo.pitch)
d3b2e93629eb Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents: 698
diff changeset
218 memcpy (dest, src, rowinc) ;
d3b2e93629eb Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents: 698
diff changeset
219 }
d3b2e93629eb Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents: 698
diff changeset
220 else
471
26dafefeebb2 Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
221 #endif
699
d3b2e93629eb Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents: 698
diff changeset
222 {
471
26dafefeebb2 Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
223 if (currently_fullscreen) {
26dafefeebb2 Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
224 GrArea (FSwindow, SDL_GC, OffsetX, OffsetY, this -> screen -> w,
26dafefeebb2 Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
225 this -> screen -> h, SDL_Image, pixel_type) ;
699
d3b2e93629eb Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents: 698
diff changeset
226 } else {
471
26dafefeebb2 Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
227 GrArea (SDL_Window, SDL_GC, 0, 0, this -> screen -> w,
26dafefeebb2 Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
228 this -> screen -> h, SDL_Image, pixel_type) ;
699
d3b2e93629eb Fixed some bugs in the Nano-X video driver
Sam Lantinga <slouken@libsdl.org>
parents: 698
diff changeset
229 }
30
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
230 }
471
26dafefeebb2 Date: Sat, 24 Aug 2002 22:20:01 -0600
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
231 GrFlush();
30
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
232
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
233 Dprintf ("leave NX_RefreshDisplay\n") ;
57bf11a5efd7 Added initial support for Nano-X (thanks Hsieh-Fu!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
234 }