summaryrefslogtreecommitdiff
path: root/beos
diff options
context:
space:
mode:
authorleo2000-08-19 18:38:17 +0000
committerleo2000-08-19 18:38:17 +0000
commit8548095d61ba49d4d49e1478533461d22979ab2a (patch)
treec11f7b5f28478b263e920efa92e313b43f599dc9 /beos
parent23628b3b6852f14a8041628a99a7780a286848d1 (diff)
start of BeOS port
git-svn-id: http://svn.leocad.org/trunk@99 c7d43263-9d01-0410-8a33-9dba5d9f93d6
Diffstat (limited to 'beos')
-rw-r--r--beos/beos_gl.cpp73
-rw-r--r--beos/beos_gl.h5
-rw-r--r--beos/main.cpp142
-rw-r--r--beos/system.cpp269
4 files changed, 489 insertions, 0 deletions
diff --git a/beos/beos_gl.cpp b/beos/beos_gl.cpp
new file mode 100644
index 0000000..df6058a
--- /dev/null
+++ b/beos/beos_gl.cpp
@@ -0,0 +1,73 @@
+//
+// BeOS OpenGL functions
+//
+
+#include <stdio.h>
+#include <be/kernel/image.h>
+#include "opengl.h"
+
+static image_id gl_image;
+
+// =============================================================================
+// Function pointers
+
+// =============================================================================
+// Global functions
+
+void* Sys_GLGetProc (const char *symbol)
+{
+ void *func;
+
+ if (get_image_symbol (gl_image, symbol, B_SYMBOL_TYPE_TEXT, &func) == B_OK)
+ return func;
+
+ printf ("Error loading OpenGL function %s.\n", symbol);
+ return NULL;
+}
+
+void* Sys_GLGetExtension (const char *symbol)
+{
+/*
+ if (pfnglXGetProcAddressARB == NULL)
+ return NULL;
+ else
+ return pfnglXGetProcAddressARB ((GLubyte*)symbol);
+ */
+ return NULL;
+}
+
+bool Sys_GLOpenLibrary (const char* libname)
+{
+ if (libname)
+ {
+ gl_image = load_add_on (libname);
+ if (gl_image <= 0)
+ printf ("Error loading OpenGL library %s\n", libname);
+ }
+
+ if (gl_image <= 0)
+ {
+ libname = "/beos/beos/system/lib/libGL.so";
+ gl_image = load_add_on (libname);
+ if (gl_image <= 0)
+ printf ("Error loading OpenGL library %s\n", libname);
+ }
+
+ if (gl_image <= 0)
+ return false;
+
+// pfnglXChooseVisual = (PFNGLXCHOOSEVISUAL) Sys_GLGetProc ("glXChooseVisual");
+
+ return true;
+}
+
+void Sys_GLCloseLibrary ()
+{
+ if (gl_image <= 0)
+ {
+ unload_add_on (gl_image);
+ gl_image = (image_id)NULL;
+ }
+
+ // pfnglXChooseVisual = NULL;
+}
diff --git a/beos/beos_gl.h b/beos/beos_gl.h
new file mode 100644
index 0000000..a826512
--- /dev/null
+++ b/beos/beos_gl.h
@@ -0,0 +1,5 @@
+#ifndef _BEOS_GL_H_
+#define _BEOS_GL_H_
+
+
+#endif // _BEOS_GL_H_ \ No newline at end of file
diff --git a/beos/main.cpp b/beos/main.cpp
new file mode 100644
index 0000000..401d4e6
--- /dev/null
+++ b/beos/main.cpp
@@ -0,0 +1,142 @@
+//
+// LeoCAD for BeOS
+//
+
+#include <stdlib.h>
+#include <be/kernel/OS.h>
+#include "opengl.h"
+#include "project.h"
+#include "globals.h"
+
+// Flag to tell whether or not the Be application is active or not
+int BeAppActive = 0;
+static thread_id AppThread = 0;
+
+static int32 RunThread (void *data)
+{
+ SDL_RunThread (data);
+ return 0;
+}
+
+// Initialize the Be Application, if it's not already started
+int InitBeApp ()
+{
+ // Create the BApplication that handles appserver interaction
+ if (BeAppActive <= 0)
+ {
+ // Create the thread and go!
+ AppThread = spawn_thread (RunThread, "LeoCAD", B_NORMAL_PRIORITY, NULL);
+ if ((AppThread == B_NO_MORE_THREADS) ||
+ (AppThread == B_NO_MEMORY))
+ {
+ printf ("Not enough resources to create thread\n");
+ return -1;
+ }
+ resume_thread (AppThread);
+
+ do
+ {
+ snooze (10);
+ } while ((be_app == NULL) || be_app->IsLaunching ());
+
+ // Mark the application active
+ BeAppActive = 0;
+ }
+
+ // Increment the application reference count
+ BeAppActive++;
+
+ // The app is running, and we're ready to go
+ return 0;
+}
+
+// Quit the Be Application, if there's nothing left to do
+void QuitBeApp ()
+{
+ // Decrement the application reference count
+ BeAppActive--;
+
+ // If the reference count reached zero, clean up the app
+ if (BeAppActive == 0)
+ {
+ if (AppThread != 0)
+ {
+ if (be_app != NULL)
+ {
+ // Not tested
+ be_app->PostMessage(B_QUIT_REQUESTED);
+ }
+
+ status_t the_status;
+ wait_for_thread (AppThread, &the_status);
+ AppThread = 0;
+ }
+ // be_app should now be NULL since be_app has quit
+ }
+}
+
+int main (int argc, char** argv)
+{
+ char* libgl = NULL;
+ int i, j, k;
+
+ // Parse and remove system arguments
+ for (i = 1; i < argc; i++)
+ {
+ char* param = argv[i];
+
+ if (param[0] == '-' && param[1] == '-')
+ {
+ param += 2;
+
+ if ((strcmp (param, "libgl") == 0) && (i != argc))
+ {
+ libgl = argv[i+1];
+ argv[i] = argv[i+1] = NULL;
+ i++;
+ }
+ }
+ }
+
+ for (i = 1; i < argc; i++)
+ {
+ for (k = i; k < argc; k++)
+ if (argv[k] != NULL)
+ break;
+
+ if (k > i)
+ {
+ k -= i;
+ for (j = i + k; j < argc; j++)
+ argv[j-k] = argv[j];
+ argc -= k;
+ }
+ }
+
+ if (!GL_Initialize (libgl))
+ return 1;
+
+
+
+
+
+
+ project = new Project();
+
+ char* path;
+ path = getenv("LEOCAD_LIB");
+ if (path == NULL)
+ path = "/boot/home/leocad/";
+
+ if (project->Initialize(argc, argv, path) == false)
+ {
+ delete project;
+ GL_Shutdown ();
+ return 1;
+ }
+
+ delete project;
+ GL_Shutdown ();
+
+ return 0;
+} \ No newline at end of file
diff --git a/beos/system.cpp b/beos/system.cpp
new file mode 100644
index 0000000..a79fa76
--- /dev/null
+++ b/beos/system.cpp
@@ -0,0 +1,269 @@
+/*
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <gdk/gdkx.h>
+#include <gtk/gtk.h>
+#include "opengl.h"
+#include "gdkgl.h"
+#include "gtkglarea.h"
+#include "gtkmisc.h"
+#include "project.h"
+#include "system.h"
+#include "main.h"
+#include "toolbar.h"
+#include "dialogs.h"
+#include "globals.h"
+*/
+#include "file.h"
+#include "camera.h"
+#include "defines.h"
+
+// =============================================================================
+// Cursor functions
+
+/*
+void Sys_BeginWait ()
+{
+ GdkCursor *cursor = gdk_cursor_new (GDK_WATCH);
+ gdk_window_set_cursor (g_pParentWnd->m_pWidget->window, cursor);
+ gdk_cursor_destroy (cursor);
+}
+
+void Sys_EndWait ()
+{
+ GdkCursor *cursor = gdk_cursor_new (GDK_LEFT_PTR);
+ gdk_window_set_cursor (g_pParentWnd->m_pWidget->window, cursor);
+ gdk_cursor_destroy (cursor);
+}
+
+void Sys_GetCursorPos (int *x, int *y)
+{
+ gdk_window_get_pointer (NULL, x, y, NULL);
+}
+
+void Sys_SetCursorPos (int x, int y)
+{
+ XWarpPointer (GDK_DISPLAY(), None, GDK_ROOT_WINDOW(), 0, 0, 0, 0, x, y);
+}
+*/
+
+// =============================================================================
+// Message Boxes
+
+int Sys_MessageBox (const char* text, const char* caption, int type)
+{
+ return 0;
+}
+
+// =============================================================================
+// Memory rendering
+
+typedef struct
+{
+ int width, height;
+} LC_RENDER;
+
+void* Sys_StartMemoryRender(int width, int height)
+{
+ return NULL;
+}
+
+void Sys_FinishMemoryRender(void* param)
+{
+}
+
+// Profile functions
+bool Sys_ProfileSaveInt (const char *section, const char *key, int value)
+{
+ return false;
+}
+
+bool Sys_ProfileSaveString (const char *section, const char *key, const char *value)
+{
+ return false;
+}
+
+int Sys_ProfileLoadInt (const char *section, const char *key, int default_value)
+{
+ return default_value;
+}
+
+char* Sys_ProfileLoadString (const char *section, const char *key, const char *default_value)
+{
+ static char tmp[1024];
+ strcpy (tmp, default_value);
+ return tmp;
+}
+
+
+
+
+
+
+// String
+char* strupr(char* string)
+{
+ char *cp;
+ for (cp=string; *cp; ++cp)
+ {
+ if ('a' <= *cp && *cp <= 'z')
+ *cp += 'A' - 'a';
+ }
+
+ return string;
+}
+
+char* strlwr(char* string)
+{
+ char *cp;
+ for (cp = string; *cp; ++cp)
+ {
+ if ('A' <= *cp && *cp <= 'Z')
+ *cp += 'a' - 'A';
+ }
+
+ return string;
+}
+
+
+
+
+
+void SystemPumpMessages()
+{
+}
+
+long SystemGetTicks()
+{
+ return 0;//GetTickCount();
+}
+
+// User Interface
+void SystemUpdateViewport(int new_vp, int old_vp)
+{
+}
+
+void SystemUpdateAction(int new_action, int old_action)
+{
+}
+
+void SystemSetGroup(int new_group)
+{
+}
+
+void SystemUpdateColorList(int new_color)
+{
+}
+
+void SystemUpdateRenderingMode(bool bBackground, bool bFast)
+{
+}
+
+void SystemUpdateUndoRedo(char* undo, char* redo)
+{
+}
+
+void SystemUpdateSnap(const unsigned long snap)
+{
+}
+
+void SystemUpdateCurrentCamera(Camera* pOld, Camera* pNew, Camera* pCamera)
+{
+}
+
+void SystemUpdateCameraMenu(Camera* pCamera)
+{
+}
+
+void SystemUpdateTime(bool bAnimation, int nTime, int nTotal)
+{
+}
+
+void SystemUpdateAnimation(bool bAnimation, bool bAddKeys)
+{
+}
+
+void SystemUpdateMoveSnap(unsigned short move_snap)
+{
+}
+
+void SystemUpdateSelected(unsigned long flags)
+{
+}
+
+void SystemUpdateRecentMenu(char names[4][LC_MAXPATH])
+{
+}
+
+void SystemUpdatePaste(bool enable)
+{
+}
+
+void SystemUpdatePlay(bool play, bool stop)
+{
+}
+
+void SystemUpdateFocus(void* object, unsigned char type)
+{
+}
+
+void SystemInit()
+{
+}
+
+void SystemFinish()
+{
+}
+
+int SystemDoMessageBox(char* prompt, int mode)
+{
+ return 0;
+}
+
+bool SystemDoDialog(int mode, void* param)
+{
+ return false;
+}
+
+void SystemDoPopupMenu(int nMenu, int x, int y)
+{
+}
+
+void SystemDoWaitCursor(int code)
+{
+}
+
+void SystemExportClipboard(File* clip)
+{
+}
+
+File* SystemImportClipboard()
+{
+ return NULL;
+}
+
+void SystemSetWindowCaption(char* caption)
+{
+}
+
+void SystemRedrawView()
+{
+}
+
+void SystemPieceComboAdd(char* name)
+{
+}
+
+
+void SystemCaptureMouse()
+{
+}
+
+void SystemReleaseMouse()
+{
+}
+
+void SystemSwapBuffers()
+{
+}