mirror of
https://github.com/godotengine/godot.git
synced 2025-02-14 23:01:25 +00:00
Haiku: create a GL context and initialize the audio and physics servers
This commit is contained in:
parent
f99b72c04f
commit
8df3e30abd
@ -1,4 +1,4 @@
|
||||
#ifdef GLEW_ENABLED
|
||||
#ifndef GLEW_ENABLED
|
||||
/*
|
||||
** The OpenGL Extension Wrangler Library
|
||||
** Copyright (C) 2002-2008, Milan Ikits <milan ikits[]ieee org>
|
||||
|
@ -1,7 +1,11 @@
|
||||
Import('env')
|
||||
|
||||
common_haiku = [
|
||||
'os_haiku.cpp'
|
||||
'os_haiku.cpp',
|
||||
'context_gl_haiku.cpp',
|
||||
'haiku_application.cpp',
|
||||
'haiku_direct_window.cpp',
|
||||
'haiku_gl_view.cpp'
|
||||
]
|
||||
|
||||
env.Program(
|
||||
|
55
platform/haiku/context_gl_haiku.cpp
Normal file
55
platform/haiku/context_gl_haiku.cpp
Normal file
@ -0,0 +1,55 @@
|
||||
#include "context_gl_haiku.h"
|
||||
|
||||
#if defined(OPENGL_ENABLED) || defined(LEGACYGL_ENABLED)
|
||||
|
||||
ContextGL_Haiku::ContextGL_Haiku(HaikuDirectWindow** p_window, OS::VideoMode& p_default_video_mode) {
|
||||
video_mode = p_default_video_mode;
|
||||
|
||||
uint32 type = BGL_RGB|BGL_DOUBLE|BGL_DEPTH;
|
||||
|
||||
BRect windowRect;
|
||||
windowRect.Set(50, 50, 800, 600);
|
||||
|
||||
window = new HaikuDirectWindow(windowRect);
|
||||
view = new HaikuGLView(window->Bounds(), type);
|
||||
|
||||
*p_window = window;
|
||||
}
|
||||
|
||||
ContextGL_Haiku::~ContextGL_Haiku() {
|
||||
delete view;
|
||||
}
|
||||
|
||||
Error ContextGL_Haiku::initialize() {
|
||||
window->AddChild(view);
|
||||
view->LockGL();
|
||||
window->SetHaikuGLView(view);
|
||||
window->InitMessageRunner();
|
||||
window->Show();
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
void ContextGL_Haiku::release_current() {
|
||||
ERR_PRINT("release_current() NOT IMPLEMENTED");
|
||||
}
|
||||
|
||||
void ContextGL_Haiku::make_current() {
|
||||
ERR_PRINT("make_current() NOT IMPLEMENTED");
|
||||
}
|
||||
|
||||
void ContextGL_Haiku::swap_buffers() {
|
||||
view->SwapBuffers();
|
||||
}
|
||||
|
||||
int ContextGL_Haiku::get_window_width() {
|
||||
// TODO: implement
|
||||
return 800;
|
||||
}
|
||||
|
||||
int ContextGL_Haiku::get_window_height() {
|
||||
// TODO: implement
|
||||
return 600;
|
||||
}
|
||||
|
||||
#endif
|
31
platform/haiku/context_gl_haiku.h
Normal file
31
platform/haiku/context_gl_haiku.h
Normal file
@ -0,0 +1,31 @@
|
||||
#ifndef CONTEXT_GL_HAIKU_H
|
||||
#define CONTEXT_GL_HAIKU_H
|
||||
|
||||
#if defined(OPENGL_ENABLED) || defined(LEGACYGL_ENABLED)
|
||||
|
||||
#include "os/os.h"
|
||||
#include "drivers/gl_context/context_gl.h"
|
||||
|
||||
#include "haiku_direct_window.h"
|
||||
#include "haiku_gl_view.h"
|
||||
|
||||
class ContextGL_Haiku : public ContextGL {
|
||||
private:
|
||||
HaikuGLView* view;
|
||||
HaikuDirectWindow* window;
|
||||
OS::VideoMode video_mode;
|
||||
|
||||
public:
|
||||
ContextGL_Haiku(HaikuDirectWindow** p_window, OS::VideoMode& default_video_mode);
|
||||
~ContextGL_Haiku();
|
||||
|
||||
virtual Error initialize();
|
||||
virtual void release_current();
|
||||
virtual void make_current();
|
||||
virtual void swap_buffers();
|
||||
virtual int get_window_width();
|
||||
virtual int get_window_height();
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
@ -50,9 +50,10 @@ def configure(env):
|
||||
env.Append(CCFLAGS=['-g2', '-Wall','-DDEBUG_ENABLED','-DDEBUG_MEMORY_ENABLED'])
|
||||
|
||||
#env.Append(CCFLAGS=['-DFREETYPE_ENABLED'])
|
||||
env.Append(CPPFLAGS = ['-DGLEW_ENABLED'])
|
||||
env.Append(CPPFLAGS = ['-DOPENGL_ENABLED'])
|
||||
env.Append(CPPFLAGS = ['-DUNIX_ENABLED', '-DGLES2_ENABLED', '-DGLES_OVER_GL'])
|
||||
env.Append(LIBS = ['be', 'GL', 'GLEW', 'z', 'network', 'bnetapi'])
|
||||
env.Append(LIBS = ['be', 'game', 'GL', 'GLEW', 'z', 'network', 'bnetapi'])
|
||||
|
||||
import methods
|
||||
env.Append(BUILDERS = {'GLSL120' : env.Builder(action = methods.build_legacygl_headers, suffix = 'glsl.h',src_suffix = '.glsl')})
|
||||
|
7
platform/haiku/haiku_application.cpp
Normal file
7
platform/haiku/haiku_application.cpp
Normal file
@ -0,0 +1,7 @@
|
||||
#include "haiku_application.h"
|
||||
|
||||
HaikuApplication::HaikuApplication()
|
||||
: BApplication("application/x-vnd.Haiku-GLDirectMode")
|
||||
{
|
||||
|
||||
}
|
15
platform/haiku/haiku_application.h
Normal file
15
platform/haiku/haiku_application.h
Normal file
@ -0,0 +1,15 @@
|
||||
#ifndef HAIKU_APPLICATION_H
|
||||
#define HAIKU_APPLICATION_H
|
||||
|
||||
#include <kernel/image.h> // needed for image_id
|
||||
#include <Application.h>
|
||||
|
||||
class HaikuApplication : public BApplication
|
||||
{
|
||||
public:
|
||||
HaikuApplication();
|
||||
//private:
|
||||
// HaikuDirectWindow* window;
|
||||
};
|
||||
|
||||
#endif
|
45
platform/haiku/haiku_direct_window.cpp
Normal file
45
platform/haiku/haiku_direct_window.cpp
Normal file
@ -0,0 +1,45 @@
|
||||
#include "haiku_direct_window.h"
|
||||
|
||||
HaikuDirectWindow::HaikuDirectWindow(BRect p_frame)
|
||||
: BDirectWindow(p_frame, "Godot", B_TITLED_WINDOW, 0)
|
||||
{
|
||||
// TODO: formatting
|
||||
float minWidth = 0.0f;
|
||||
float maxWidth = 0.0f;
|
||||
float minHeight = 0.0f;
|
||||
float maxHeight = 0.0f;
|
||||
|
||||
GetSizeLimits(&minWidth, &maxWidth, &minHeight, &maxHeight);
|
||||
SetSizeLimits(50.0f, maxWidth, 50.0f, maxHeight);
|
||||
}
|
||||
|
||||
|
||||
HaikuDirectWindow::~HaikuDirectWindow()
|
||||
{
|
||||
delete update_runner;
|
||||
}
|
||||
|
||||
void HaikuDirectWindow::SetHaikuGLView(HaikuGLView* p_view) {
|
||||
view = p_view;
|
||||
}
|
||||
|
||||
void HaikuDirectWindow::InitMessageRunner() {
|
||||
update_runner = new BMessageRunner(BMessenger(view),
|
||||
new BMessage(REDRAW_MSG), 1000000/60 /* 60 fps */);
|
||||
}
|
||||
|
||||
|
||||
bool HaikuDirectWindow::QuitRequested()
|
||||
{
|
||||
view->EnableDirectMode(false);
|
||||
be_app->PostMessage(B_QUIT_REQUESTED);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void HaikuDirectWindow::DirectConnected(direct_buffer_info *info)
|
||||
{
|
||||
view->DirectConnected(info);
|
||||
view->EnableDirectMode(true);
|
||||
}
|
||||
|
27
platform/haiku/haiku_direct_window.h
Normal file
27
platform/haiku/haiku_direct_window.h
Normal file
@ -0,0 +1,27 @@
|
||||
#ifndef HAIKU_DIRECT_WINDOW_H
|
||||
#define HAIKU_DIRECT_WINDOW_H
|
||||
|
||||
#include <kernel/image.h> // needed for image_id
|
||||
#include <DirectWindow.h>
|
||||
|
||||
#include "haiku_gl_view.h"
|
||||
|
||||
#define REDRAW_MSG 'rdrw'
|
||||
|
||||
class HaikuDirectWindow : public BDirectWindow
|
||||
{
|
||||
public:
|
||||
HaikuDirectWindow(BRect p_frame);
|
||||
~HaikuDirectWindow();
|
||||
|
||||
void SetHaikuGLView(HaikuGLView* p_view);
|
||||
void InitMessageRunner();
|
||||
virtual bool QuitRequested();
|
||||
virtual void DirectConnected(direct_buffer_info *info);
|
||||
|
||||
private:
|
||||
HaikuGLView* view;
|
||||
BMessageRunner* update_runner;
|
||||
};
|
||||
|
||||
#endif
|
54
platform/haiku/haiku_gl_view.cpp
Normal file
54
platform/haiku/haiku_gl_view.cpp
Normal file
@ -0,0 +1,54 @@
|
||||
#include "haiku_gl_view.h"
|
||||
|
||||
HaikuGLView::HaikuGLView(BRect frame, uint32 type)
|
||||
: BGLView(frame, "SampleGLView", B_FOLLOW_ALL_SIDES, 0, type), rotate(0)
|
||||
{
|
||||
width = frame.right-frame.left;
|
||||
height = frame.bottom-frame.top;
|
||||
}
|
||||
|
||||
void HaikuGLView::AttachedToWindow(void)
|
||||
{
|
||||
LockGL();
|
||||
BGLView::AttachedToWindow();
|
||||
UnlockGL();
|
||||
MakeFocus();
|
||||
}
|
||||
|
||||
void HaikuGLView::FrameResized(float newWidth, float newHeight)
|
||||
{
|
||||
}
|
||||
|
||||
void HaikuGLView::gDraw(float rotation)
|
||||
{
|
||||
}
|
||||
|
||||
void HaikuGLView::gReshape(int width, int height)
|
||||
{
|
||||
}
|
||||
|
||||
void HaikuGLView::Render(void)
|
||||
{
|
||||
LockGL();
|
||||
SwapBuffers();
|
||||
UnlockGL();
|
||||
}
|
||||
|
||||
void HaikuGLView::MessageReceived(BMessage * msg)
|
||||
{
|
||||
switch (msg->what) {
|
||||
case 'rdrw':
|
||||
Render();
|
||||
/* Rotate a bit more */
|
||||
rotate++;
|
||||
break;
|
||||
|
||||
default:
|
||||
BGLView::MessageReceived(msg);
|
||||
}
|
||||
}
|
||||
|
||||
void HaikuGLView::KeyDown(const char *bytes, int32 numBytes)
|
||||
{
|
||||
|
||||
}
|
27
platform/haiku/haiku_gl_view.h
Normal file
27
platform/haiku/haiku_gl_view.h
Normal file
@ -0,0 +1,27 @@
|
||||
#ifndef HAIKU_GL_VIEW_H
|
||||
#define HAIKU_GL_VIEW_H
|
||||
|
||||
#include <kernel/image.h> // needed for image_id
|
||||
#include <GLView.h>
|
||||
|
||||
class HaikuGLView : public BGLView
|
||||
{
|
||||
public:
|
||||
HaikuGLView(BRect frame, uint32 type);
|
||||
virtual void AttachedToWindow(void);
|
||||
virtual void FrameResized(float newWidth, float newHeight);
|
||||
virtual void MessageReceived(BMessage * msg);
|
||||
virtual void KeyDown(const char* bytes, int32 numBytes);
|
||||
|
||||
void Render(void);
|
||||
|
||||
private:
|
||||
void gDraw(float rotation = 0);
|
||||
void gReshape(int width, int height);
|
||||
|
||||
float width;
|
||||
float height;
|
||||
float rotate;
|
||||
};
|
||||
|
||||
#endif
|
@ -1,14 +1,37 @@
|
||||
#include "servers/visual/visual_server_raster.h"
|
||||
#include "servers/visual/visual_server_wrap_mt.h"
|
||||
#include "drivers/gles2/rasterizer_gles2.h"
|
||||
#include "servers/physics/physics_server_sw.h"
|
||||
#include "main/main.h"
|
||||
|
||||
#include "os_haiku.h"
|
||||
|
||||
|
||||
OS_Haiku::OS_Haiku() {
|
||||
|
||||
AudioDriverManagerSW::add_driver(&driver_dummy);
|
||||
};
|
||||
|
||||
void OS_Haiku::run() {
|
||||
ERR_PRINT("run() NOT IMPLEMENTED");
|
||||
if (!main_loop) {
|
||||
return;
|
||||
}
|
||||
|
||||
main_loop->init();
|
||||
|
||||
/*
|
||||
while (true) {
|
||||
// TODO: process events
|
||||
|
||||
if (Main::iteration() == true) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
app->Run();
|
||||
delete app;
|
||||
|
||||
main_loop->finish();
|
||||
}
|
||||
|
||||
String OS_Haiku::get_name() {
|
||||
@ -31,20 +54,44 @@ void OS_Haiku::initialize(const VideoMode& p_desired, int p_video_driver, int p_
|
||||
main_loop = NULL;
|
||||
current_video_mode = p_desired;
|
||||
|
||||
app = new HaikuApplication();
|
||||
|
||||
#if defined(OPENGL_ENABLED) || defined(LEGACYGL_ENABLED)
|
||||
//context_gl = memnew( ContextGL_X11( x11_display, x11_window,current_videomode, false ) );
|
||||
//context_gl->initialize();
|
||||
context_gl = memnew(ContextGL_Haiku(&window, current_video_mode));
|
||||
context_gl->initialize();
|
||||
|
||||
rasterizer = memnew(RasterizerGLES2);
|
||||
#endif
|
||||
|
||||
visual_server = memnew(VisualServerRaster(rasterizer));
|
||||
|
||||
ERR_FAIL_COND(!visual_server);
|
||||
|
||||
if (get_render_thread_mode() != RENDER_THREAD_UNSAFE) {
|
||||
visual_server = memnew(VisualServerWrapMT(visual_server, get_render_thread_mode() == RENDER_SEPARATE_THREAD));
|
||||
}
|
||||
|
||||
visual_server->init();
|
||||
|
||||
physics_server = memnew(PhysicsServerSW);
|
||||
physics_server->init();
|
||||
physics_2d_server = memnew(Physics2DServerSW);
|
||||
physics_2d_server->init();
|
||||
|
||||
AudioDriverManagerSW::get_driver(p_audio_driver)->set_singleton();
|
||||
|
||||
if (AudioDriverManagerSW::get_driver(p_audio_driver)->init() != OK) {
|
||||
ERR_PRINT("Initializing audio failed.");
|
||||
}
|
||||
|
||||
sample_manager = memnew(SampleManagerMallocSW);
|
||||
audio_server = memnew(AudioServerSW(sample_manager));
|
||||
audio_server->init();
|
||||
|
||||
spatial_sound_server = memnew(SpatialSoundServerSW);
|
||||
spatial_sound_server->init();
|
||||
spatial_sound_2d_server = memnew(SpatialSound2DServerSW);
|
||||
spatial_sound_2d_server->init();
|
||||
}
|
||||
|
||||
void OS_Haiku::finalize() {
|
||||
@ -54,9 +101,29 @@ void OS_Haiku::finalize() {
|
||||
|
||||
main_loop = NULL;
|
||||
|
||||
spatial_sound_server->finish();
|
||||
memdelete(spatial_sound_server);
|
||||
|
||||
spatial_sound_2d_server->finish();
|
||||
memdelete(spatial_sound_2d_server);
|
||||
|
||||
audio_server->finish();
|
||||
memdelete(audio_server);
|
||||
memdelete(sample_manager);
|
||||
|
||||
visual_server->finish();
|
||||
memdelete(visual_server);
|
||||
memdelete(rasterizer);
|
||||
|
||||
physics_server->finish();
|
||||
memdelete(physics_server);
|
||||
|
||||
physics_2d_server->finish();
|
||||
memdelete(physics_2d_server);
|
||||
|
||||
#if defined(OPENGL_ENABLED) || defined(LEGACYGL_ENABLED)
|
||||
memdelete(context_gl);
|
||||
#endif
|
||||
}
|
||||
|
||||
void OS_Haiku::set_main_loop(MainLoop* p_main_loop) {
|
||||
@ -78,8 +145,21 @@ void OS_Haiku::delete_main_loop() {
|
||||
main_loop = NULL;
|
||||
}
|
||||
|
||||
void OS_Haiku::release_rendering_thread() {
|
||||
ERR_PRINT("release_rendering_thread() NOT IMPLEMENTED");
|
||||
}
|
||||
|
||||
void OS_Haiku::make_rendering_thread() {
|
||||
ERR_PRINT("make_rendering_thread() NOT IMPLEMENTED");
|
||||
}
|
||||
|
||||
bool OS_Haiku::can_draw() const {
|
||||
ERR_PRINT("can_draw() NOT IMPLEMENTED");
|
||||
// TODO: implement
|
||||
return true;
|
||||
}
|
||||
|
||||
void OS_Haiku::swap_buffers() {
|
||||
context_gl->swap_buffers();
|
||||
}
|
||||
|
||||
Point2 OS_Haiku::get_mouse_pos() const {
|
||||
@ -95,7 +175,8 @@ void OS_Haiku::set_cursor_shape(CursorShape p_shape) {
|
||||
}
|
||||
|
||||
void OS_Haiku::set_window_title(const String& p_title) {
|
||||
ERR_PRINT("set_window_title() NOT IMPLEMENTED");
|
||||
//ERR_PRINT("set_window_title() NOT IMPLEMENTED");
|
||||
window->SetTitle(p_title.utf8().get_data());
|
||||
}
|
||||
|
||||
Size2 OS_Haiku::get_window_size() const {
|
||||
|
@ -4,13 +4,39 @@
|
||||
#include "drivers/unix/os_unix.h"
|
||||
#include "servers/visual_server.h"
|
||||
#include "servers/visual/rasterizer.h"
|
||||
#include "servers/physics_server.h"
|
||||
#include "servers/physics_2d/physics_2d_server_sw.h"
|
||||
#include "servers/audio/audio_server_sw.h"
|
||||
#include "servers/audio/sample_manager_sw.h"
|
||||
#include "servers/spatial_sound/spatial_sound_server_sw.h"
|
||||
#include "servers/spatial_sound_2d/spatial_sound_2d_server_sw.h"
|
||||
#include "servers/audio/audio_driver_dummy.h"
|
||||
|
||||
#include "context_gl_haiku.h"
|
||||
#include "haiku_application.h"
|
||||
#include "haiku_direct_window.h"
|
||||
|
||||
|
||||
class OS_Haiku : public OS_Unix {
|
||||
private:
|
||||
HaikuApplication* app;
|
||||
HaikuDirectWindow* window;
|
||||
MainLoop* main_loop;
|
||||
Rasterizer* rasterizer;
|
||||
VisualServer* visual_server;
|
||||
VideoMode current_video_mode;
|
||||
PhysicsServer* physics_server;
|
||||
Physics2DServer* physics_2d_server;
|
||||
AudioServerSW* audio_server;
|
||||
SampleManagerMallocSW* sample_manager;
|
||||
SpatialSoundServerSW* spatial_sound_server;
|
||||
SpatialSound2DServerSW* spatial_sound_2d_server;
|
||||
|
||||
AudioDriverDummy driver_dummy; // TODO: use a real driver
|
||||
|
||||
#if defined(OPENGL_ENABLED) || defined(LEGACYGL_ENABLED)
|
||||
ContextGL_Haiku* context_gl;
|
||||
#endif
|
||||
|
||||
virtual void delete_main_loop();
|
||||
|
||||
@ -31,7 +57,11 @@ public:
|
||||
virtual String get_name();
|
||||
|
||||
virtual MainLoop* get_main_loop() const;
|
||||
|
||||
virtual bool can_draw() const;
|
||||
virtual void release_rendering_thread();
|
||||
virtual void make_rendering_thread();
|
||||
virtual void swap_buffers();
|
||||
|
||||
virtual Point2 get_mouse_pos() const;
|
||||
virtual int get_mouse_button_state() const;
|
||||
|
Loading…
Reference in New Issue
Block a user