From 8548095d61ba49d4d49e1478533461d22979ab2a Mon Sep 17 00:00:00 2001 From: leo Date: Sat, 19 Aug 2000 18:38:17 +0000 Subject: start of BeOS port git-svn-id: http://svn.leocad.org/trunk@99 c7d43263-9d01-0410-8a33-9dba5d9f93d6 --- beos/beos_gl.cpp | 73 +++++++++++++++ beos/beos_gl.h | 5 ++ beos/main.cpp | 142 +++++++++++++++++++++++++++++ beos/system.cpp | 269 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 489 insertions(+) create mode 100644 beos/beos_gl.cpp create mode 100644 beos/beos_gl.h create mode 100644 beos/main.cpp create mode 100644 beos/system.cpp (limited to 'beos') 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 +#include +#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 +#include +#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 +#include +#include +#include +#include +#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() +{ +} -- cgit v1.2.3