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" 69 : BDirectWindow(bounds,
"Untitled", look, B_NORMAL_WINDOW_FEEL, flags)
91 B_NORMAL_PRIORITY, (
void*)
this);
104 _SDL_GLView->UnlockGL();
105 RemoveChild(_SDL_GLView);
129 virtual BGLView *CreateGLView(
Uint32 gl_flags) {
131 if (_SDL_GLView ==
NULL) {
132 _SDL_GLView =
new BGLView(Bounds(),
"SDL GLView",
134 (B_WILL_DRAW | B_FRAME_EVENTS),
137 AddChild(_SDL_GLView);
138 _SDL_GLView->EnableDirectMode(
true);
139 _SDL_GLView->LockGL();
141 return (_SDL_GLView);
144 virtual void RemoveGLView() {
147 _SDL_GLView->UnlockGL();
148 RemoveChild(_SDL_GLView);
153 virtual void SwapBuffers(
void) {
154 _SDL_GLView->UnlockGL();
155 _SDL_GLView->LockGL();
156 _SDL_GLView->SwapBuffers();
168 || ((info->buffer_state & B_BUFFER_RESIZED)
169 || (info->buffer_state & B_BUFFER_RESET)
170 || (info->driver_state == B_MODE_CHANGED));
173 switch(info->buffer_state & B_DIRECT_MODE_MASK) {
177 case B_DIRECT_MODIFY:
189 _bits = (uint8*) info->bits;
203 _SDL_GLView->DirectConnected(info);
209 BDirectWindow::DirectConnected(info);
223 msg.AddInt32(
"window-x", (
int)origin.x);
224 msg.AddInt32(
"window-y", (
int)origin.y);
228 BDirectWindow::FrameMoved(origin);
235 msg.AddInt32(
"window-w", (
int)width + 1);
236 msg.AddInt32(
"window-h", (
int)height + 1);
240 BDirectWindow::FrameResized(width, height);
256 virtual void Zoom(BPoint origin,
267 BDirectWindow::Zoom(origin, width, height);
273 BDirectWindow::Show();
282 BDirectWindow::Hide();
290 BDirectWindow::Minimize(minimize);
293 BMessage msg(minState);
308 if (msg->FindPoint(
"where", &where) == B_OK
309 && msg->FindInt32(
"be:transit", &transit) == B_OK) {
317 if (msg->FindInt32(
"buttons", &buttons) == B_OK) {
326 if (msg->FindInt32(
"buttons", &buttons) == B_OK) {
331 case B_MOUSE_WHEEL_CHANGED:
333 if (msg->FindFloat(
"be:wheel_delta_x", &x) == B_OK
334 && msg->FindFloat(
"be:wheel_delta_y", &y) == B_OK) {
343 int8 bytes[4] = { 0, 0, 0, 0 };
344 while (i < 4 && msg->FindInt8(
"byte", i, &byte) == B_OK) {
348 if (msg->FindInt32(
"key", &key) == B_OK) {
354 case B_UNMAPPED_KEY_DOWN:
355 if (msg->FindInt32(
"key", &key) == B_OK) {
361 case B_UNMAPPED_KEY_UP:
362 if (msg->FindInt32(
"key", &key) == B_OK) {
377 BDirectWindow::DispatchMessage(msg, target);
382 switch (message->what) {
419 BDirectWindow::MessageReceived(message);
444 BGLView *GetGLView() {
return _SDL_GLView; }
460 if(transit == B_EXITED_VIEW) {
471 msg.AddInt32(
"x", (
int)where.x);
472 msg.AddInt32(
"y", (
int)where.y);
481 msg.AddBool(
"focusGained", focusGained);
493 if( !(buttonStateChange) ) {
498 if(buttonStateChange & B_PRIMARY_MOUSE_BUTTON) {
500 B_PRIMARY_MOUSE_BUTTON);
502 if(buttonStateChange & B_SECONDARY_MOUSE_BUTTON) {
504 B_PRIMARY_MOUSE_BUTTON);
506 if(buttonStateChange & B_TERTIARY_MOUSE_BUTTON) {
508 B_PRIMARY_MOUSE_BUTTON);
511 _last_buttons = buttons;
516 msg.AddInt32(
"button-id", button);
517 msg.AddInt32(
"button-state", state);
524 msg.AddInt32(
"xticks", x);
525 msg.AddInt32(
"yticks", y);
529 void _KeyEvent(int32 keyCode,
const int8 *keyUtf8,
const ssize_t &
len, int32 keyState) {
532 msg.AddInt32(
"key-state", keyState);
533 msg.AddInt32(
"key-scancode", keyCode);
534 if (keyUtf8 !=
NULL) {
535 msg.AddData(
"key-utf8", B_INT8_TYPE, (
const void*)keyUtf8, len);
537 be_app->PostMessage(&msg);
546 msg.AddInt32(
"window-id",
_id);
547 be_app->PostMessage(&msg);
554 msg->FindString(
"window-title", &title) != B_OK
564 msg->FindInt32(
"window-x", &x) != B_OK ||
565 msg->FindInt32(
"window-y", &y) != B_OK
575 msg->FindInt32(
"window-w", &w) != B_OK ||
576 msg->FindInt32(
"window-h", &h) != B_OK
585 if(msg->FindBool(
"window-border", &bEnabled) != B_OK) {
588 SetLook(bEnabled ? B_BORDERED_WINDOW_LOOK : B_NO_BORDER_WINDOW_LOOK);
593 if(msg->FindBool(
"window-resizable", &bEnabled) != B_OK) {
597 SetFlags(Flags() & ~(B_NOT_RESIZABLE | B_NOT_ZOOMABLE));
599 SetFlags(Flags() | (B_NOT_RESIZABLE | B_NOT_ZOOMABLE));
606 }
else if(IsHidden()) {
617 msg->FindBool(
"fullscreen", &fullscreen) != B_OK
621 SetFullScreen(fullscreen);
626 BGLView * _SDL_GLView;
GLsizei GLfixed GLfixed GLfixed GLfixed const GLubyte * bitmap
void _ResizeTo(BMessage *msg)
virtual void WindowActivated(bool active)
GLint GLint GLsizei width
bool _connection_disabled
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()
uint32_t Uint32
An unsigned 32-bit integer type.
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)
void _SetResizable(BMessage *msg)
virtual void FrameMoved(BPoint origin)
void _SetTitle(BMessage *msg)
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
void _SetBordered(BMessage *msg)
bool _trash_window_buffer
void _PostWindowEvent(BMessage &msg)
void _KeyEvent(int32 keyCode, const int8 *keyUtf8, const ssize_t &len, int32 keyState)
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()