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
2f941519
Commit
2f941519
authored
Jul 30, 2011
by
Nathan Heisey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Framebuffer code moved to SDL_bframebuffer.*, OpenGL support began
parent
41cbb17d
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
341 additions
and
256 deletions
+341
-256
SDL_BApp.h
src/main/beos/SDL_BApp.h
+26
-23
SDL_BWin.h
src/video/bwindow/SDL_BWin.h
+34
-49
SDL_bframebuffer.cc
src/video/bwindow/SDL_bframebuffer.cc
+172
-0
SDL_bframebuffer.h
src/video/bwindow/SDL_bframebuffer.h
+43
-0
SDL_bmodes.cc
src/video/bwindow/SDL_bmodes.cc
+1
-130
SDL_bmodes.h
src/video/bwindow/SDL_bmodes.h
+3
-9
SDL_bopengl.cc
src/video/bwindow/SDL_bopengl.cc
+46
-27
SDL_bopengl.h
src/video/bwindow/SDL_bopengl.h
+12
-3
SDL_bvideo.cc
src/video/bwindow/SDL_bvideo.cc
+4
-15
No files found.
src/main/beos/SDL_BApp.h
View file @
2f941519
...
@@ -22,6 +22,7 @@
...
@@ -22,6 +22,7 @@
#define SDL_BAPP_H
#define SDL_BAPP_H
#include <InterfaceKit.h>
#include <InterfaceKit.h>
#include <OpenGLKit.h>
#include "../../video/bwindow/SDL_bkeyboard.h"
#include "../../video/bwindow/SDL_bkeyboard.h"
...
@@ -37,16 +38,14 @@ extern "C" {
...
@@ -37,16 +38,14 @@ extern "C" {
/* Local includes */
/* Local includes */
#include "../../events/SDL_events_c.h"
#include "../../events/SDL_events_c.h"
#include "../../video/bwindow/SDL_bkeyboard.h"
#include "../../video/bwindow/SDL_bkeyboard.h"
#include "../../video/bwindow/SDL_b
modes
.h"
#include "../../video/bwindow/SDL_b
framebuffer
.h"
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#include <vector>
/* Vector should only be included if we use a C++
compiler */
#endif
#endif
#include <vector>
...
@@ -82,18 +81,15 @@ class SDL_BApp : public BApplication {
...
@@ -82,18 +81,15 @@ class SDL_BApp : public BApplication {
public
:
public
:
SDL_BApp
(
const
char
*
signature
)
:
SDL_BApp
(
const
char
*
signature
)
:
BApplication
(
signature
)
{
BApplication
(
signature
)
{
#ifndef __cplusplus
_current_context
=
NULL
;
/* Set vector imitation variables */
_ResizeArray
();
_size
=
0
;
_length
=
0
;
#endif
}
}
virtual
~
SDL_BApp
()
{
virtual
~
SDL_BApp
()
{
#ifndef __cplusplus
SDL_free
(
window_map
);
#endif
}
}
/* Event-handling functions */
/* Event-handling functions */
virtual
void
MessageReceived
(
BMessage
*
message
)
{
virtual
void
MessageReceived
(
BMessage
*
message
)
{
/* Sort out SDL-related messages */
/* Sort out SDL-related messages */
...
@@ -182,9 +178,9 @@ public:
...
@@ -182,9 +178,9 @@ public:
}
}
/* Modes methods */
/* Modes methods */
void
SetPrevMode
(
display_mode
*
prevMode
)
{
saved_mode
=
prevMode
;
}
void
SetPrevMode
(
display_mode
*
prevMode
)
{
_
saved_mode
=
prevMode
;
}
display_mode
*
GetPrevMode
()
{
return
saved_mode
;
}
display_mode
*
GetPrevMode
()
{
return
_
saved_mode
;
}
/* FIXME: Bad coding practice, but I can't include SDL_BWin.h here. Is
/* FIXME: Bad coding practice, but I can't include SDL_BWin.h here. Is
there another way to do this? */
there another way to do this? */
...
@@ -192,9 +188,15 @@ public:
...
@@ -192,9 +188,15 @@ public:
SDL_Window
*
GetSDLWindow
(
int32
winID
)
{
SDL_Window
*
GetSDLWindow
(
int32
winID
)
{
return
window_map
[
winID
];
return
_
window_map
[
winID
];
}
}
void
SetCurrentContext
(
BGLView
*
newContext
)
{
if
(
_current_context
)
_current_context
->
UnlockGL
();
_current_context
=
newContext
;
_current_context
->
LockGL
();
}
private
:
private
:
/* Event management */
/* Event management */
void
_HandleBasicWindowEvent
(
BMessage
*
msg
,
int32
sdlEventType
)
{
void
_HandleBasicWindowEvent
(
BMessage
*
msg
,
int32
sdlEventType
)
{
...
@@ -359,27 +361,28 @@ private:
...
@@ -359,27 +361,28 @@ private:
/* Vector functions: Wraps vector stuff in case we need to change
/* Vector functions: Wraps vector stuff in case we need to change
implementation */
implementation */
void
_SetSDLWindow
(
SDL_Window
*
win
,
int32
winID
)
{
void
_SetSDLWindow
(
SDL_Window
*
win
,
int32
winID
)
{
window_map
[
winID
]
=
win
;
_
window_map
[
winID
]
=
win
;
}
}
int32
_GetNumWindowSlots
()
{
int32
_GetNumWindowSlots
()
{
return
window_map
.
size
();
return
_
window_map
.
size
();
}
}
void
_PopBackWindow
()
{
void
_PopBackWindow
()
{
window_map
.
pop_back
();
_
window_map
.
pop_back
();
}
}
void
_PushBackWindow
(
SDL_Window
*
win
)
{
void
_PushBackWindow
(
SDL_Window
*
win
)
{
window_map
.
push_back
(
win
);
_
window_map
.
push_back
(
win
);
}
}
/* Members */
/* Members */
vector
<
SDL_Window
*>
window_map
;
/* Keeps track of SDL_Windows by index-id */
vector
<
SDL_Window
*>
_
window_map
;
/* Keeps track of SDL_Windows by index-id */
display_mode
*
saved_mode
;
display_mode
*
_saved_mode
;
BGLView
*
_current_context
;
};
};
#endif
#endif
src/video/bwindow/SDL_BWin.h
View file @
2f941519
...
@@ -29,6 +29,7 @@ extern "C" {
...
@@ -29,6 +29,7 @@ extern "C" {
#include "SDL_config.h"
#include "SDL_config.h"
#include "SDL.h"
#include "SDL.h"
#include "SDL_syswm.h"
#include "SDL_syswm.h"
#include "SDL_bframebuffer.h"
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
@@ -44,6 +45,7 @@ extern "C" {
...
@@ -44,6 +45,7 @@ extern "C" {
#include "SDL_events.h"
#include "SDL_events.h"
#include "../../main/beos/SDL_BApp.h"
#include "../../main/beos/SDL_BApp.h"
enum
WinCommands
{
enum
WinCommands
{
BWIN_MOVE_WINDOW
,
BWIN_MOVE_WINDOW
,
BWIN_RESIZE_WINDOW
,
BWIN_RESIZE_WINDOW
,
...
@@ -113,37 +115,35 @@ class SDL_BWin:public BDirectWindow
...
@@ -113,37 +115,35 @@ class SDL_BWin:public BDirectWindow
}
}
/*
Other construction
*/
/*
* * * * OpenGL functionality * * * *
*/
#if SDL_VIDEO_OPENGL
#if SDL_VIDEO_OPENGL
virtual
int
CreateView
(
Uint32
flags
,
Uint32
gl_flags
)
virtual
BGLView
*
CreateGLView
(
Uint32
gl_flags
)
{
{
int
retval
;
retval
=
0
;
Lock
();
Lock
();
if
(
flags
&
SDL_OPENGL
/*SDL_INTERNALOPENGL*/
)
{
if
(
_SDL_GLView
==
NULL
)
{
if
(
_SDL_GLView
==
NULL
)
{
_SDL_GLView
=
new
BGLView
(
Bounds
(),
"SDL GLView"
,
_SDL_GLView
=
new
BGLView
(
Bounds
(),
"SDL GLView"
,
B_FOLLOW_ALL_SIDES
,
B_FOLLOW_ALL_SIDES
,
(
B_WILL_DRAW
|
B_FRAME_EVENTS
),
(
B_WILL_DRAW
|
B_FRAME_EVENTS
),
gl_flags
);
gl_flags
);
}
}
if
(
_the_view
!=
_SDL_GLView
)
{
if
(
_the_view
)
{
RemoveChild
(
_the_view
);
}
AddChild
(
_SDL_GLView
);
AddChild
(
_SDL_GLView
);
_SDL_GLView
->
LockGL
();
_SDL_GLView
->
LockGL
();
/* "New" GLViews are created */
_the_view
=
_SDL_GLView
;
Unlock
();
return
(
_SDL_GLView
);
}
}
}
else
{
if
(
_the_view
)
{
virtual
void
RemoveGLView
()
{
Lock
();
if
(
_SDL_GLView
)
{
_SDL_GLView
->
UnlockGL
();
_SDL_GLView
->
UnlockGL
();
RemoveChild
(
_the_view
);
RemoveChild
(
_SDL_GLView
);
}
}
}
Unlock
();
Unlock
();
return
(
retval
);
}
virtual
void
SwapBuffers
(
void
)
{
_SDL_GLView
->
UnlockGL
();
_SDL_GLView
->
LockGL
();
_SDL_GLView
->
SwapBuffers
();
}
}
#endif
#endif
...
@@ -180,9 +180,6 @@ class SDL_BWin:public BDirectWindow
...
@@ -180,9 +180,6 @@ class SDL_BWin:public BDirectWindow
_bounds
=
info
->
window_bounds
;
_bounds
=
info
->
window_bounds
;
_bytes_per_px
=
info
->
bits_per_pixel
/
8
;
_bytes_per_px
=
info
->
bits_per_pixel
/
8
;
_buffer_dirty
=
true
;
_buffer_dirty
=
true
;
/* Now we check for a good buffer */
// SetBufferExists(!_trash_window_buffer);
}
}
break
;
break
;
...
@@ -190,6 +187,11 @@ class SDL_BWin:public BDirectWindow
...
@@ -190,6 +187,11 @@ class SDL_BWin:public BDirectWindow
_connected
=
false
;
_connected
=
false
;
break
;
break
;
}
}
#if SDL_VIDEO_OPENGL
if
(
_SDL_GLView
)
{
_SDL_GLView
->
DirectConnected
(
info
);
}
#endif
UnlockBuffer
();
UnlockBuffer
();
}
}
...
@@ -213,8 +215,8 @@ class SDL_BWin:public BDirectWindow
...
@@ -213,8 +215,8 @@ class SDL_BWin:public BDirectWindow
virtual
void
FrameResized
(
float
width
,
float
height
)
{
virtual
void
FrameResized
(
float
width
,
float
height
)
{
/* Post a message to the BApp so that it can handle the window event */
/* Post a message to the BApp so that it can handle the window event */
BMessage
msg
(
BAPP_WINDOW_RESIZED
);
BMessage
msg
(
BAPP_WINDOW_RESIZED
);
msg
.
AddInt32
(
"window-w"
,
(
int
)
width
)
+
1
;
/* TODO: Check that +1 is needed */
msg
.
AddInt32
(
"window-w"
,
(
int
)
width
+
1
)
;
/* TODO: Check that +1 is needed */
msg
.
AddInt32
(
"window-h"
,
(
int
)
height
)
+
1
;
msg
.
AddInt32
(
"window-h"
,
(
int
)
height
+
1
)
;
_PostWindowEvent
(
msg
);
_PostWindowEvent
(
msg
);
/* Perform normal hook operations */
/* Perform normal hook operations */
...
@@ -415,22 +417,6 @@ class SDL_BWin:public BDirectWindow
...
@@ -415,22 +417,6 @@ class SDL_BWin:public BDirectWindow
void
SetTrashBuffer
(
bool
trash
)
{
_trash_window_buffer
=
trash
;
}
void
SetTrashBuffer
(
bool
trash
)
{
_trash_window_buffer
=
trash
;
}
#if SDL_VIDEO_OPENGL
virtual
void
SwapBuffers
(
void
)
{
_SDL_GLView
->
UnlockGL
();
_SDL_GLView
->
LockGL
();
_SDL_GLView
->
SwapBuffers
();
}
#endif
virtual
BView
*
View
(
void
)
{
return
(
_the_view
);
}
private
:
private
:
/* Event redirection */
/* Event redirection */
void
_MouseMotionEvent
(
BPoint
&
where
,
int32
transit
)
{
void
_MouseMotionEvent
(
BPoint
&
where
,
int32
transit
)
{
...
@@ -581,7 +567,6 @@ private:
...
@@ -581,7 +567,6 @@ private:
#if SDL_VIDEO_OPENGL
#if SDL_VIDEO_OPENGL
BGLView
*
_SDL_GLView
;
BGLView
*
_SDL_GLView
;
#endif
#endif
BView
*
_the_view
;
int32
_last_buttons
;
int32
_last_buttons
;
int32
_id
;
/* Window id used by SDL_BApp */
int32
_id
;
/* Window id used by SDL_BApp */
...
...
src/video/bwindow/SDL_bframebuffer.cc
0 → 100644
View file @
2f941519
/*
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_bframebuffer.h"
#include <AppKit.h>
#include <InterfaceKit.h>
#include "SDL_bmodes.h"
#include "SDL_BWin.h"
#include "../../main/beos/SDL_BApp.h"
#ifdef __cplusplus
extern
"C"
{
#endif
static
inline
SDL_BWin
*
_ToBeWin
(
SDL_Window
*
window
)
{
return
((
SDL_BWin
*
)(
window
->
driverdata
));
}
static
inline
SDL_BApp
*
_GetBeApp
()
{
return
((
SDL_BApp
*
)
be_app
);
}
int
BE_CreateWindowFramebuffer
(
_THIS
,
SDL_Window
*
window
,
Uint32
*
format
,
void
**
pixels
,
int
*
pitch
)
{
SDL_BWin
*
bwin
=
_ToBeWin
(
window
);
BScreen
bscreen
;
if
(
!
bscreen
.
IsValid
())
{
return
-
1
;
}
while
(
!
bwin
->
Connected
())
{
snooze
(
100
);
}
/* Make sure we have exclusive access to frame buffer data */
bwin
->
LockBuffer
();
/* format */
display_mode
bmode
;
bscreen
.
GetMode
(
&
bmode
);
int32
bpp
=
ColorSpaceToBitsPerPixel
(
bmode
.
space
);
*
format
=
BPPToSDLPxFormat
(
bpp
);
/* pitch = width of screen, in bytes */
*
pitch
=
bwin
->
GetFbWidth
()
*
bwin
->
GetBytesPerPx
();
/* Create a copy of the pixel buffer if it doesn't recycle */
*
pixels
=
bwin
->
GetWindowFramebuffer
();
if
(
(
*
pixels
)
!=
NULL
)
{
SDL_free
(
*
pixels
);
}
*
pixels
=
SDL_calloc
((
*
pitch
)
*
bwin
->
GetFbHeight
()
*
bwin
->
GetBytesPerPx
(),
sizeof
(
uint8
));
bwin
->
SetWindowFramebuffer
((
uint8
*
)(
*
pixels
));
bwin
->
SetBufferExists
(
true
);
bwin
->
SetTrashBuffer
(
false
);
bwin
->
UnlockBuffer
();
return
0
;
}
int
BE_UpdateWindowFramebuffer
(
_THIS
,
SDL_Window
*
window
,
SDL_Rect
*
rects
,
int
numrects
)
{
if
(
!
window
)
return
0
;
SDL_BWin
*
bwin
=
_ToBeWin
(
window
);
bwin
->
LockBuffer
();
bwin
->
SetBufferDirty
(
true
);
bwin
->
UnlockBuffer
();
return
0
;
}
int32
BE_DrawThread
(
void
*
data
)
{
SDL_BWin
*
bwin
=
(
SDL_BWin
*
)
data
;
SDL_Window
*
window
=
_GetBeApp
()
->
GetSDLWindow
(
bwin
->
GetID
());
BScreen
bscreen
;
if
(
!
bscreen
.
IsValid
())
{
return
-
1
;
}
while
(
bwin
->
ConnectionEnabled
())
{
if
(
bwin
->
Connected
()
&&
bwin
->
BufferExists
()
&&
bwin
->
BufferIsDirty
()
)
{
bwin
->
LockBuffer
();
int32
windowPitch
=
window
->
surface
->
pitch
;
int32
bufferPitch
=
bwin
->
GetRowBytes
();
uint8
*
windowpx
;
uint8
*
bufferpx
;
int32
BPP
=
bwin
->
GetBytesPerPx
();
uint8
*
windowBaseAddress
=
(
uint8
*
)
window
->
surface
->
pixels
;
int32
windowSub
=
bwin
->
GetFbX
()
*
BPP
+
bwin
->
GetFbY
()
*
windowPitch
;
clipping_rect
*
clips
=
bwin
->
GetClips
();
int32
numClips
=
bwin
->
GetNumClips
();
int
i
,
y
;
/* Blit each clipping rectangle */
bscreen
.
WaitForRetrace
();
for
(
i
=
0
;
i
<
numClips
;
++
i
)
{
clipping_rect
rc
=
clips
[
i
];
/* Get addresses of the start of each clipping rectangle */
int32
width
=
clips
[
i
].
right
-
clips
[
i
].
left
+
1
;
int32
height
=
clips
[
i
].
bottom
-
clips
[
i
].
top
+
1
;
bufferpx
=
bwin
->
GetBufferPx
()
+
clips
[
i
].
top
*
bufferPitch
+
clips
[
i
].
left
*
BPP
;
windowpx
=
windowBaseAddress
+
clips
[
i
].
top
*
windowPitch
+
clips
[
i
].
left
*
BPP
-
windowSub
;
/* Copy each row of pixels from the window buffer into the frame
buffer */
for
(
y
=
0
;
y
<
height
;
++
y
)
{
if
(
bwin
->
CanTrashWindowBuffer
())
{
goto
escape
;
/* Break out before the buffer is killed */
}
memcpy
(
bufferpx
,
windowpx
,
width
*
BPP
);
bufferpx
+=
bufferPitch
;
windowpx
+=
windowPitch
;
}
}
bwin
->
SetBufferDirty
(
false
);
escape
:
bwin
->
UnlockBuffer
();
}
else
{
snooze
(
16000
);
}
}
return
B_OK
;
}
void
BE_DestroyWindowFramebuffer
(
_THIS
,
SDL_Window
*
window
)
{
SDL_BWin
*
bwin
=
_ToBeWin
(
window
);
bwin
->
LockBuffer
();
/* Free and clear the window buffer */
uint8
*
winBuffer
=
bwin
->
GetWindowFramebuffer
();
SDL_free
(
winBuffer
);
bwin
->
SetWindowFramebuffer
(
NULL
);
bwin
->
SetBufferExists
(
false
);
bwin
->
UnlockBuffer
();
}
#ifdef __cplusplus
}
#endif
src/video/bwindow/SDL_bframebuffer.h
0 → 100644
View file @
2f941519
/*
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_BFRAMEBUFFER_H
#define SDL_BFRAMEBUFFER_H
#include <SupportDefs.h>
#ifdef __cplusplus
extern
"C"
{
#endif
#include "../SDL_sysvideo.h"
extern
int
BE_CreateWindowFramebuffer
(
_THIS
,
SDL_Window
*
window
,
Uint32
*
format
,
void
**
pixels
,
int
*
pitch
);
extern
int
BE_UpdateWindowFramebuffer
(
_THIS
,
SDL_Window
*
window
,
SDL_Rect
*
rects
,
int
numrects
);
extern
void
BE_DestroyWindowFramebuffer
(
_THIS
,
SDL_Window
*
window
);
extern
int32
BE_DrawThread
(
void
*
data
);
#ifdef __cplusplus
}
#endif
#endif
src/video/bwindow/SDL_bmodes.cc
View file @
2f941519
...
@@ -54,7 +54,7 @@ static float get_refresh_rate(display_mode &mode) {
...
@@ -54,7 +54,7 @@ static float get_refresh_rate(display_mode &mode) {
/
float
(
mode
.
timing
.
h_total
*
mode
.
timing
.
v_total
);
/
float
(
mode
.
timing
.
h_total
*
mode
.
timing
.
v_total
);
}
}
static
inline
int
ColorSpaceToBitsPerPixel
(
uint32
colorspace
)
static
inline
int
32
ColorSpaceToBitsPerPixel
(
uint32
colorspace
)
{
{
int
bitsperpixel
;
int
bitsperpixel
;
...
@@ -207,135 +207,6 @@ int BE_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode){
...
@@ -207,135 +207,6 @@ int BE_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode){
return
-
1
;
return
-
1
;
}
}
int
BE_CreateWindowFramebuffer
(
_THIS
,
SDL_Window
*
window
,
Uint32
*
format
,
void
**
pixels
,
int
*
pitch
)
{
SDL_BWin
*
bwin
=
_ToBeWin
(
window
);
BScreen
bscreen
;
if
(
!
bscreen
.
IsValid
())
{
return
-
1
;
}
while
(
!
bwin
->
Connected
())
{
snooze
(
100
);
}
/* Make sure we have exclusive access to frame buffer data */
bwin
->
LockBuffer
();
/* format */
display_mode
bmode
;
bscreen
.
GetMode
(
&
bmode
);
int32
bpp
=
ColorSpaceToBitsPerPixel
(
bmode
.
space
);
*
format
=
BPPToSDLPxFormat
(
bpp
);
/* pitch = width of screen, in bytes */
*
pitch
=
bwin
->
GetFbWidth
()
*
bwin
->
GetBytesPerPx
();
/* Create a copy of the pixel buffer if it doesn't recycle */
*
pixels
=
bwin
->
GetWindowFramebuffer
();
if
(
(
*
pixels
)
!=
NULL
)
{
SDL_free
(
*
pixels
);
}
*
pixels
=
SDL_calloc
((
*
pitch
)
*
bwin
->
GetFbHeight
()
*
bwin
->
GetBytesPerPx
(),
sizeof
(
uint8
));
bwin
->
SetWindowFramebuffer
((
uint8
*
)(
*
pixels
));
bwin
->
SetBufferExists
(
true
);
bwin
->
SetTrashBuffer
(
false
);
bwin
->
UnlockBuffer
();
return
0
;
}
int
BE_UpdateWindowFramebuffer
(
_THIS
,
SDL_Window
*
window
,
SDL_Rect
*
rects
,
int
numrects
)
{
if
(
!
window
)
return
0
;
SDL_BWin
*
bwin
=
_ToBeWin
(
window
);
bwin
->
LockBuffer
();
bwin
->
SetBufferDirty
(
true
);
bwin
->
UnlockBuffer
();
return
0
;
}
int32
BE_DrawThread
(
void
*
data
)
{
SDL_BWin
*
bwin
=
(
SDL_BWin
*
)
data
;
SDL_Window
*
window
=
_GetBeApp
()
->
GetSDLWindow
(
bwin
->
GetID
());
BScreen
bscreen
;
if
(
!
bscreen
.
IsValid
())
{
return
-
1
;
}
while
(
bwin
->
ConnectionEnabled
())
{
if
(
bwin
->
Connected
()
&&
bwin
->
BufferExists
()
&&
bwin
->
BufferIsDirty
()
)
{
bwin
->
LockBuffer
();
int32
windowPitch
=
window
->
surface
->
pitch
;
int32
bufferPitch
=
bwin
->
GetRowBytes
();
uint8
*
windowpx
;
uint8
*
bufferpx
;
int32
BPP
=
bwin
->
GetBytesPerPx
();
uint8
*
windowBaseAddress
=
(
uint8
*
)
window
->
surface
->
pixels
;
int32
windowSub
=
bwin
->
GetFbX
()
*
BPP
+
bwin
->
GetFbY
()
*
windowPitch
;
clipping_rect
*
clips
=
bwin
->
GetClips
();
int32
numClips
=
bwin
->
GetNumClips
();
int
i
,
y
;
/* Blit each clipping rectangle */
bscreen
.
WaitForRetrace
();
for
(
i
=
0
;
i
<
numClips
;
++
i
)
{
clipping_rect
rc
=
clips
[
i
];
/* Get addresses of the start of each clipping rectangle */
int32
width
=
clips
[
i
].
right
-
clips
[
i
].
left
+
1
;
int32
height
=
clips
[
i
].
bottom
-
clips
[
i
].
top
+
1
;
bufferpx
=
bwin
->
GetBufferPx
()
+
clips
[
i
].
top
*
bufferPitch
+
clips
[
i
].
left
*
BPP
;
windowpx
=
windowBaseAddress
+
clips
[
i
].
top
*
windowPitch
+
clips
[
i
].
left
*
BPP
-
windowSub
;
/* Copy each row of pixels from the window buffer into the frame
buffer */
for
(
y
=
0
;
y
<
height
;
++
y
)
{
if
(
bwin
->
CanTrashWindowBuffer
())
{
goto
escape
;
/* Break out before the buffer is killed */
}
memcpy
(
bufferpx
,
windowpx
,
width
*
BPP
);
bufferpx
+=
bufferPitch
;
windowpx
+=
windowPitch
;
}
}
bwin
->
SetBufferDirty
(
false
);
escape
:
bwin
->
UnlockBuffer
();
}
else
{
snooze
(
16000
);
}
}
return
B_OK
;
}
void
BE_DestroyWindowFramebuffer
(
_THIS
,
SDL_Window
*
window
)
{
SDL_BWin
*
bwin
=
_ToBeWin
(
window
);
bwin
->
LockBuffer
();
/* Free and clear the window buffer */
uint8
*
winBuffer
=
bwin
->
GetWindowFramebuffer
();
SDL_free
(
winBuffer
);
bwin
->
SetWindowFramebuffer
(
NULL
);
bwin
->
SetBufferExists
(
false
);
bwin
->
UnlockBuffer
();
}
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
src/video/bwindow/SDL_bmodes.h
View file @
2f941519
...
@@ -28,6 +28,9 @@ extern "C" {
...
@@ -28,6 +28,9 @@ extern "C" {
#include "../SDL_sysvideo.h"
#include "../SDL_sysvideo.h"
extern
int32
ColorSpaceToBitsPerPixel
(
uint32
colorspace
);
extern
int32
BPPToSDLPxFormat
(
int32
bpp
);
extern
int
BE_InitModes
(
_THIS
);
extern
int
BE_InitModes
(
_THIS
);
extern
int
BE_QuitModes
(
_THIS
);
extern
int
BE_QuitModes
(
_THIS
);
extern
int
BE_GetDisplayBounds
(
_THIS
,
SDL_VideoDisplay
*
display
,
extern
int
BE_GetDisplayBounds
(
_THIS
,
SDL_VideoDisplay
*
display
,
...
@@ -36,15 +39,6 @@ extern void BE_GetDisplayModes(_THIS, SDL_VideoDisplay *display);
...
@@ -36,15 +39,6 @@ extern void BE_GetDisplayModes(_THIS, SDL_VideoDisplay *display);
extern
int
BE_SetDisplayMode
(
_THIS
,
SDL_VideoDisplay
*
display
,
extern
int
BE_SetDisplayMode
(
_THIS
,
SDL_VideoDisplay
*
display
,
SDL_DisplayMode
*
mode
);
SDL_DisplayMode
*
mode
);
extern
int
BE_CreateWindowFramebuffer
(
_THIS
,
SDL_Window
*
window
,
Uint32
*
format
,
void
**
pixels
,
int
*
pitch
);
extern
int
BE_UpdateWindowFramebuffer
(
_THIS
,
SDL_Window
*
window
,
SDL_Rect
*
rects
,
int
numrects
);
extern
void
BE_DestroyWindowFramebuffer
(
_THIS
,
SDL_Window
*
window
);
extern
int32
BE_DrawThread
(
void
*
data
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
src/video/bwindow/SDL_bopengl.cc
View file @
2f941519
...
@@ -21,14 +21,27 @@
...
@@ -21,14 +21,27 @@
#include "SDL_bopengl.h"
#include "SDL_bopengl.h"
#include <unistd.h>
#include <KernelKit.h>
#include <OpenGLKit.h>
#include "SDL_BWin.h"
#include "../../main/beos/SDL_BApp.h"
#ifdef __cplusplus
#ifdef __cplusplus
extern
"C"
{
extern
"C"
{
#endif
#endif
static
inline
SDL_BWin
*
_ToBeWin
(
SDL_Window
*
window
)
{
return
((
SDL_BWin
*
)(
window
->
driverdata
));
}
static
inline
SDL_BApp
*
_GetBeApp
()
{
return
((
SDL_BApp
*
)
be_app
);
}
/* Passing a NULL path means load pointers from the application */
/* Passing a NULL path means load pointers from the application */
int
BE_GL_LoadLibrary
(
_THIS
,
const
char
*
path
)
int
BE_GL_LoadLibrary
(
_THIS
,
const
char
*
path
)
{
{
#if 0
if
(
path
==
NULL
)
{
if
(
path
==
NULL
)
{
if
(
_this
->
gl_config
.
dll_handle
==
NULL
)
{
if
(
_this
->
gl_config
.
dll_handle
==
NULL
)
{
image_info
info
;
image_info
info
;
...
@@ -83,12 +96,10 @@ int BE_GL_LoadLibrary(_THIS, const char *path)
...
@@ -83,12 +96,10 @@ int BE_GL_LoadLibrary(_THIS, const char *path)
*
_this
->
gl_config
.
driver_path
=
'\0'
;
*
_this
->
gl_config
.
driver_path
=
'\0'
;
return
-
1
;
return
-
1
;
}
}
#endif
}
}
void
*
BE_GL_GetProcAddress
(
_THIS
,
const
char
*
proc
)
void
*
BE_GL_GetProcAddress
(
_THIS
,
const
char
*
proc
)
{
{
#if 0
if
(
_this
->
gl_config
.
dll_handle
!=
NULL
)
{
if
(
_this
->
gl_config
.
dll_handle
!=
NULL
)
{
void
*
location
=
NULL
;
void
*
location
=
NULL
;
status_t
err
;
status_t
err
;
...
@@ -105,29 +116,9 @@ void *BE_GL_GetProcAddress(_THIS, const char *proc)
...
@@ -105,29 +116,9 @@ void *BE_GL_GetProcAddress(_THIS, const char *proc)
SDL_SetError
(
"OpenGL library not loaded"
);
SDL_SetError
(
"OpenGL library not loaded"
);
return
NULL
;
return
NULL
;
}
}
#endif
}
int
BE_GL_MakeCurrent
(
_THIS
)
{
/* FIXME: should we glview->unlock and then glview->lock()? */
return
0
;
}
}
#if 0 /* Functions from 1.2 that do not appear to be used in 1.3 */
#if 0 /* Functions from 1.2 that do not appear to be used in 1.3 */
int BE_GL_GetAttribute(_THIS, SDL_GLattr attrib, int *value)
int BE_GL_GetAttribute(_THIS, SDL_GLattr attrib, int *value)
...
@@ -190,11 +181,39 @@ int BE_GL_MakeCurrent(_THIS)
...
@@ -190,11 +181,39 @@ int BE_GL_MakeCurrent(_THIS)
return 0;
return 0;
}
}
void BE_GL_SwapBuffers(_THIS)
{
SDL_Win->SwapBuffers();
}
#endif
#endif
void
BE_GL_SwapWindow
(
_THIS
,
SDL_Window
*
window
)
{
_ToBeWin
(
window
)
->
SwapBuffers
();
}
int
BE_GL_MakeCurrent
(
_THIS
,
SDL_Window
*
window
,
SDL_GLContext
context
)
{
_GetBeApp
()
->
SetCurrentContext
((
BGLView
*
)
context
);
return
0
;
}
SDL_GLContext
BE_GL_CreateContext
(
_THIS
,
SDL_Window
*
window
)
{
/* FIXME: Not sure what flags should be included here; may want to have
most of them */
return
(
SDL_GLContext
)(
_ToBeWin
(
window
)
->
CreateGLView
(
BGL_RGB
|
BGL_DOUBLE
));
}
void
BE_GL_DeleteContext
(
_THIS
,
SDL_GLContext
context
)
{
/* Currently, automatically unlocks the view */
// _ToBeWin(window)->RemoveGLView(); FIXME: Need to get the bwindow somehow
}
int
BE_GL_SetSwapInterval
(
_THIS
,
int
interval
)
{
}
int
BE_GL_GetSwapInterval
(
_THIS
)
{
}
void
BE_GL_UnloadLibrary
(
_THIS
)
{
}
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
src/video/bwindow/SDL_bopengl.h
View file @
2f941519
...
@@ -29,10 +29,19 @@ extern "C" {
...
@@ -29,10 +29,19 @@ extern "C" {
#include "../SDL_sysvideo.h"
#include "../SDL_sysvideo.h"
extern
int
BE_GL_LoadLibrary
(
_THIS
,
const
char
*
path
);
//FIXME
extern
void
*
BE_GL_GetProcAddress
(
_THIS
,
const
char
*
proc
);
//FIXME
extern
void
BE_GL_UnloadLibrary
(
_THIS
);
//TODO
//extern int BE_GL_SetupWindow(_THIS, SDL_Window * window); //TODO
extern
int
BE_GL_MakeCurrent
(
_THIS
,
SDL_Window
*
window
,
SDL_GLContext
context
);
extern
int
BE_GL_SetSwapInterval
(
_THIS
,
int
interval
);
//TODO
extern
int
BE_GL_GetSwapInterval
(
_THIS
);
//TODO
extern
void
BE_GL_SwapWindow
(
_THIS
,
SDL_Window
*
window
);
extern
SDL_GLContext
BE_GL_CreateContext
(
_THIS
,
SDL_Window
*
window
);
extern
void
BE_GL_DeleteContext
(
_THIS
,
SDL_GLContext
context
);
extern
int
BE_GL_LoadLibrary
(
_THIS
,
const
char
*
path
);
extern
void
*
BE_GL_GetProcAddress
(
_THIS
,
const
char
*
proc
);
extern
int
BE_GL_MakeCurrent
(
_THIS
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
src/video/bwindow/SDL_bvideo.cc
View file @
2f941519
...
@@ -32,22 +32,11 @@ extern "C" {
...
@@ -32,22 +32,11 @@ extern "C" {
#include "SDL_bvideo.h"
#include "SDL_bvideo.h"
#include "SDL_bopengl.h"
#include "SDL_bopengl.h"
#include "SDL_bmodes.h"
#include "SDL_bmodes.h"
#include "SDL_bframebuffer.h"
#include "SDL_bevents.h"
#include "SDL_bevents.h"
/* FIXME: Undefined functions */
/* FIXME: Undefined functions */
// #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
// #define BE_GL_GetProcAddress NULL
#define BE_GL_UnloadLibrary NULL
#define BE_GL_CreateContext NULL
// #define BE_GL_MakeCurrent NULL
#define BE_GL_SetSwapInterval NULL
#define BE_GL_GetSwapInterval NULL
#define BE_GL_SwapWindow NULL
#define BE_GL_DeleteContext NULL
#endif
#define BE_StartTextInput NULL
#define BE_StartTextInput NULL
#define BE_StopTextInput NULL
#define BE_StopTextInput NULL
#define BE_SetTextInputRect NULL
#define BE_SetTextInputRect NULL
...
@@ -116,7 +105,7 @@ BE_CreateDevice(int devindex)
...
@@ -116,7 +105,7 @@ BE_CreateDevice(int devindex)
device
->
shape_driver
.
SetWindowShape
=
NULL
;
device
->
shape_driver
.
SetWindowShape
=
NULL
;
device
->
shape_driver
.
ResizeWindowShape
=
NULL
;
device
->
shape_driver
.
ResizeWindowShape
=
NULL
;
#if SDL_VIDEO_OPENGL_WGL
/* FIXME: Replace with BeOs's SDL OPENGL stuff */
//
#if SDL_VIDEO_OPENGL_WGL /* FIXME: Replace with BeOs's SDL OPENGL stuff */
device
->
GL_LoadLibrary
=
BE_GL_LoadLibrary
;
device
->
GL_LoadLibrary
=
BE_GL_LoadLibrary
;
device
->
GL_GetProcAddress
=
BE_GL_GetProcAddress
;
device
->
GL_GetProcAddress
=
BE_GL_GetProcAddress
;
device
->
GL_UnloadLibrary
=
BE_GL_UnloadLibrary
;
device
->
GL_UnloadLibrary
=
BE_GL_UnloadLibrary
;
...
@@ -126,7 +115,7 @@ BE_CreateDevice(int devindex)
...
@@ -126,7 +115,7 @@ BE_CreateDevice(int devindex)
device
->
GL_GetSwapInterval
=
BE_GL_GetSwapInterval
;
device
->
GL_GetSwapInterval
=
BE_GL_GetSwapInterval
;
device
->
GL_SwapWindow
=
BE_GL_SwapWindow
;
device
->
GL_SwapWindow
=
BE_GL_SwapWindow
;
device
->
GL_DeleteContext
=
BE_GL_DeleteContext
;
device
->
GL_DeleteContext
=
BE_GL_DeleteContext
;
#endif
//
#endif
device
->
StartTextInput
=
BE_StartTextInput
;
device
->
StartTextInput
=
BE_StartTextInput
;
device
->
StopTextInput
=
BE_StopTextInput
;
device
->
StopTextInput
=
BE_StopTextInput
;
device
->
SetTextInputRect
=
BE_SetTextInputRect
;
device
->
SetTextInputRect
=
BE_SetTextInputRect
;
...
...
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