29 #include "../../SDL_internal.h" 40 #include <InterfaceKit.h> 41 #include <be/game/DirectWindow.h> 43 #include <be/opengl/GLView.h> 46 #include "../../main/haiku/SDL_BApp.h" 68 : BDirectWindow(bounds,
"Untitled", look, B_NORMAL_WINDOW_FEEL, flags)
90 B_NORMAL_PRIORITY, (
void*)
this);
103 _SDL_GLView->UnlockGL();
104 RemoveChild(_SDL_GLView);
128 virtual BGLView *CreateGLView(
Uint32 gl_flags) {
130 if (_SDL_GLView ==
NULL) {
131 _SDL_GLView =
new BGLView(Bounds(),
"SDL GLView",
133 (B_WILL_DRAW | B_FRAME_EVENTS),
136 AddChild(_SDL_GLView);
137 _SDL_GLView->EnableDirectMode(
true);
138 _SDL_GLView->LockGL();
140 return (_SDL_GLView);
143 virtual void RemoveGLView() {
146 _SDL_GLView->UnlockGL();
147 RemoveChild(_SDL_GLView);
152 virtual void SwapBuffers(
void) {
153 _SDL_GLView->UnlockGL();
154 _SDL_GLView->LockGL();
155 _SDL_GLView->SwapBuffers();
167 || ((info->buffer_state & B_BUFFER_RESIZED)
168 || (info->buffer_state & B_BUFFER_RESET)
169 || (info->driver_state == B_MODE_CHANGED));
172 switch(info->buffer_state & B_DIRECT_MODE_MASK) {
176 case B_DIRECT_MODIFY:
188 _bits = (uint8*) info->bits;
202 _SDL_GLView->DirectConnected(info);
208 BDirectWindow::DirectConnected(info);
222 msg.AddInt32(
"window-x", (
int)origin.x);
223 msg.AddInt32(
"window-y", (
int)origin.y);
227 BDirectWindow::FrameMoved(origin);
234 msg.AddInt32(
"window-w", (
int)width + 1);
235 msg.AddInt32(
"window-h", (
int)height + 1);
239 BDirectWindow::FrameResized(width, height);
255 virtual void Zoom(BPoint origin,
266 BDirectWindow::Zoom(origin, width, height);
272 BDirectWindow::Show();
281 BDirectWindow::Hide();
289 BDirectWindow::Minimize(minimize);
292 BMessage msg(minState);
307 if (msg->FindPoint(
"where", &where) == B_OK
308 && msg->FindInt32(
"be:transit", &transit) == B_OK) {
316 if (msg->FindInt32(
"buttons", &buttons) == B_OK) {
325 if (msg->FindInt32(
"buttons", &buttons) == B_OK) {
330 case B_MOUSE_WHEEL_CHANGED:
332 if (msg->FindFloat(
"be:wheel_delta_x", &x) == B_OK
333 && msg->FindFloat(
"be:wheel_delta_y", &y) == B_OK) {
339 case B_UNMAPPED_KEY_DOWN:
340 if (msg->FindInt32(
"key", &key) == B_OK) {
346 case B_UNMAPPED_KEY_UP:
347 if (msg->FindInt32(
"key", &key) == B_OK) {
362 BDirectWindow::DispatchMessage(msg, target);
367 switch (message->what) {
401 BDirectWindow::MessageReceived(message);
426 BGLView *GetGLView() {
return _SDL_GLView; }
442 if(transit == B_EXITED_VIEW) {
453 msg.AddInt32(
"x", (
int)where.x);
454 msg.AddInt32(
"y", (
int)where.y);
463 msg.AddBool(
"focusGained", focusGained);
475 if( !(buttonStateChange) ) {
480 if(buttonStateChange & B_PRIMARY_MOUSE_BUTTON) {
482 B_PRIMARY_MOUSE_BUTTON);
484 if(buttonStateChange & B_SECONDARY_MOUSE_BUTTON) {
486 B_PRIMARY_MOUSE_BUTTON);
488 if(buttonStateChange & B_TERTIARY_MOUSE_BUTTON) {
490 B_PRIMARY_MOUSE_BUTTON);
493 _last_buttons = buttons;
498 msg.AddInt32(
"button-id", button);
499 msg.AddInt32(
"button-state", state);
506 msg.AddInt32(
"xticks", x);
507 msg.AddInt32(
"yticks", y);
514 msg.AddInt32(
"key-state", keyState);
515 msg.AddInt32(
"key-scancode", keyCode);
516 be_app->PostMessage(&msg);
526 msg.AddInt32(
"window-id",
_id);
527 be_app->PostMessage(&msg);
534 msg->FindString(
"window-title", &title) != B_OK
544 msg->FindInt32(
"window-x", &x) != B_OK ||
545 msg->FindInt32(
"window-y", &y) != B_OK
555 msg->FindInt32(
"window-w", &w) != B_OK ||
556 msg->FindInt32(
"window-h", &h) != B_OK
565 if(msg->FindBool(
"window-border", &bEnabled) != B_OK) {
568 SetLook(bEnabled ? B_BORDERED_WINDOW_LOOK : B_NO_BORDER_WINDOW_LOOK);
574 }
else if(IsHidden()) {
585 msg->FindBool(
"fullscreen", &fullscreen) != B_OK
589 SetFullScreen(fullscreen);
594 BGLView * _SDL_GLView;
void _KeyEvent(int32 keyCode, int32 keyState)
GLsizei GLfixed GLfixed GLfixed GLfixed const GLubyte * bitmap
void _ResizeTo(BMessage *msg)
virtual void WindowActivated(bool active)
GLint GLint GLsizei width
bool _connection_disabled
uint32_t Uint32
An unsigned 32-bit integer type.
GLuint GLsizei const GLchar * message
GLint GLint GLint GLint GLint x
void _MouseButtonEvent(int32 buttons)
SDL_BWin(BRect bounds, window_look look, uint32 flags)
void _SendMouseButton(int32 button, int32 state)
clipping_rect * GetClips()
GLint GLint GLsizei GLsizei height
void SetBitmap(BBitmap *bitmap)
void SetBufferExists(bool bufferExists)
void _SetFullScreen(BMessage *msg)
void _MouseFocusEvent(bool focusGained)
GLint GLint GLint GLint GLint GLint y
virtual void DispatchMessage(BMessage *msg, BHandler *target)
virtual void Minimize(bool minimize)
virtual void Zoom(BPoint origin, float width, float height)
virtual void MessageReceived(BMessage *message)
virtual void FrameResized(float width, float height)
#define SDL_BUTTON_MIDDLE
void _MoveTo(BMessage *msg)
void SetBufferDirty(bool bufferDirty)
virtual void FrameMoved(BPoint origin)
void _SetTitle(BMessage *msg)
void _SetBordered(BMessage *msg)
bool _trash_window_buffer
void _PostWindowEvent(BMessage &msg)
void _MouseMotionEvent(BPoint &where, int32 transit)
bool CanTrashWindowBuffer()
virtual void DirectConnected(direct_buffer_info *info)
GLubyte GLubyte GLubyte GLubyte w
void SetTrashBuffer(bool trash)
thread_id _draw_thread_id
int32 BE_DrawThread(void *data)
SDL_Scancode
The SDL keyboard scancode representation.
GLfloat GLfloat GLfloat GLfloat h
void _MouseWheelEvent(int32 x, int32 y)
virtual bool QuitRequested()