Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libSDL
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PocketInsanity
libSDL
Commits
e0f869b6
Commit
e0f869b6
authored
Feb 10, 2011
by
Sam Lantinga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed gamma support since it wasn't widely used and not well supported.
parent
c4f308a1
Changes
24
Hide whitespace changes
Inline
Side-by-side
Showing
24 changed files
with
28 additions
and
1137 deletions
+28
-1137
SDL_compat.h
include/SDL_compat.h
+6
-0
SDL_video.h
include/SDL_video.h
+0
-49
SDL_compat.c
src/SDL_compat.c
+20
-0
SDL_gamma.c
src/video/SDL_gamma.c
+0
-236
SDL_pixels.c
src/video/SDL_pixels.c
+0
-14
SDL_pixels_c.h
src/video/SDL_pixels_c.h
+0
-2
SDL_sysvideo.h
src/video/SDL_sysvideo.h
+0
-11
SDL_video.c
src/video/SDL_video.c
+0
-10
SDL_sysvideo.cc
src/video/bwindow/SDL_sysvideo.cc
+0
-1
SDL_DirectFB_video.c
src/video/directfb/SDL_DirectFB_video.c
+0
-1
SDL_pandora.h
src/video/pandora/SDL_pandora.h
+0
-2
SDL_windowsgamma.c
src/video/windows/SDL_windowsgamma.c
+0
-71
SDL_windowsgamma.h
src/video/windows/SDL_windowsgamma.h
+0
-32
SDL_windowsvideo.c
src/video/windows/SDL_windowsvideo.c
+0
-2
SDL_windowsvideo.h
src/video/windows/SDL_windowsvideo.h
+0
-1
SDL_x11gamma.c
src/video/x11/SDL_x11gamma.c
+0
-232
SDL_x11gamma.h
src/video/x11/SDL_x11gamma.h
+0
-36
SDL_x11modes.c
src/video/x11/SDL_x11modes.c
+1
-3
SDL_x11opengl.c
src/video/x11/SDL_x11opengl.c
+0
-13
SDL_x11video.c
src/video/x11/SDL_x11video.c
+0
-11
SDL_x11video.h
src/video/x11/SDL_x11video.h
+0
-3
SDL_x11window.c
src/video/x11/SDL_x11window.c
+1
-212
Makefile.in
test/Makefile.in
+0
-1
testgamma.c
test/testgamma.c
+0
-194
No files found.
include/SDL_compat.h
View file @
e0f869b6
...
@@ -328,6 +328,12 @@ extern DECLSPEC int SDLCALL SDL_DisplayYUVOverlay(SDL_Overlay * overlay,
...
@@ -328,6 +328,12 @@ extern DECLSPEC int SDLCALL SDL_DisplayYUVOverlay(SDL_Overlay * overlay,
SDL_Rect
*
dstrect
);
SDL_Rect
*
dstrect
);
extern
DECLSPEC
void
SDLCALL
SDL_FreeYUVOverlay
(
SDL_Overlay
*
overlay
);
extern
DECLSPEC
void
SDLCALL
SDL_FreeYUVOverlay
(
SDL_Overlay
*
overlay
);
extern
DECLSPEC
void
SDLCALL
SDL_GL_SwapBuffers
(
void
);
extern
DECLSPEC
void
SDLCALL
SDL_GL_SwapBuffers
(
void
);
extern
DECLSPEC
int
SDLCALL
SDL_SetGamma
(
float
red
,
float
green
,
float
blue
);
extern
DECLSPEC
int
SDLCALL
SDL_SetGammaRamp
(
const
Uint16
*
red
,
const
Uint16
*
green
,
const
Uint16
*
blue
);
extern
DECLSPEC
int
SDLCALL
SDL_GetGammaRamp
(
Uint16
*
red
,
Uint16
*
green
,
Uint16
*
blue
);
extern
DECLSPEC
int
SDLCALL
SDL_EnableKeyRepeat
(
int
delay
,
int
interval
);
extern
DECLSPEC
int
SDLCALL
SDL_EnableKeyRepeat
(
int
delay
,
int
interval
);
extern
DECLSPEC
void
SDLCALL
SDL_GetKeyRepeat
(
int
*
delay
,
int
*
interval
);
extern
DECLSPEC
void
SDLCALL
SDL_GetKeyRepeat
(
int
*
delay
,
int
*
interval
);
extern
DECLSPEC
int
SDLCALL
SDL_EnableUNICODE
(
int
enable
);
extern
DECLSPEC
int
SDLCALL
SDL_EnableUNICODE
(
int
enable
);
...
...
include/SDL_video.h
View file @
e0f869b6
...
@@ -360,55 +360,6 @@ extern DECLSPEC int SDLCALL SDL_GetWindowDisplayMode(SDL_Window * window,
...
@@ -360,55 +360,6 @@ extern DECLSPEC int SDLCALL SDL_GetWindowDisplayMode(SDL_Window * window,
*/
*/
extern
DECLSPEC
Uint32
SDLCALL
SDL_GetWindowPixelFormat
(
SDL_Window
*
window
);
extern
DECLSPEC
Uint32
SDLCALL
SDL_GetWindowPixelFormat
(
SDL_Window
*
window
);
/**
* \brief Set the gamma correction for each of the color channels on the
* currently selected display.
*
* \return 0 on success, or -1 if setting the gamma isn't supported.
*
* \sa SDL_SetGammaRamp()
*/
extern
DECLSPEC
int
SDLCALL
SDL_SetGamma
(
float
red
,
float
green
,
float
blue
);
/**
* \brief Set the gamma ramp for the currently selected display.
*
* \param red The translation table for the red channel, or NULL.
* \param green The translation table for the green channel, or NULL.
* \param blue The translation table for the blue channel, or NULL.
*
* \return 0 on success, or -1 if gamma ramps are unsupported.
*
* Set the gamma translation table for the red, green, and blue channels
* of the video hardware. Each table is an array of 256 16-bit quantities,
* representing a mapping between the input and output for that channel.
* The input is the index into the array, and the output is the 16-bit
* gamma value at that index, scaled to the output color precision.
*
* \sa SDL_GetGammaRamp()
*/
extern
DECLSPEC
int
SDLCALL
SDL_SetGammaRamp
(
const
Uint16
*
red
,
const
Uint16
*
green
,
const
Uint16
*
blue
);
/**
* \brief Get the gamma ramp for the currently selected display.
*
* \param red A pointer to a 256 element array of 16-bit quantities to hold
* the translation table for the red channel, or NULL.
* \param green A pointer to a 256 element array of 16-bit quantities to hold
* the translation table for the green channel, or NULL.
* \param blue A pointer to a 256 element array of 16-bit quantities to hold
* the translation table for the blue channel, or NULL.
*
* \return 0 on success, or -1 if gamma ramps are unsupported.
*
* \sa SDL_SetGammaRamp()
*/
extern
DECLSPEC
int
SDLCALL
SDL_GetGammaRamp
(
Uint16
*
red
,
Uint16
*
green
,
Uint16
*
blue
);
/**
/**
* \brief Create a window with the specified position, dimensions, and flags.
* \brief Create a window with the specified position, dimensions, and flags.
*
*
...
...
src/SDL_compat.c
View file @
e0f869b6
...
@@ -1526,6 +1526,26 @@ SDL_GL_SwapBuffers(void)
...
@@ -1526,6 +1526,26 @@ SDL_GL_SwapBuffers(void)
SDL_GL_SwapWindow
(
SDL_VideoWindow
);
SDL_GL_SwapWindow
(
SDL_VideoWindow
);
}
}
int
SDL_SetGamma
(
float
red
,
float
green
,
float
blue
)
{
SDL_Unsupported
();
return
-
1
;
}
int
SDL_SetGammaRamp
(
const
Uint16
*
red
,
const
Uint16
*
green
,
const
Uint16
*
blue
)
{
SDL_Unsupported
();
return
-
1
;
}
int
SDL_GetGammaRamp
(
Uint16
*
red
,
Uint16
*
green
,
Uint16
*
blue
)
{
SDL_Unsupported
();
return
-
1
;
}
int
int
SDL_EnableKeyRepeat
(
int
delay
,
int
interval
)
SDL_EnableKeyRepeat
(
int
delay
,
int
interval
)
...
...
src/video/SDL_gamma.c
deleted
100644 → 0
View file @
c4f308a1
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2010 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
/* Gamma correction support */
#include "SDL_sysvideo.h"
static
void
CalculateGammaRamp
(
float
gamma
,
Uint16
*
ramp
)
{
int
i
;
/* 0.0 gamma is all black */
if
(
gamma
<=
0
.
0
f
)
{
for
(
i
=
0
;
i
<
256
;
++
i
)
{
ramp
[
i
]
=
0
;
}
return
;
}
else
/* 1.0 gamma is identity */
if
(
gamma
==
1
.
0
f
)
{
for
(
i
=
0
;
i
<
256
;
++
i
)
{
ramp
[
i
]
=
(
i
<<
8
)
|
i
;
}
return
;
}
else
/* Calculate a real gamma ramp */
{
int
value
;
gamma
=
1
.
0
f
/
gamma
;
for
(
i
=
0
;
i
<
256
;
++
i
)
{
value
=
(
int
)
(
SDL_pow
((
double
)
i
/
256
.
0
,
gamma
)
*
65535
.
0
+
0
.
5
);
if
(
value
>
65535
)
{
value
=
65535
;
}
ramp
[
i
]
=
(
Uint16
)
value
;
}
}
}
static
void
CalculateGammaFromRamp
(
float
*
gamma
,
Uint16
*
ramp
)
{
/* The following is adapted from a post by Garrett Bass on OpenGL
Gamedev list, March 4, 2000.
*/
float
sum
=
0
.
0
f
;
int
i
,
count
=
0
;
*
gamma
=
1
.
0
;
for
(
i
=
1
;
i
<
256
;
++
i
)
{
if
((
ramp
[
i
]
!=
0
)
&&
(
ramp
[
i
]
!=
65535
))
{
double
B
=
(
double
)
i
/
256
.
0
;
double
A
=
ramp
[
i
]
/
65535
.
0
;
sum
+=
(
float
)
(
SDL_log
(
A
)
/
SDL_log
(
B
));
count
++
;
}
}
if
(
count
&&
sum
>
0
.
0
f
)
{
*
gamma
=
1
.
0
f
/
(
sum
/
count
);
}
}
int
SDL_SetGamma
(
float
red
,
float
green
,
float
blue
)
{
Uint16
ramp
[
3
][
256
];
CalculateGammaRamp
(
red
,
ramp
[
0
]);
CalculateGammaRamp
(
green
,
ramp
[
1
]);
CalculateGammaRamp
(
blue
,
ramp
[
2
]);
return
SDL_SetGammaRamp
(
ramp
[
0
],
ramp
[
1
],
ramp
[
2
]);
}
/* Calculating the gamma by integrating the gamma ramps isn't exact,
so this function isn't officially supported.
*/
int
SDL_GetGamma
(
float
*
red
,
float
*
green
,
float
*
blue
)
{
int
succeeded
;
Uint16
ramp
[
3
][
256
];
succeeded
=
SDL_GetGammaRamp
(
ramp
[
0
],
ramp
[
1
],
ramp
[
2
]);
if
(
succeeded
>=
0
)
{
CalculateGammaFromRamp
(
red
,
ramp
[
0
]);
CalculateGammaFromRamp
(
green
,
ramp
[
1
]);
CalculateGammaFromRamp
(
blue
,
ramp
[
2
]);
}
return
succeeded
;
}
static
void
SDL_UninitializedVideo
()
{
SDL_SetError
(
"Video subsystem has not been initialized"
);
}
int
SDL_SetGammaRampForDisplay
(
SDL_VideoDisplay
*
display
,
const
Uint16
*
red
,
const
Uint16
*
green
,
const
Uint16
*
blue
)
{
SDL_VideoDevice
*
_this
=
SDL_GetVideoDevice
();
int
succeeded
;
if
(
!
_this
)
{
SDL_UninitializedVideo
();
return
-
1
;
}
/* Lazily allocate the gamma tables */
if
(
!
display
->
gamma
)
{
if
(
SDL_GetGammaRampForDisplay
(
display
,
NULL
,
NULL
,
NULL
)
<
0
)
{
return
-
1
;
}
}
/* Fill the gamma table with the new values */
if
(
red
)
{
SDL_memcpy
(
&
display
->
gamma
[
0
*
256
],
red
,
256
*
sizeof
(
*
display
->
gamma
));
}
if
(
green
)
{
SDL_memcpy
(
&
display
->
gamma
[
1
*
256
],
green
,
256
*
sizeof
(
*
display
->
gamma
));
}
if
(
blue
)
{
SDL_memcpy
(
&
display
->
gamma
[
2
*
256
],
blue
,
256
*
sizeof
(
*
display
->
gamma
));
}
/* Try to set the gamma ramp in the driver */
succeeded
=
-
1
;
if
(
_this
&&
_this
->
SetDisplayGammaRamp
)
{
if
(
SDL_GetFocusWindow
())
{
succeeded
=
_this
->
SetDisplayGammaRamp
(
_this
,
display
,
display
->
gamma
);
}
else
{
succeeded
=
0
;
}
}
else
{
SDL_SetError
(
"Gamma ramp manipulation not supported"
);
}
return
succeeded
;
}
int
SDL_SetGammaRamp
(
const
Uint16
*
red
,
const
Uint16
*
green
,
const
Uint16
*
blue
)
{
SDL_VideoDevice
*
_this
=
SDL_GetVideoDevice
();
if
(
!
_this
)
{
SDL_UninitializedVideo
();
return
-
1
;
}
return
SDL_SetGammaRampForDisplay
(
SDL_CurrentDisplay
,
red
,
green
,
blue
);
}
int
SDL_GetGammaRampForDisplay
(
SDL_VideoDisplay
*
display
,
Uint16
*
red
,
Uint16
*
green
,
Uint16
*
blue
)
{
SDL_VideoDevice
*
_this
=
SDL_GetVideoDevice
();
if
(
!
_this
)
{
SDL_UninitializedVideo
();
return
-
1
;
}
/* Lazily allocate the gamma table */
if
(
!
display
->
gamma
)
{
size_t
rampsize
=
(
3
*
256
*
sizeof
(
*
display
->
gamma
));
display
->
gamma
=
SDL_malloc
(
rampsize
*
2
);
if
(
!
display
->
gamma
)
{
SDL_OutOfMemory
();
return
-
1
;
}
if
(
_this
&&
_this
->
GetDisplayGammaRamp
)
{
/* Get the real hardware gamma */
_this
->
GetDisplayGammaRamp
(
_this
,
display
,
display
->
gamma
);
}
else
{
/* Assume an identity gamma */
int
i
;
for
(
i
=
0
;
i
<
256
;
++
i
)
{
display
->
gamma
[
0
*
256
+
i
]
=
(
i
<<
8
)
|
i
;
display
->
gamma
[
1
*
256
+
i
]
=
(
i
<<
8
)
|
i
;
display
->
gamma
[
2
*
256
+
i
]
=
(
i
<<
8
)
|
i
;
}
}
display
->
saved_gamma
=
display
->
gamma
+
(
3
*
256
);
SDL_memcpy
(
display
->
saved_gamma
,
display
->
gamma
,
rampsize
);
}
/* Just copy from our internal table */
if
(
red
)
{
SDL_memcpy
(
red
,
&
display
->
gamma
[
0
*
256
],
256
*
sizeof
(
*
red
));
}
if
(
green
)
{
SDL_memcpy
(
green
,
&
display
->
gamma
[
1
*
256
],
256
*
sizeof
(
*
green
));
}
if
(
blue
)
{
SDL_memcpy
(
blue
,
&
display
->
gamma
[
2
*
256
],
256
*
sizeof
(
*
blue
));
}
return
0
;
}
int
SDL_GetGammaRamp
(
Uint16
*
red
,
Uint16
*
green
,
Uint16
*
blue
)
{
SDL_VideoDevice
*
_this
=
SDL_GetVideoDevice
();
if
(
!
_this
)
{
SDL_UninitializedVideo
();
return
-
1
;
}
return
SDL_GetGammaRampForDisplay
(
SDL_CurrentDisplay
,
red
,
green
,
blue
);
}
/* vi: set ts=4 sw=4 expandtab: */
src/video/SDL_pixels.c
View file @
e0f869b6
...
@@ -764,20 +764,6 @@ SDL_GetRGBA(Uint32 pixel, const SDL_PixelFormat * format,
...
@@ -764,20 +764,6 @@ SDL_GetRGBA(Uint32 pixel, const SDL_PixelFormat * format,
}
}
}
}
/* Apply gamma to a set of colors - this is easy. :) */
void
SDL_ApplyGamma
(
Uint16
*
gamma
,
SDL_Color
*
colors
,
SDL_Color
*
output
,
int
ncolors
)
{
int
i
;
for
(
i
=
0
;
i
<
ncolors
;
++
i
)
{
output
[
i
].
r
=
gamma
[
0
*
256
+
colors
[
i
].
r
]
>>
8
;
output
[
i
].
g
=
gamma
[
1
*
256
+
colors
[
i
].
g
]
>>
8
;
output
[
i
].
b
=
gamma
[
2
*
256
+
colors
[
i
].
b
]
>>
8
;
}
}
/* Map from Palette to Palette */
/* Map from Palette to Palette */
static
Uint8
*
static
Uint8
*
Map1to1
(
SDL_Palette
*
src
,
SDL_Palette
*
dst
,
int
*
identical
)
Map1to1
(
SDL_Palette
*
src
,
SDL_Palette
*
dst
,
int
*
identical
)
...
...
src/video/SDL_pixels_c.h
View file @
e0f869b6
...
@@ -45,7 +45,5 @@ extern void SDL_FreeBlitMap(SDL_BlitMap * map);
...
@@ -45,7 +45,5 @@ extern void SDL_FreeBlitMap(SDL_BlitMap * map);
extern
int
SDL_CalculatePitch
(
SDL_Surface
*
surface
);
extern
int
SDL_CalculatePitch
(
SDL_Surface
*
surface
);
extern
void
SDL_DitherColors
(
SDL_Color
*
colors
,
int
bpp
);
extern
void
SDL_DitherColors
(
SDL_Color
*
colors
,
int
bpp
);
extern
Uint8
SDL_FindColor
(
SDL_Palette
*
pal
,
Uint8
r
,
Uint8
g
,
Uint8
b
);
extern
Uint8
SDL_FindColor
(
SDL_Palette
*
pal
,
Uint8
r
,
Uint8
g
,
Uint8
b
);
extern
void
SDL_ApplyGamma
(
Uint16
*
gamma
,
SDL_Color
*
colors
,
SDL_Color
*
output
,
int
ncolors
);
/* vi: set ts=4 sw=4 expandtab: */
/* vi: set ts=4 sw=4 expandtab: */
src/video/SDL_sysvideo.h
View file @
e0f869b6
...
@@ -110,9 +110,6 @@ struct SDL_VideoDisplay
...
@@ -110,9 +110,6 @@ struct SDL_VideoDisplay
SDL_DisplayMode
current_mode
;
SDL_DisplayMode
current_mode
;
SDL_bool
updating_fullscreen
;
SDL_bool
updating_fullscreen
;
Uint16
*
gamma
;
Uint16
*
saved_gamma
;
/* (just offset into gamma) */
SDL_Window
*
windows
;
SDL_Window
*
windows
;
SDL_Window
*
fullscreen_window
;
SDL_Window
*
fullscreen_window
;
...
@@ -169,12 +166,6 @@ struct SDL_VideoDevice
...
@@ -169,12 +166,6 @@ struct SDL_VideoDevice
*/
*/
int
(
*
SetDisplayMode
)
(
_THIS
,
SDL_VideoDisplay
*
display
,
SDL_DisplayMode
*
mode
);
int
(
*
SetDisplayMode
)
(
_THIS
,
SDL_VideoDisplay
*
display
,
SDL_DisplayMode
*
mode
);
/* Set the gamma ramp */
int
(
*
SetDisplayGammaRamp
)
(
_THIS
,
SDL_VideoDisplay
*
display
,
Uint16
*
ramp
);
/* Get the gamma ramp */
int
(
*
GetDisplayGammaRamp
)
(
_THIS
,
SDL_VideoDisplay
*
display
,
Uint16
*
ramp
);
/* * * */
/* * * */
/*
/*
* Window functions
* Window functions
...
@@ -343,8 +334,6 @@ extern int SDL_GetDesktopDisplayModeForDisplay(SDL_VideoDisplay * display, SDL_D
...
@@ -343,8 +334,6 @@ extern int SDL_GetDesktopDisplayModeForDisplay(SDL_VideoDisplay * display, SDL_D
extern
int
SDL_GetCurrentDisplayModeForDisplay
(
SDL_VideoDisplay
*
display
,
SDL_DisplayMode
*
mode
);
extern
int
SDL_GetCurrentDisplayModeForDisplay
(
SDL_VideoDisplay
*
display
,
SDL_DisplayMode
*
mode
);
extern
SDL_DisplayMode
*
SDL_GetClosestDisplayModeForDisplay
(
SDL_VideoDisplay
*
display
,
const
SDL_DisplayMode
*
mode
,
SDL_DisplayMode
*
closest
);
extern
SDL_DisplayMode
*
SDL_GetClosestDisplayModeForDisplay
(
SDL_VideoDisplay
*
display
,
const
SDL_DisplayMode
*
mode
,
SDL_DisplayMode
*
closest
);
extern
int
SDL_SetDisplayModeForDisplay
(
SDL_VideoDisplay
*
display
,
const
SDL_DisplayMode
*
mode
);
extern
int
SDL_SetDisplayModeForDisplay
(
SDL_VideoDisplay
*
display
,
const
SDL_DisplayMode
*
mode
);
extern
int
SDL_SetGammaRampForDisplay
(
SDL_VideoDisplay
*
display
,
const
Uint16
*
red
,
const
Uint16
*
green
,
const
Uint16
*
blue
);
extern
int
SDL_GetGammaRampForDisplay
(
SDL_VideoDisplay
*
display
,
Uint16
*
red
,
Uint16
*
green
,
Uint16
*
blue
);
extern
int
SDL_RecreateWindow
(
SDL_Window
*
window
,
Uint32
flags
);
extern
int
SDL_RecreateWindow
(
SDL_Window
*
window
,
Uint32
flags
);
...
...
src/video/SDL_video.c
View file @
e0f869b6
...
@@ -1644,9 +1644,6 @@ SDL_OnWindowFocusGained(SDL_Window * window)
...
@@ -1644,9 +1644,6 @@ SDL_OnWindowFocusGained(SDL_Window * window)
{
{
SDL_VideoDisplay
*
display
=
window
->
display
;
SDL_VideoDisplay
*
display
=
window
->
display
;
if
(
display
->
gamma
&&
_this
->
SetDisplayGammaRamp
)
{
_this
->
SetDisplayGammaRamp
(
_this
,
display
,
display
->
gamma
);
}
if
((
window
->
flags
&
(
SDL_WINDOW_INPUT_GRABBED
|
SDL_WINDOW_FULLSCREEN
))
if
((
window
->
flags
&
(
SDL_WINDOW_INPUT_GRABBED
|
SDL_WINDOW_FULLSCREEN
))
&&
_this
->
SetWindowGrab
)
{
&&
_this
->
SetWindowGrab
)
{
_this
->
SetWindowGrab
(
_this
,
window
);
_this
->
SetWindowGrab
(
_this
,
window
);
...
@@ -1664,9 +1661,6 @@ SDL_OnWindowFocusLost(SDL_Window * window)
...
@@ -1664,9 +1661,6 @@ SDL_OnWindowFocusLost(SDL_Window * window)
SDL_MinimizeWindow
(
window
);
SDL_MinimizeWindow
(
window
);
}
}
if
(
display
->
gamma
&&
_this
->
SetDisplayGammaRamp
)
{
_this
->
SetDisplayGammaRamp
(
_this
,
display
,
display
->
saved_gamma
);
}
if
((
window
->
flags
&
(
SDL_WINDOW_INPUT_GRABBED
|
SDL_WINDOW_FULLSCREEN
))
if
((
window
->
flags
&
(
SDL_WINDOW_INPUT_GRABBED
|
SDL_WINDOW_FULLSCREEN
))
&&
_this
->
SetWindowGrab
)
{
&&
_this
->
SetWindowGrab
)
{
_this
->
SetWindowGrab
(
_this
,
window
);
_this
->
SetWindowGrab
(
_this
,
window
);
...
@@ -1825,10 +1819,6 @@ SDL_VideoQuit(void)
...
@@ -1825,10 +1819,6 @@ SDL_VideoQuit(void)
SDL_free
(
display
->
desktop_mode
.
driverdata
);
SDL_free
(
display
->
desktop_mode
.
driverdata
);
display
->
desktop_mode
.
driverdata
=
NULL
;
display
->
desktop_mode
.
driverdata
=
NULL
;
}
}
if
(
display
->
gamma
)
{
SDL_free
(
display
->
gamma
);
display
->
gamma
=
NULL
;
}
if
(
display
->
driverdata
)
{
if
(
display
->
driverdata
)
{
SDL_free
(
display
->
driverdata
);
SDL_free
(
display
->
driverdata
);
display
->
driverdata
=
NULL
;
display
->
driverdata
=
NULL
;
...
...
src/video/bwindow/SDL_sysvideo.cc
View file @
e0f869b6
...
@@ -129,7 +129,6 @@ extern "C"
...
@@ -129,7 +129,6 @@ extern "C"
device
->
UnlockHWSurface
=
BE_UnlockHWSurface
;
device
->
UnlockHWSurface
=
BE_UnlockHWSurface
;
device
->
FlipHWSurface
=
NULL
;
device
->
FlipHWSurface
=
NULL
;
device
->
FreeHWSurface
=
BE_FreeHWSurface
;
device
->
FreeHWSurface
=
BE_FreeHWSurface
;
/* Gamma support */
#if SDL_VIDEO_OPENGL
#if SDL_VIDEO_OPENGL
/* OpenGL support */
/* OpenGL support */
device
->
GL_LoadLibrary
=
BE_GL_LoadLibrary
;
device
->
GL_LoadLibrary
=
BE_GL_LoadLibrary
;
...
...
src/video/directfb/SDL_DirectFB_video.c
View file @
e0f869b6
...
@@ -27,7 +27,6 @@
...
@@ -27,7 +27,6 @@
#include "SDL_DirectFB_events.h"
#include "SDL_DirectFB_events.h"
/*
/*
* #include "SDL_DirectFB_gamma.h"
* #include "SDL_DirectFB_keyboard.h"
* #include "SDL_DirectFB_keyboard.h"
*/
*/
#include "SDL_DirectFB_modes.h"
#include "SDL_DirectFB_modes.h"
...
...
src/video/pandora/SDL_pandora.h
View file @
e0f869b6
...
@@ -70,8 +70,6 @@ int PND_videoinit(_THIS);
...
@@ -70,8 +70,6 @@ int PND_videoinit(_THIS);
void
PND_videoquit
(
_THIS
);
void
PND_videoquit
(
_THIS
);
void
PND_getdisplaymodes
(
_THIS
,
SDL_VideoDisplay
*
display
);
void
PND_getdisplaymodes
(
_THIS
,
SDL_VideoDisplay
*
display
);
int
PND_setdisplaymode
(
_THIS
,
SDL_VideoDisplay
*
display
,
SDL_DisplayMode
*
mode
);
int
PND_setdisplaymode
(
_THIS
,
SDL_VideoDisplay
*
display
,
SDL_DisplayMode
*
mode
);
int
PND_setdisplaygammaramp
(
_THIS
,
Uint16
*
ramp
);
int
PND_getdisplaygammaramp
(
_THIS
,
Uint16
*
ramp
);
int
PND_createwindow
(
_THIS
,
SDL_Window
*
window
);
int
PND_createwindow
(
_THIS
,
SDL_Window
*
window
);
int
PND_createwindowfrom
(
_THIS
,
SDL_Window
*
window
,
const
void
*
data
);
int
PND_createwindowfrom
(
_THIS
,
SDL_Window
*
window
,
const
void
*
data
);
void
PND_setwindowtitle
(
_THIS
,
SDL_Window
*
window
);
void
PND_setwindowtitle
(
_THIS
,
SDL_Window
*
window
);
...
...
src/video/windows/SDL_windowsgamma.c
deleted
100644 → 0
View file @
c4f308a1
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2010 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
#include "SDL_windowsvideo.h"
int
WIN_SetDisplayGammaRamp
(
_THIS
,
SDL_VideoDisplay
*
display
,
Uint16
*
ramp
)
{
#ifdef _WIN32_WCE
return
-
1
;
#else
SDL_DisplayData
*
data
=
(
SDL_DisplayData
*
)
display
->
driverdata
;
HDC
hdc
;
BOOL
succeeded
=
FALSE
;
hdc
=
CreateDC
(
data
->
DeviceName
,
NULL
,
NULL
,
NULL
);
if
(
hdc
)
{
succeeded
=
SetDeviceGammaRamp
(
hdc
,
ramp
);
if
(
!
succeeded
)
{
WIN_SetError
(
"SetDeviceGammaRamp()"
);
}
DeleteDC
(
hdc
);
}
return
succeeded
?
0
:
-
1
;
#endif
}
int
WIN_GetDisplayGammaRamp
(
_THIS
,
SDL_VideoDisplay
*
display
,
Uint16
*
ramp
)
{
#ifdef _WIN32_WCE
return
-
1
;
#else
SDL_DisplayData
*
data
=
(
SDL_DisplayData
*
)
display
->
driverdata
;
HDC
hdc
;
BOOL
succeeded
=
FALSE
;
hdc
=
CreateDC
(
data
->
DeviceName
,
NULL
,
NULL
,
NULL
);
if
(
hdc
)
{
succeeded
=
GetDeviceGammaRamp
(
hdc
,
ramp
);
if
(
!
succeeded
)
{
WIN_SetError
(
"GetDeviceGammaRamp()"
);
}
DeleteDC
(
hdc
);
}
return
succeeded
?
0
:
-
1
;
#endif
}
/* vi: set ts=4 sw=4 expandtab: */
src/video/windows/SDL_windowsgamma.h
deleted
100644 → 0
View file @
c4f308a1
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2010 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
#ifndef _SDL_windowsgamma_h
#define _SDL_windowsgamma_h
extern
int
WIN_SetDisplayGammaRamp
(
_THIS
,
SDL_VideoDisplay
*
display
,
Uint16
*
ramp
);
extern
int
WIN_GetDisplayGammaRamp
(
_THIS
,
SDL_VideoDisplay
*
display
,
Uint16
*
ramp
);
#endif
/* _SDL_windowsgamma_h */
/* vi: set ts=4 sw=4 expandtab: */
src/video/windows/SDL_windowsvideo.c
View file @
e0f869b6
...
@@ -109,8 +109,6 @@ WIN_CreateDevice(int devindex)
...
@@ -109,8 +109,6 @@ WIN_CreateDevice(int devindex)
device
->
GetDisplayBounds
=
WIN_GetDisplayBounds
;
device
->
GetDisplayBounds
=
WIN_GetDisplayBounds
;
device
->
GetDisplayModes
=
WIN_GetDisplayModes
;
device
->
GetDisplayModes
=
WIN_GetDisplayModes
;
device
->
SetDisplayMode
=
WIN_SetDisplayMode
;
device
->
SetDisplayMode
=
WIN_SetDisplayMode
;
device
->
SetDisplayGammaRamp
=
WIN_SetDisplayGammaRamp
;
device
->
GetDisplayGammaRamp
=
WIN_GetDisplayGammaRamp
;
device
->
PumpEvents
=
WIN_PumpEvents
;
device
->
PumpEvents
=
WIN_PumpEvents
;
#undef CreateWindow
#undef CreateWindow
...
...
src/video/windows/SDL_windowsvideo.h
View file @
e0f869b6
...
@@ -41,7 +41,6 @@
...
@@ -41,7 +41,6 @@
#include "SDL_windowsclipboard.h"
#include "SDL_windowsclipboard.h"
#include "SDL_windowsevents.h"
#include "SDL_windowsevents.h"
#include "SDL_windowsgamma.h"
#include "SDL_windowskeyboard.h"
#include "SDL_windowskeyboard.h"
#include "SDL_windowsmodes.h"
#include "SDL_windowsmodes.h"
#include "SDL_windowsmouse.h"
#include "SDL_windowsmouse.h"
...
...
src/video/x11/SDL_x11gamma.c
deleted
100644 → 0
View file @
c4f308a1
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2010 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
#include "../SDL_sysvideo.h"
#include "SDL_x11video.h"
/* The size of *all* SDL gamma ramps */
#define SDL_GammaRampSize (3 * 256 * sizeof(Uint16))
static
int
numCmaps
=
0
;
typedef
struct
{
Display
*
display
;
int
scrNum
;
Colormap
colormap
;
Visual
visual
;
Uint16
*
ramp
;
}
cmapTableEntry
;
cmapTableEntry
*
cmapTable
=
NULL
;
/* To reduce the overhead as much as possible lets do as little as
possible. When we do have to create a colormap keep track of it and
reuse it. We're going to do this for both DirectColor and
PseudoColor colormaps. */
Colormap
X11_LookupColormap
(
Display
*
display
,
int
scrNum
,
VisualID
vid
)
{
int
i
;
for
(
i
=
0
;
i
<
numCmaps
;
i
++
)
{
if
(
cmapTable
[
i
].
display
==
display
&&
cmapTable
[
i
].
scrNum
==
scrNum
&&
cmapTable
[
i
].
visual
.
visualid
==
vid
)
{
return
cmapTable
[
i
].
colormap
;
}
}
return
0
;
}
void
X11_TrackColormap
(
Display
*
display
,
int
scrNum
,
Colormap
colormap
,
Visual
*
visual
,
XColor
*
ramp
)
{
int
i
;
Uint16
*
newramp
;
int
ncolors
;
/* search the table to find out if we already have this one. We
only want one entry for each display, screen number, visualid,
and colormap combination */
for
(
i
=
0
;
i
<
numCmaps
;
i
++
)
{
if
(
cmapTable
[
i
].
display
==
display
&&
cmapTable
[
i
].
scrNum
==
scrNum
&&
cmapTable
[
i
].
visual
.
visualid
==
visual
->
visualid
&&
cmapTable
[
i
].
colormap
==
colormap
)
{
return
;
}
}
/* increase the table by one entry. If the table is NULL create the
first entrty */
cmapTable
=
SDL_realloc
(
cmapTable
,
(
numCmaps
+
1
)
*
sizeof
(
cmapTableEntry
));
if
(
NULL
==
cmapTable
)
{
SDL_SetError
(
"Out of memory in X11_TrackColormap()"
);
return
;
}
cmapTable
[
numCmaps
].
display
=
display
;
cmapTable
[
numCmaps
].
scrNum
=
scrNum
;
cmapTable
[
numCmaps
].
colormap
=
colormap
;
SDL_memcpy
(
&
cmapTable
[
numCmaps
].
visual
,
visual
,
sizeof
(
Visual
));
cmapTable
[
numCmaps
].
ramp
=
NULL
;
if
(
ramp
!=
NULL
)
{
newramp
=
SDL_malloc
(
SDL_GammaRampSize
);
if
(
NULL
==
newramp
)
{
SDL_SetError
(
"Out of memory in X11_TrackColormap()"
);
return
;
}
SDL_memset
(
newramp
,
0
,
SDL_GammaRampSize
);
cmapTable
[
numCmaps
].
ramp
=
newramp
;
ncolors
=
cmapTable
[
numCmaps
].
visual
.
map_entries
;
for
(
i
=
0
;
i
<
ncolors
;
i
++
)
{
newramp
[(
0
*
256
)
+
i
]
=
ramp
[
i
].
red
;
newramp
[(
1
*
256
)
+
i
]
=
ramp
[
i
].
green
;
newramp
[(
2
*
256
)
+
i
]
=
ramp
[
i
].
blue
;
}
}
numCmaps
++
;
}
/* The problem is that you have to have at least one DirectColor
colormap before you can set the gamma ramps or read the gamma
ramps. If the application has created a DirectColor window then the
cmapTable will have at least one colormap in it and everything is
cool. If not, then we just fail */
int
X11_SetDisplayGammaRamp
(
_THIS
,
SDL_VideoDisplay
*
sdl_display
,
Uint16
*
ramp
)
{
Visual
*
visual
;
Display
*
display
;
Colormap
colormap
;
XColor
*
colorcells
;
int
ncolors
;
int
rmask
,
gmask
,
bmask
;
int
rshift
,
gshift
,
bshift
;
int
i
;
int
j
;
for
(
j
=
0
;
j
<
numCmaps
;
j
++
)
{
if
(
cmapTable
[
j
].
visual
.
class
==
DirectColor
)
{
display
=
cmapTable
[
j
].
display
;
colormap
=
cmapTable
[
j
].
colormap
;
ncolors
=
cmapTable
[
j
].
visual
.
map_entries
;
visual
=
&
cmapTable
[
j
].
visual
;
colorcells
=
SDL_malloc
(
ncolors
*
sizeof
(
XColor
));
if
(
NULL
==
colorcells
)
{
SDL_SetError
(
"out of memory in X11_SetDisplayGammaRamp"
);
return
-
1
;
}
/* remember the new ramp */
if
(
cmapTable
[
j
].
ramp
==
NULL
)
{
Uint16
*
newramp
=
SDL_malloc
(
SDL_GammaRampSize
);
if
(
NULL
==
newramp
)
{
SDL_SetError
(
"Out of memory in X11_TrackColormap()"
);
return
-
1
;
}
cmapTable
[
j
].
ramp
=
newramp
;
}
SDL_memcpy
(
cmapTable
[
j
].
ramp
,
ramp
,
SDL_GammaRampSize
);
rshift
=
0
;
rmask
=
visual
->
red_mask
;
while
(
0
==
(
rmask
&
1
))
{
rshift
++
;
rmask
>>=
1
;
}
/* printf("rmask = %4x rshift = %4d\n", rmask, rshift); */
gshift
=
0
;
gmask
=
visual
->
green_mask
;
while
(
0
==
(
gmask
&
1
))
{
gshift
++
;
gmask
>>=
1
;
}
/* printf("gmask = %4x gshift = %4d\n", gmask, gshift); */
bshift
=
0
;
bmask
=
visual
->
blue_mask
;
while
(
0
==
(
bmask
&
1
))
{
bshift
++
;
bmask
>>=
1
;
}
/* printf("bmask = %4x bshift = %4d\n", bmask, bshift); */
/* build the color table pixel values */
for
(
i
=
0
;
i
<
ncolors
;
i
++
)
{
Uint32
rbits
=
(
rmask
*
i
)
/
(
ncolors
-
1
);
Uint32
gbits
=
(
gmask
*
i
)
/
(
ncolors
-
1
);
Uint32
bbits
=
(
bmask
*
i
)
/
(
ncolors
-
1
);
Uint32
pix
=
(
rbits
<<
rshift
)
|
(
gbits
<<
gshift
)
|
(
bbits
<<
bshift
);
colorcells
[
i
].
pixel
=
pix
;
colorcells
[
i
].
flags
=
DoRed
|
DoGreen
|
DoBlue
;
colorcells
[
i
].
red
=
ramp
[(
0
*
256
)
+
i
];
colorcells
[
i
].
green
=
ramp
[(
1
*
256
)
+
i
];
colorcells
[
i
].
blue
=
ramp
[(
2
*
256
)
+
i
];
}
XStoreColors
(
display
,
colormap
,
colorcells
,
ncolors
);
XFlush
(
display
);
SDL_free
(
colorcells
);
}
}
return
0
;
}
int
X11_GetDisplayGammaRamp
(
_THIS
,
SDL_VideoDisplay
*
display
,
Uint16
*
ramp
)
{
int
i
;
/* find the first DirectColor colormap and use it to get the gamma
ramp */
for
(
i
=
0
;
i
<
numCmaps
;
i
++
)
{
if
(
cmapTable
[
i
].
visual
.
class
==
DirectColor
)
{
SDL_memcpy
(
ramp
,
cmapTable
[
i
].
ramp
,
SDL_GammaRampSize
);
return
0
;
}
}
return
-
1
;
}
src/video/x11/SDL_x11gamma.h
deleted
100644 → 0
View file @
c4f308a1
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2010 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
#ifndef _SDL_x11gamma_h
#define _SDL_x11gamma_h
extern
Colormap
X11_LookupColormap
(
Display
*
display
,
int
scrNum
,
VisualID
vid
);
extern
void
X11_TrackColormap
(
Display
*
display
,
int
scrNum
,
Colormap
colormap
,
Visual
*
visual
,
XColor
*
ramp
);
extern
int
X11_SetDisplayGammaRamp
(
_THIS
,
SDL_VideoDisplay
*
display
,
Uint16
*
ramp
);
extern
int
X11_GetDisplayGammaRamp
(
_THIS
,
SDL_VideoDisplay
*
display
,
Uint16
*
ramp
);
#endif
src/video/x11/SDL_x11modes.c
View file @
e0f869b6
...
@@ -47,9 +47,7 @@ get_visualinfo(Display * display, int screen, XVisualInfo * vinfo)
...
@@ -47,9 +47,7 @@ get_visualinfo(Display * display, int screen, XVisualInfo * vinfo)
}
}
depth
=
DefaultDepth
(
display
,
screen
);
depth
=
DefaultDepth
(
display
,
screen
);
if
((
X11_UseDirectColorVisuals
()
&&
if
(
XMatchVisualInfo
(
display
,
screen
,
depth
,
TrueColor
,
vinfo
)
||
XMatchVisualInfo
(
display
,
screen
,
depth
,
DirectColor
,
vinfo
))
||
XMatchVisualInfo
(
display
,
screen
,
depth
,
TrueColor
,
vinfo
)
||
XMatchVisualInfo
(
display
,
screen
,
depth
,
PseudoColor
,
vinfo
)
||
XMatchVisualInfo
(
display
,
screen
,
depth
,
PseudoColor
,
vinfo
)
||
XMatchVisualInfo
(
display
,
screen
,
depth
,
StaticColor
,
vinfo
))
{
XMatchVisualInfo
(
display
,
screen
,
depth
,
StaticColor
,
vinfo
))
{
return
0
;
return
0
;
...
...
src/video/x11/SDL_x11opengl.c
View file @
e0f869b6
...
@@ -365,22 +365,9 @@ X11_GL_GetVisual(_THIS, Display * display, int screen)
...
@@ -365,22 +365,9 @@ X11_GL_GetVisual(_THIS, Display * display, int screen)
GLX_SLOW_VISUAL_EXT
;
GLX_SLOW_VISUAL_EXT
;
}
}
#ifdef GLX_DIRECT_COLOR
/* Try for a DirectColor visual for gamma support */
if
(
X11_UseDirectColorVisuals
())
{
attribs
[
i
++
]
=
GLX_X_VISUAL_TYPE
;
attribs
[
i
++
]
=
GLX_DIRECT_COLOR
;
}
#endif
attribs
[
i
++
]
=
None
;
attribs
[
i
++
]
=
None
;
vinfo
=
_this
->
gl_data
->
glXChooseVisual
(
display
,
screen
,
attribs
);
vinfo
=
_this
->
gl_data
->
glXChooseVisual
(
display
,
screen
,
attribs
);
#ifdef GLX_DIRECT_COLOR
if
(
!
vinfo
&&
X11_UseDirectColorVisuals
())
{
/* No DirectColor visual? Try again.. */
attribs
[
i
-
3
]
=
None
;
vinfo
=
_this
->
gl_data
->
glXChooseVisual
(
display
,
screen
,
attribs
);
}
#endif
if
(
!
vinfo
)
{
if
(
!
vinfo
)
{
SDL_SetError
(
"Couldn't find matching GLX visual"
);
SDL_SetError
(
"Couldn't find matching GLX visual"
);
}
}
...
...
src/video/x11/SDL_x11video.c
View file @
e0f869b6
...
@@ -186,8 +186,6 @@ X11_CreateDevice(int devindex)
...
@@ -186,8 +186,6 @@ X11_CreateDevice(int devindex)
device
->
VideoQuit
=
X11_VideoQuit
;
device
->
VideoQuit
=
X11_VideoQuit
;
device
->
GetDisplayModes
=
X11_GetDisplayModes
;
device
->
GetDisplayModes
=
X11_GetDisplayModes
;
device
->
SetDisplayMode
=
X11_SetDisplayMode
;
device
->
SetDisplayMode
=
X11_SetDisplayMode
;
device
->
SetDisplayGammaRamp
=
X11_SetDisplayGammaRamp
;
device
->
GetDisplayGammaRamp
=
X11_GetDisplayGammaRamp
;
device
->
SuspendScreenSaver
=
X11_SuspendScreenSaver
;
device
->
SuspendScreenSaver
=
X11_SuspendScreenSaver
;
device
->
PumpEvents
=
X11_PumpEvents
;
device
->
PumpEvents
=
X11_PumpEvents
;
...
@@ -384,13 +382,4 @@ X11_VideoQuit(_THIS)
...
@@ -384,13 +382,4 @@ X11_VideoQuit(_THIS)
X11_QuitTouch
(
_this
);
X11_QuitTouch
(
_this
);
}
}
SDL_bool
X11_UseDirectColorVisuals
(
void
)
{
/* Once we implement DirectColor colormaps and gamma ramp support...
return SDL_getenv("SDL_VIDEO_X11_NODIRECTCOLOR") ? SDL_FALSE : SDL_TRUE;
*/
return
SDL_FALSE
;
}
/* vim: set ts=4 sw=4 expandtab: */
/* vim: set ts=4 sw=4 expandtab: */
src/video/x11/SDL_x11video.h
View file @
e0f869b6
...
@@ -55,7 +55,6 @@
...
@@ -55,7 +55,6 @@
#include "SDL_x11clipboard.h"
#include "SDL_x11clipboard.h"
#include "SDL_x11events.h"
#include "SDL_x11events.h"
#include "SDL_x11gamma.h"
#include "SDL_x11keyboard.h"
#include "SDL_x11keyboard.h"
#include "SDL_x11modes.h"
#include "SDL_x11modes.h"
#include "SDL_x11mouse.h"
#include "SDL_x11mouse.h"
...
@@ -93,8 +92,6 @@ typedef struct SDL_VideoData
...
@@ -93,8 +92,6 @@ typedef struct SDL_VideoData
SDL_bool
selection_waiting
;
SDL_bool
selection_waiting
;
}
SDL_VideoData
;
}
SDL_VideoData
;
extern
SDL_bool
X11_UseDirectColorVisuals
(
void
);
#endif
/* _SDL_x11video_h */
#endif
/* _SDL_x11video_h */
/* vi: set ts=4 sw=4 expandtab: */
/* vi: set ts=4 sw=4 expandtab: */
src/video/x11/SDL_x11window.c
View file @
e0f869b6
...
@@ -28,7 +28,6 @@
...
@@ -28,7 +28,6 @@
#include "SDL_x11video.h"
#include "SDL_x11video.h"
#include "SDL_x11mouse.h"
#include "SDL_x11mouse.h"
#include "SDL_x11gamma.h"
#include "SDL_x11shape.h"
#include "SDL_x11shape.h"
#ifdef SDL_VIDEO_DRIVER_PANDORA
#ifdef SDL_VIDEO_DRIVER_PANDORA
...
@@ -326,217 +325,7 @@ X11_CreateWindow(_THIS, SDL_Window * window)
...
@@ -326,217 +325,7 @@ X11_CreateWindow(_THIS, SDL_Window * window)
}
}
xattr
.
background_pixel
=
0
;
xattr
.
background_pixel
=
0
;
xattr
.
border_pixel
=
0
;
xattr
.
border_pixel
=
0
;
xattr
.
colormap
=
XCreateColormap
(
display
,
RootWindow
(
display
,
screen
),
visual
,
AllocNone
);
if
(
visual
->
class
==
PseudoColor
)
{
printf
(
"asking for PseudoColor
\n
"
);
/* Status status; */
XColor
*
colorcells
;
Colormap
colormap
;
Sint32
pix
;
Sint32
ncolors
;
Sint32
nbits
;
Sint32
rmax
,
gmax
,
bmax
;
Sint32
rwidth
,
gwidth
,
bwidth
;
Sint32
rmask
,
gmask
,
bmask
;
Sint32
rshift
,
gshift
,
bshift
;
Sint32
r
,
g
,
b
;
/* Is the colormap we need already registered in SDL? */
if
((
colormap
=
X11_LookupColormap
(
display
,
screen
,
visual
->
visualid
)))
{
xattr
.
colormap
=
colormap
;
/* printf("found existing colormap\n"); */
}
else
{
/* The colormap is not known to SDL so we will create it */
colormap
=
XCreateColormap
(
display
,
RootWindow
(
display
,
screen
),
visual
,
AllocAll
);
/* printf("colormap = %x\n", colormap); */
/* If we can't create a colormap, then we must die */
if
(
!
colormap
)
{
SDL_SetError
(
"Couldn't create window: Could not create writable colormap"
);
return
-
1
;
}
/* OK, we got a colormap, now fill it in as best as we can */
colorcells
=
SDL_malloc
(
visual
->
map_entries
*
sizeof
(
XColor
));
if
(
NULL
==
colorcells
)
{
SDL_SetError
(
"out of memory in X11_CreateWindow"
);
return
-
1
;
}
ncolors
=
visual
->
map_entries
;
nbits
=
visual
->
bits_per_rgb
;
/* printf("ncolors = %d nbits = %d\n", ncolors, nbits); */
/* what if ncolors != (1 << nbits)? That can happen on a
true PseudoColor display. I'm assuming that we will
always have ncolors == (1 << nbits) */
/* I'm making a lot of assumptions here. */
/* Compute the width of each field. If there is one extra
bit, give it to green. If there are two extra bits give
them to red and greed. We can get extra bits when the
number of bits per pixel is not a multiple of 3. For
example when we have 16 bits per pixel and need a 5/6/5
layout for the RGB fields */
rwidth
=
(
nbits
/
3
)
+
(((
nbits
%
3
)
==
2
)
?
1
:
0
);
gwidth
=
(
nbits
/
3
)
+
(((
nbits
%
3
)
>=
1
)
?
1
:
0
);
bwidth
=
(
nbits
/
3
);
rshift
=
gwidth
+
bwidth
;
gshift
=
bwidth
;
bshift
=
0
;
rmax
=
1
<<
rwidth
;
gmax
=
1
<<
gwidth
;
bmax
=
1
<<
bwidth
;
rmask
=
rmax
-
1
;
gmask
=
gmax
-
1
;
bmask
=
bmax
-
1
;
/* printf("red mask = %4x shift = %4d width = %d\n", rmask, rshift, rwidth); */
/* printf("green mask = %4x shift = %4d width = %d\n", gmask, gshift, gwidth); */
/* printf("blue mask = %4x shift = %4d width = %d\n", bmask, bshift, bwidth); */
/* build the color table pixel values */
pix
=
0
;
for
(
r
=
0
;
r
<
rmax
;
r
++
)
{
for
(
g
=
0
;
g
<
gmax
;
g
++
)
{
for
(
b
=
0
;
b
<
bmax
;
b
++
)
{
colorcells
[
pix
].
pixel
=
(
r
<<
rshift
)
|
(
g
<<
gshift
)
|
(
b
<<
bshift
);
colorcells
[
pix
].
red
=
(
0xffff
*
r
)
/
rmask
;
colorcells
[
pix
].
green
=
(
0xffff
*
g
)
/
gmask
;
colorcells
[
pix
].
blue
=
(
0xffff
*
b
)
/
bmask
;
/* printf("%4x:%4x [%4x %4x %4x]\n", */
/* pix, */
/* colorcells[pix].pixel, */
/* colorcells[pix].red, */
/* colorcells[pix].green, */
/* colorcells[pix].blue); */
pix
++
;
}
}
}
/* status = */
/* XStoreColors(display, colormap, colorcells, ncolors); */
xattr
.
colormap
=
colormap
;
X11_TrackColormap
(
display
,
screen
,
colormap
,
visual
,
NULL
);
SDL_free
(
colorcells
);
}
}
else
if
(
visual
->
class
==
DirectColor
)
{
Status
status
;
XColor
*
colorcells
;
Colormap
colormap
;
int
i
;
int
ncolors
;
int
rmax
,
gmax
,
bmax
;
int
rmask
,
gmask
,
bmask
;
int
rshift
,
gshift
,
bshift
;
/* Is the colormap we need already registered in SDL? */
if
((
colormap
=
X11_LookupColormap
(
display
,
screen
,
visual
->
visualid
)))
{
xattr
.
colormap
=
colormap
;
/* printf("found existing colormap\n"); */
}
else
{
/* The colormap is not known to SDL so we will create it */
colormap
=
XCreateColormap
(
display
,
RootWindow
(
display
,
screen
),
visual
,
AllocAll
);
/* printf("colormap = %x\n", colormap); */
/* If we can't create a colormap, then we must die */
if
(
!
colormap
)
{
SDL_SetError
(
"Couldn't create window: Could not create writable colormap"
);
return
-
1
;
}
/* OK, we got a colormap, now fill it in as best as we can */
colorcells
=
SDL_malloc
(
visual
->
map_entries
*
sizeof
(
XColor
));
if
(
NULL
==
colorcells
)
{
SDL_SetError
(
"out of memory in X11_CreateWindow"
);
return
-
1
;
}
ncolors
=
visual
->
map_entries
;
rmax
=
0xffff
;
gmax
=
0xffff
;
bmax
=
0xffff
;
rshift
=
0
;
rmask
=
visual
->
red_mask
;
while
(
0
==
(
rmask
&
1
))
{
rshift
++
;
rmask
>>=
1
;
}
/* printf("rmask = %4x rshift = %4d\n", rmask, rshift); */
gshift
=
0
;
gmask
=
visual
->
green_mask
;
while
(
0
==
(
gmask
&
1
))
{
gshift
++
;
gmask
>>=
1
;
}
/* printf("gmask = %4x gshift = %4d\n", gmask, gshift); */
bshift
=
0
;
bmask
=
visual
->
blue_mask
;
while
(
0
==
(
bmask
&
1
))
{
bshift
++
;
bmask
>>=
1
;
}
/* printf("bmask = %4x bshift = %4d\n", bmask, bshift); */
/* build the color table pixel values */
for
(
i
=
0
;
i
<
ncolors
;
i
++
)
{
Uint32
red
=
(
rmax
*
i
)
/
(
ncolors
-
1
);
Uint32
green
=
(
gmax
*
i
)
/
(
ncolors
-
1
);
Uint32
blue
=
(
bmax
*
i
)
/
(
ncolors
-
1
);
Uint32
rbits
=
(
rmask
*
i
)
/
(
ncolors
-
1
);
Uint32
gbits
=
(
gmask
*
i
)
/
(
ncolors
-
1
);
Uint32
bbits
=
(
bmask
*
i
)
/
(
ncolors
-
1
);
Uint32
pix
=
(
rbits
<<
rshift
)
|
(
gbits
<<
gshift
)
|
(
bbits
<<
bshift
);
colorcells
[
i
].
pixel
=
pix
;
colorcells
[
i
].
red
=
red
;
colorcells
[
i
].
green
=
green
;
colorcells
[
i
].
blue
=
blue
;
colorcells
[
i
].
flags
=
DoRed
|
DoGreen
|
DoBlue
;
/* printf("%2d:%4x [%4x %4x %4x]\n", i, pix, red, green, blue); */
}
status
=
XStoreColors
(
display
,
colormap
,
colorcells
,
ncolors
);
xattr
.
colormap
=
colormap
;
X11_TrackColormap
(
display
,
screen
,
colormap
,
visual
,
colorcells
);
SDL_free
(
colorcells
);
}
}
else
{
xattr
.
colormap
=
XCreateColormap
(
display
,
RootWindow
(
display
,
screen
),
visual
,
AllocNone
);
}
if
(
oldstyle_fullscreen
if
(
oldstyle_fullscreen
||
window
->
x
==
SDL_WINDOWPOS_CENTERED
)
{
||
window
->
x
==
SDL_WINDOWPOS_CENTERED
)
{
...
...
test/Makefile.in
View file @
e0f869b6
...
@@ -23,7 +23,6 @@ TARGETS = \
...
@@ -23,7 +23,6 @@ TARGETS = \
testerror
$(EXE)
\
testerror
$(EXE)
\
testfile
$(EXE)
\
testfile
$(EXE)
\
testfill
$(EXE)
\
testfill
$(EXE)
\
testgamma
$(EXE)
\
testgesture
$(EXE)
\
testgesture
$(EXE)
\
testgl
$(EXE)
\
testgl
$(EXE)
\
testgl2
$(EXE)
\
testgl2
$(EXE)
\
...
...
test/testgamma.c
deleted
100644 → 0
View file @
c4f308a1
/* Bring up a window and manipulate the gamma on it */
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include "SDL.h"
/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
static
void
quit
(
int
rc
)
{
SDL_Quit
();
exit
(
rc
);
}
/* Turn a normal gamma value into an appropriate gamma ramp */
void
CalculateGamma
(
double
gamma
,
Uint16
*
ramp
)
{
int
i
,
value
;
gamma
=
1
.
0
/
gamma
;
for
(
i
=
0
;
i
<
256
;
++
i
)
{
value
=
(
int
)
(
pow
((
double
)
i
/
256
.
0
,
gamma
)
*
65535
.
0
+
0
.
5
);
if
(
value
>
65535
)
{
value
=
65535
;
}
ramp
[
i
]
=
(
Uint16
)
value
;
}
}
/* This can be used as a general routine for all of the test programs */
int
get_video_args
(
char
*
argv
[],
int
*
w
,
int
*
h
,
int
*
bpp
,
Uint32
*
flags
)
{
int
i
;
*
w
=
640
;
*
h
=
480
;
*
bpp
=
0
;
*
flags
=
SDL_SWSURFACE
;
for
(
i
=
1
;
argv
[
i
];
++
i
)
{
if
(
strcmp
(
argv
[
i
],
"-width"
)
==
0
)
{
if
(
argv
[
i
+
1
])
{
*
w
=
atoi
(
argv
[
++
i
]);
}
}
else
if
(
strcmp
(
argv
[
i
],
"-height"
)
==
0
)
{
if
(
argv
[
i
+
1
])
{
*
h
=
atoi
(
argv
[
++
i
]);
}
}
else
if
(
strcmp
(
argv
[
i
],
"-bpp"
)
==
0
)
{
if
(
argv
[
i
+
1
])
{
*
bpp
=
atoi
(
argv
[
++
i
]);
}
}
else
if
(
strcmp
(
argv
[
i
],
"-fullscreen"
)
==
0
)
{
*
flags
|=
SDL_FULLSCREEN
;
}
else
if
(
strcmp
(
argv
[
i
],
"-hw"
)
==
0
)
{
*
flags
|=
SDL_HWSURFACE
;
}
else
if
(
strcmp
(
argv
[
i
],
"-hwpalette"
)
==
0
)
{
*
flags
|=
SDL_HWPALETTE
;
}
else
break
;
}
return
i
;
}
int
main
(
int
argc
,
char
*
argv
[])
{
SDL_Surface
*
screen
;
SDL_Surface
*
image
;
float
gamma
;
int
i
;
int
w
,
h
,
bpp
;
Uint32
flags
;
Uint16
ramp
[
256
];
Uint16
red_ramp
[
256
];
Uint32
then
,
timeout
;
/* Check command line arguments */
argv
+=
get_video_args
(
argv
,
&
w
,
&
h
,
&
bpp
,
&
flags
);
/* Initialize SDL */
if
(
SDL_Init
(
SDL_INIT_VIDEO
)
<
0
)
{
fprintf
(
stderr
,
"Couldn't initialize SDL: %s
\n
"
,
SDL_GetError
());
return
(
1
);
}
/* Initialize the display, always use hardware palette */
screen
=
SDL_SetVideoMode
(
w
,
h
,
bpp
,
flags
|
SDL_HWPALETTE
);
if
(
screen
==
NULL
)
{
fprintf
(
stderr
,
"Couldn't set %dx%d video mode: %s
\n
"
,
w
,
h
,
SDL_GetError
());
quit
(
1
);
}
/* Set the window manager title bar */
SDL_WM_SetCaption
(
"SDL gamma test"
,
"testgamma"
);
/* Set the desired gamma, if any */
gamma
=
1
.
0
f
;
if
(
*
argv
)
{
gamma
=
(
float
)
atof
(
*
argv
);
}
if
(
SDL_SetGamma
(
gamma
,
gamma
,
gamma
)
<
0
)
{
fprintf
(
stderr
,
"Unable to set gamma: %s
\n
"
,
SDL_GetError
());
quit
(
1
);
}
#if 0 /* This isn't supported. Integrating the gamma ramps isn't exact */
/* See what gamma was actually set */
float real[3];
if (SDL_GetGamma(&real[0], &real[1], &real[2]) < 0) {
printf("Couldn't get gamma: %s\n", SDL_GetError());
} else {
printf("Set gamma values: R=%2.2f, G=%2.2f, B=%2.2f\n",
real[0], real[1], real[2]);
}
#endif
/* Do all the drawing work */
image
=
SDL_LoadBMP
(
"sample.bmp"
);
if
(
image
)
{
SDL_Rect
dst
;
dst
.
x
=
(
screen
->
w
-
image
->
w
)
/
2
;
dst
.
y
=
(
screen
->
h
-
image
->
h
)
/
2
;
dst
.
w
=
image
->
w
;
dst
.
h
=
image
->
h
;
SDL_BlitSurface
(
image
,
NULL
,
screen
,
&
dst
);
SDL_UpdateRects
(
screen
,
1
,
&
dst
);
}
/* Wait a bit, handling events */
then
=
SDL_GetTicks
();
timeout
=
(
5
*
1000
);
while
((
SDL_GetTicks
()
-
then
)
<
timeout
)
{
SDL_Event
event
;
while
(
SDL_PollEvent
(
&
event
))
{
switch
(
event
.
type
)
{
case
SDL_QUIT
:
/* Quit now */
timeout
=
0
;
break
;
case
SDL_KEYDOWN
:
switch
(
event
.
key
.
keysym
.
sym
)
{
case
SDLK_SPACE
:
/* Go longer.. */
timeout
+=
(
5
*
1000
);
break
;
case
SDLK_UP
:
gamma
+=
0
.
2
f
;
SDL_SetGamma
(
gamma
,
gamma
,
gamma
);
break
;
case
SDLK_DOWN
:
gamma
-=
0
.
2
f
;
SDL_SetGamma
(
gamma
,
gamma
,
gamma
);
break
;
case
SDLK_ESCAPE
:
timeout
=
0
;
break
;
default:
break
;
}
break
;
}
}
}
/* Perform a gamma flash to red using color ramps */
while
(
gamma
<
10
.
0
)
{
/* Increase the red gamma and decrease everything else... */
gamma
+=
0
.
1
f
;
CalculateGamma
(
gamma
,
red_ramp
);
CalculateGamma
(
1
.
0
/
gamma
,
ramp
);
SDL_SetGammaRamp
(
red_ramp
,
ramp
,
ramp
);
}
/* Finish completely red */
memset
(
red_ramp
,
255
,
sizeof
(
red_ramp
));
memset
(
ramp
,
0
,
sizeof
(
ramp
));
SDL_SetGammaRamp
(
red_ramp
,
ramp
,
ramp
);
/* Now fade out to black */
for
(
i
=
(
red_ramp
[
0
]
>>
8
);
i
>=
0
;
--
i
)
{
memset
(
red_ramp
,
i
,
sizeof
(
red_ramp
));
SDL_SetGammaRamp
(
red_ramp
,
NULL
,
NULL
);
}
SDL_Delay
(
1
*
1000
);
SDL_Quit
();
return
(
0
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment