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
a6ec7506
Commit
a6ec7506
authored
Jul 20, 2011
by
Nathan Heisey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Framebuffer support in progress.
parent
569fcd28
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
301 additions
and
70 deletions
+301
-70
SDL_BWin.h
src/video/bwindow/SDL_BWin.h
+14
-6
SDL_bevents.cc
src/video/bwindow/SDL_bevents.cc
+33
-0
SDL_bevents.h
src/video/bwindow/SDL_bevents.h
+37
-0
SDL_bmodes.cc
src/video/bwindow/SDL_bmodes.cc
+171
-45
SDL_bmodes.h
src/video/bwindow/SDL_bmodes.h
+16
-0
SDL_bvideo.cc
src/video/bwindow/SDL_bvideo.cc
+13
-9
SDL_bvideo.h
src/video/bwindow/SDL_bvideo.h
+1
-0
SDL_bwindow.cc
src/video/bwindow/SDL_bwindow.cc
+16
-10
No files found.
src/video/bwindow/SDL_BWin.h
View file @
a6ec7506
...
...
@@ -66,17 +66,16 @@ class SDL_BWin:public BDirectWindow
B_TITLED_WINDOW
,
0
)
{
last_buttons
=
0
;
printf
(
"SDL_BWin.h: 69
\n
"
);
the_view
=
NULL
;
#if SDL_VIDEO_OPENGL
SDL_GLView
=
NULL
;
#endif
SDL_View
=
NULL
;
Unlock
();
_shown
=
false
;
inhibit_resize
=
false
;
mouse_focused
=
false
;
prev_frame
=
NULL
;
prev_frame
=
NULL
;
printf
(
"SDL_BWin.h: 79
\n
"
);
}
virtual
~
SDL_BWin
()
...
...
@@ -151,6 +150,12 @@ class SDL_BWin:public BDirectWindow
return
(
retval
);
}
/* * * * * Framebuffering* * * * */
virtual
void
DirectConnected
(
direct_buffer_info
*
info
)
{
}
/* * * * * Event sending * * * * */
/* Hook functions */
virtual
void
FrameMoved
(
BPoint
origin
)
{
...
...
@@ -460,13 +465,16 @@ private:
/* Add any mouse button events */
if
(
buttonStateChange
&
B_PRIMARY_MOUSE_BUTTON
)
{
_SendMouseButton
(
SDL_BUTTON_LEFT
,
buttons
&
B_PRIMARY_MOUSE_BUTTON
);
_SendMouseButton
(
SDL_BUTTON_LEFT
,
buttons
&
B_PRIMARY_MOUSE_BUTTON
);
}
if
(
buttonStateChange
&
B_SECONDARY_MOUSE_BUTTON
)
{
_SendMouseButton
(
SDL_BUTTON_RIGHT
,
buttons
&
B_PRIMARY_MOUSE_BUTTON
);
_SendMouseButton
(
SDL_BUTTON_RIGHT
,
buttons
&
B_PRIMARY_MOUSE_BUTTON
);
}
if
(
buttonStateChange
&
B_TERTIARY_MOUSE_BUTTON
)
{
_SendMouseButton
(
SDL_BUTTON_MIDDLE
,
buttons
&
B_PRIMARY_MOUSE_BUTTON
);
_SendMouseButton
(
SDL_BUTTON_MIDDLE
,
buttons
&
B_PRIMARY_MOUSE_BUTTON
);
}
last_buttons
=
buttons
;
...
...
src/video/bwindow/SDL_bevents.cc
0 → 100644
View file @
a6ec7506
/*
Simple DirectMedia Layer
Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "SDL_bevents.h"
#ifdef __cplusplus
extern
"C"
{
#endif
void
BE_PumpEvents
(
_THIS
)
{
}
#ifdef __cplusplus
}
#endif
src/video/bwindow/SDL_bevents.h
0 → 100644
View file @
a6ec7506
/*
Simple DirectMedia Layer
Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef SDL_BEVENTS_H
#define SDL_BEVENTS_H
#include "../SDL_sysvideo.h"
#ifdef __cplusplus
extern
"C"
{
#endif
extern
void
BE_PumpEvents
(
_THIS
);
#ifdef __cplusplus
}
#endif
#endif
src/video/bwindow/SDL_bmodes.cc
View file @
a6ec7506
...
...
@@ -19,60 +19,186 @@
3. This notice may not be removed or altered from any source distribution.
*/
#include "../SDL_sysvideo.h"
int
BE_InitModes
(
_THIS
)
{
#if 0
display_mode *modes;
uint32 i, nmodes;
int bpp;
/* It is important that this be created after SDL_InitBeApp() */
BScreen bscreen;
#include <AppKit.h>
#include <InterfaceKit.h>
#include "SDL_bmodes.h"
/* Save the current display mode */
bscreen.GetMode(&saved_mode);
_this->info.current_w = saved_mode.virtual_width;
_this->info.current_h = saved_mode.virtual_height;
/* Get the video modes we can switch to in fullscreen mode */
bscreen.GetModeList(&modes, &nmodes);
SDL_qsort(modes, nmodes, sizeof *modes, CompareModes);
for (i = 0; i < nmodes; ++i) {
bpp = ColorSpaceToBitsPerPixel(modes[i].space);
//if ( bpp != 0 ) { // There are bugs in changing colorspace
if (modes[i].space == saved_mode.space) {
BE_AddMode(_this, ((bpp + 7) / 8) - 1,
modes[i].virtual_width, modes[i].virtual_height);
}
}
#else
return
-
1
;
#include "../../main/beos/SDL_BApp.h"
#ifdef __cplusplus
extern
"C"
{
#endif
static
inline
SDL_BApp
*
_GetBeApp
()
{
return
((
SDL_BApp
*
)
be_app
);
}
/* Copied from haiku/trunk/src/preferences/screen/ScreenMode.cpp */
static
float
get_refresh_rate
(
display_mode
&
mode
)
{
return
rint
(
10
*
float
(
mode
.
timing
.
pixel_clock
*
1000
)
/
float
(
mode
.
timing
.
h_total
*
mode
.
timing
.
v_total
))
/
10.0
;
}
static
inline
int
ColorSpaceToBitsPerPixel
(
uint32
colorspace
)
{
int
bitsperpixel
;
bitsperpixel
=
0
;
switch
(
colorspace
)
{
case
B_CMAP8
:
bitsperpixel
=
8
;
break
;
case
B_RGB15
:
case
B_RGBA15
:
case
B_RGB15_BIG
:
case
B_RGBA15_BIG
:
bitsperpixel
=
15
;
break
;
case
B_RGB16
:
case
B_RGB16_BIG
:
bitsperpixel
=
16
;
break
;
case
B_RGB32
:
case
B_RGBA32
:
case
B_RGB32_BIG
:
case
B_RGBA32_BIG
:
bitsperpixel
=
32
;
break
;
default
:
break
;
}
return
(
bitsperpixel
);
}
static
inline
int32
BppToSDLPxFormat
(
int32
bpp
)
{
/* Translation taken from SDL_windowsmodes.c */
switch
(
bpp
)
{
case
32
:
return
SDL_PIXELFORMAT_RGB888
;
break
;
case
24
:
/* May not be supported by Haiku */
return
SDL_PIXELFORMAT_RGB24
;
break
;
case
16
:
return
SDL_PIXELFORMAT_RGB565
;
break
;
case
15
:
return
SDL_PIXELFORMAT_RGB555
;
break
;
case
8
:
return
SDL_PIXELFORMAT_INDEX8
;
break
;
case
4
:
/* May not be supported by Haiku */
return
SDL_PIXELFORMAT_INDEX4LSB
;
break
;
}
}
static
inline
void
BE_BDisplayModeToSdlDisplayMode
(
display_mode
*
bmode
,
SDL_DisplayMode
*
mode
)
{
mode
->
w
=
bmode
->
virtual_width
;
mode
->
h
=
bmode
->
virtual_height
;
mode
->
refresh_rate
=
(
int
)
get_refresh_rate
(
*
bmode
);
mode
->
driverdata
=
bmode
;
/* This makes setting display
modes easier */
/* Set the format */
int32
bpp
=
ColorSpaceToBitsPerPixel
(
bmode
->
space
);
mode
->
format
=
BppToSDLPxFormat
(
bpp
);
}
/* Later, there may be more than one monitor available */
void
BE_AddDisplay
(
BScreen
*
screen
)
{
SDL_VideoDisplay
display
;
SDL_DisplayMode
mode
;
display_mode
bmode
;
screen
->
GetMode
(
&
bmode
);
BE_BDisplayModeToSdlDisplayMode
(
&
bmode
,
&
mode
);
SDL_zero
(
display
);
display
.
desktop_mode
=
mode
;
display
.
current_mode
=
mode
;
SDL_AddVideoDisplay
(
&
display
);
}
int
BE_InitModes
(
_THIS
)
{
printf
(
"Init Modes
\n
"
);
BScreen
screen
;
/* Save the current display mode */
display_mode
*
prevMode
;
screen
.
GetMode
(
prevMode
);
_GetBeApp
()
->
SetPrevMode
(
prevMode
);
/* Only one possible video display right now */
BE_AddDisplay
(
&
screen
);
}
int
BE_QuitModes
(
_THIS
)
{
#if 0
int i, j;
for (i = 0; i < NUM_MODELISTS; ++i) {
if (SDL_modelist[i]) {
for (j = 0; SDL_modelist[i][j]; ++j) {
SDL_free(SDL_modelist[i][j]);
}
SDL_free(SDL_modelist[i]);
SDL_modelist[i] = NULL;
/* Restore the previous video mode */
printf
(
"Quit Modes
\n
"
);
BScreen
screen
;
display_mode
*
savedMode
=
_GetBeApp
()
->
GetPrevMode
();
screen
.
SetMode
(
savedMode
);
return
0
;
}
int
BE_GetDisplayBounds
(
_THIS
,
SDL_VideoDisplay
*
display
,
SDL_Rect
*
rect
)
{
BScreen
bscreen
;
BRect
rc
=
bscreen
.
Frame
();
rect
->
x
=
(
int
)
rc
.
left
;
rect
->
y
=
(
int
)
rc
.
top
;
rect
->
w
=
(
int
)
rc
.
Width
()
+
1
;
rect
->
h
=
(
int
)
rc
.
Height
()
+
1
;
return
0
;
}
void
BE_GetDisplayModes
(
_THIS
,
SDL_VideoDisplay
*
display
)
{
printf
(
"Get Display Modes
\n
"
);
/* Get the current screen */
BScreen
bscreen
;
/* Iterate through all of the modes */
SDL_DisplayMode
mode
;
display_mode
this_bmode
;
display_mode
*
bmodes
;
uint32
count
,
i
;
/* Get graphics-hardware supported modes */
bscreen
.
GetModeList
(
&
bmodes
,
&
count
);
bscreen
.
GetMode
(
&
this_bmode
);
for
(
i
=
0
;
i
<
count
;
++
i
)
{
//FIXME: Apparently there are errors with colorspace changes
if
(
bmodes
[
i
].
space
==
this_bmode
.
space
)
{
BE_BDisplayModeToSdlDisplayMode
(
&
bmodes
[
i
],
&
mode
);
SDL_AddDisplayMode
(
display
,
&
mode
);
}
}
free
(
bmodes
);
}
/* Restore the original video mode */
if (_this->screen) {
if ((_this->screen->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN) {
BScreen bscreen;
bscreen.SetMode(&saved_mode);
}
_this->screen->pixels = NULL;
int
BE_SetDisplayMode
(
_THIS
,
SDL_VideoDisplay
*
display
,
SDL_DisplayMode
*
mode
){
printf
(
"Set Display Modes
\n
"
);
/* Get the current screen */
BScreen
bscreen
;
/* Set the mode using the driver data */
display_mode
*
bmode
=
(
display_mode
*
)
mode
->
driverdata
;
if
(
bscreen
.
SetMode
(
bmode
)
==
B_OK
)
{
return
0
;
/* No error */
}
#else
return
-
1
;
#endif
return
-
1
;
}
#ifdef __cplusplus
}
#endif
src/video/bwindow/SDL_bmodes.h
View file @
a6ec7506
...
...
@@ -22,6 +22,22 @@
#ifndef SDL_BMODES_H
#define SDL_BMODES_H
#ifdef __cplusplus
extern
"C"
{
#endif
#include "../SDL_sysvideo.h"
extern
int
BE_InitModes
(
_THIS
);
extern
int
BE_QuitModes
(
_THIS
);
extern
int
BE_GetDisplayBounds
(
_THIS
,
SDL_VideoDisplay
*
display
,
SDL_Rect
*
rect
);
extern
void
BE_GetDisplayModes
(
_THIS
,
SDL_VideoDisplay
*
display
);
extern
int
BE_SetDisplayMode
(
_THIS
,
SDL_VideoDisplay
*
display
,
SDL_DisplayMode
*
mode
);
#ifdef __cplusplus
}
#endif
#endif
src/video/bwindow/SDL_bvideo.cc
View file @
a6ec7506
...
...
@@ -20,22 +20,21 @@
*/
#ifdef __cplusplus
extern
"C"
{
#endif
#include "SDL_bwindow.h"
#include "SDL_bclipboard.h"
#include "SDL_bvideo.h"
#include "SDL_bopengl.h"
#include "SDL_bmodes.h"
#include "SDL_bevents.h"
#ifdef __cplusplus
extern
"C"
{
#endif
/* FIXME: Undefined functions */
// #define BE_VideoInit NULL
// #define BE_VideoQuit NULL
#define BE_GetDisplayBounds NULL
#define BE_GetDisplayModes NULL
#define BE_SetDisplayMode NULL
#define BE_PumpEvents NULL
// #define BE_PumpEvents NULL
#if SDL_VIDEO_OPENGL_WGL
/* FIXME: Replace with BeOs's SDL OPENGL stuff */
// #define BE_GL_LoadLibrary NULL
...
...
@@ -138,6 +137,11 @@ BE_CreateDevice(int devindex)
return
device
;
}
VideoBootStrap
BWINDOW_bootstrap
=
{
"bwindow"
,
"BDirectWindow graphics"
,
BE_Available
,
BE_CreateDevice
};
static
void
BE_DeleteDevice
(
SDL_VideoDevice
*
device
)
{
SDL_free
(
device
->
driverdata
);
...
...
src/video/bwindow/SDL_bvideo.h
View file @
a6ec7506
...
...
@@ -36,6 +36,7 @@ typedef struct SDL_VideoData {
extern
void
BE_VideoQuit
(
_THIS
);
extern
int
BE_VideoInit
(
_THIS
);
extern
void
BE_DeleteDevice
(
_THIS
);
extern
int
BE_Available
(
void
);
#ifdef __cplusplus
}
...
...
src/video/bwindow/SDL_bwindow.cc
View file @
a6ec7506
...
...
@@ -37,25 +37,25 @@ static inline SDL_BApp *_GetBeApp() {
return
((
SDL_BApp
*
)
be_app
);
}
int
_InitWindow
(
_THIS
,
SDL_Window
*
window
)
{
int
_InitWindow
(
_THIS
,
SDL_Window
*
window
)
{
printf
(
"SDL_bwindow.cc: 40
\n
"
);
BRect
bounds
(
window
->
x
,
window
->
y
,
window
->
x
+
window
->
w
-
1
,
//BeWindows have an off-by-one px w/h thing
window
->
y
+
window
->
h
-
1
);
printf
(
"SDL_bwindow.cc: 30
\n
"
);
SDL_BWin
*
bwin
=
new
(
std
::
nothrow
)
SDL_BWin
(
bounds
);
if
(
bwin
==
NULL
)
return
ENOMEM
;
printf
(
"SDL_bwindow.cc: 51
\n
"
);
window
->
driverdata
=
bwin
;
int32
winID
=
_GetBeApp
()
->
GetID
(
window
);
bwin
->
SetID
(
winID
);
return
0
;
}
int
BE_CreateWindow
(
_THIS
,
SDL_Window
*
window
)
{
int
BE_CreateWindow
(
_THIS
,
SDL_Window
*
window
)
{
printf
(
"SDL_bwindow.cc: 58
\n
"
);
if
(
_InitWindow
(
_this
,
window
)
==
ENOMEM
)
return
ENOMEM
;
...
...
@@ -179,21 +179,27 @@ SDL_bool BE_GetWindowWMInfo(_THIS, SDL_Window * window,
}
extern
int
BE_CreateWindowFramebuffer
(
_THIS
,
SDL_Window
*
window
,
int
BE_CreateWindowFramebuffer
(
_THIS
,
SDL_Window
*
window
,
Uint32
*
format
,
void
**
pixels
,
int
*
pitch
)
{
/* FIXME: Not BeOs/Haiku supported */
/* pitch = width of screen, in bytes */
BScreen
bscreen
;
*
pitch
=
(
bscreen
->
Frame
().
right
-
bscreen
->
Frame
().
left
+
1
)
*
/*screen w*/
SDL_BYTESPERPIXEL
(
*
format
);
/* FIXME: FINISH! */
return
-
1
;
}
extern
int
BE_UpdateWindowFramebuffer
(
_THIS
,
SDL_Window
*
window
,
int
BE_UpdateWindowFramebuffer
(
_THIS
,
SDL_Window
*
window
,
SDL_Rect
*
rects
,
int
numrects
)
{
/* FIXME: Not BeOs/Haiku supported */
return
-
1
;
}
extern
void
BE_DestroyWindowFramebuffer
(
_THIS
,
SDL_Window
*
window
)
{
/* FIXME:
Not BeOs/Haiku supported
*/
void
BE_DestroyWindowFramebuffer
(
_THIS
,
SDL_Window
*
window
)
{
/* FIXME:
FINISH!
*/
}
...
...
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