Cross-Platform OpenGL Windowing Library
Révision | 8d3413fedb7a5eb55898802e9342d7a06806388d (tree) |
---|---|
l'heure | 2018-08-29 08:51:57 |
Auteur | AlaskanEmily <emily@alas...> |
Commiter | AlaskanEmily |
Add the very beginnings of Haiku support
@@ -1,6 +1,32 @@ | ||
1 | 1 | # Any copyright is dedicated to the Public Domain. |
2 | 2 | # http://creativecommons.org/publicdomain/zero/1.0/ |
3 | 3 | |
4 | +UNAME=$(shell uname) | |
5 | +HAIKU=Haiku | |
6 | + | |
7 | +ifeq "$(UNAME)" "Haiku" | |
8 | + | |
9 | +all: libglow.so libglow.a | |
10 | + | |
11 | +CXXFLAGS=-fno-rtti -fno-exceptions -g -std=c++98 -Wall | |
12 | + | |
13 | +glow_haiku.os: glow_haiku.cpp glow.h | |
14 | + g++ $(CXXFLAGS) -fPIC -c glow_haiku.cpp -o glow_haiku.os | |
15 | + | |
16 | +glow_haiku.o: glow_haiku.cpp glow.h | |
17 | + g++ $(CXXFLAGS) -c glow_haiku.cpp -o glow_haiku.o | |
18 | + | |
19 | +libglow.a: glow_haiku.o | |
20 | + ar rc libglow.a glow_haiku.o | |
21 | + ranlib libglow.a | |
22 | + | |
23 | +libglow.so: glow_haiku.os | |
24 | + g++ -g -fPIC -shared glow_haiku.os -o libglow.so | |
25 | + | |
26 | +else | |
27 | + | |
4 | 28 | all: libglow.so libglow.a |
5 | 29 | |
6 | 30 | include gcc.mk |
31 | + | |
32 | +endif |
@@ -12,7 +12,7 @@ | ||
12 | 12 | extern "C" { |
13 | 13 | #endif |
14 | 14 | |
15 | -#ifdef __GNUC__ | |
15 | +#if defined __GNUC__ && __GNUC__ >= 4 | |
16 | 16 | #define GLOW_CONST __attribute__((const)) |
17 | 17 | #define GLOW_PURE __attribute__((pure)) |
18 | 18 | #define GLOW_RETURNS_NOT_NULL __attribute__((returns_nonnull)) |
@@ -109,7 +109,7 @@ GLOW_EXPORT void Glow_ViewportSize(unsigned w, unsigned h, | ||
109 | 109 | * @brief Gets the underlying OS window for this GLow Window. |
110 | 110 | * |
111 | 111 | * On Win32 this is a HWND |
112 | - * On Haiku, the BGLView is returned. | |
112 | + * On Haiku, the BGLView is returned (not a window technically, but still) | |
113 | 113 | * On X11, the Window is returned. |
114 | 114 | * On Cocoa, Something happens (TODO!) |
115 | 115 | * On SDL2, the system's window is passed back. |
@@ -128,7 +128,7 @@ GLOW_EXPORT GLOW_CONST unsigned Glow_WindowStructSize(void); | ||
128 | 128 | * @brief Creates a Window |
129 | 129 | * |
130 | 130 | * The window is hidden by default. |
131 | - * | |
131 | + * | |
132 | 132 | * @sa Glow_ShowWindow |
133 | 133 | */ |
134 | 134 | GLOW_EXPORT void Glow_CreateWindow(struct Glow_Window *out, |
@@ -250,7 +250,7 @@ GLOW_EXPORT void Glow_MakeCurrent(struct Glow_Context *ctx); | ||
250 | 250 | * @warning Unlike all the other calls for Glow, this one uses malloc to |
251 | 251 | * allocate memory. You must call Glow_DestroyWindow and then free on the |
252 | 252 | * returned Window to properly free the memory. |
253 | - * | |
253 | + * | |
254 | 254 | * @sa Glow_CreateLegacyContext |
255 | 255 | * @sa Glow_CreateWindow |
256 | 256 | */ |
@@ -0,0 +1,59 @@ | ||
1 | +// Copyright (C) 2018 Alaskan Emily, Transnat Games | |
2 | +// | |
3 | +// This Source Code Form is subject to the terms of the Mozilla Public | |
4 | +// License, v. 2.0. If a copy of the MPL was not distributed with this | |
5 | +// file, You can obtain one at http://mozilla.org/MPL/2.0/. | |
6 | + | |
7 | + | |
8 | +#include "glow.h" | |
9 | + | |
10 | +#include <interface/Window.h> | |
11 | +#include <opengl/GLView.h> | |
12 | + | |
13 | +/////////////////////////////////////////////////////////////////////////////////////////////////// | |
14 | + | |
15 | +struct Glow_Window { | |
16 | + BGLView *gl_view; | |
17 | + BWindow *b_window; | |
18 | +}; | |
19 | + | |
20 | +/////////////////////////////////////////////////////////////////////////////////////////////////// | |
21 | + | |
22 | +static const int glow_gl_view_flags = BGL_RGB|BGL_ALPHA|BGL_DEPTH|BGL_DOUBLE|BGL_ACCUM|BGL_STENCIL; | |
23 | + | |
24 | +/////////////////////////////////////////////////////////////////////////////////////////////////// | |
25 | + | |
26 | +void Glow_ViewportSize(unsigned w, unsigned h, unsigned *out_w, unsigned *out_h){ | |
27 | + out_w[0] = w; | |
28 | + out_h[0] = h; | |
29 | +} | |
30 | + | |
31 | +/////////////////////////////////////////////////////////////////////////////////////////////////// | |
32 | + | |
33 | +void *Glow_GetSystemWindow(Glow_Window *window){ | |
34 | + return window->gl_view; | |
35 | +} | |
36 | + | |
37 | +/////////////////////////////////////////////////////////////////////////////////////////////////// | |
38 | + | |
39 | +unsigned Glow_WindowStructSize(){ | |
40 | + return sizeof(Glow_Window); | |
41 | +} | |
42 | + | |
43 | +/////////////////////////////////////////////////////////////////////////////////////////////////// | |
44 | + | |
45 | +void Glow_CreateWindow(Glow_Window *out, unsigned w, unsigned h, const char *title, int flags){ | |
46 | + const BRect rect = BRect(0.0f, 0.0f, static_cast<float>(w), static_cast<float>(h)); | |
47 | + const window_look look = ((flags & GLOW_UNDECORATED) != 0) ? | |
48 | + B_NO_BORDER_WINDOW_LOOK : | |
49 | + B_DOCUMENT_WINDOW_LOOK; | |
50 | + const window_feel feel = B_NORMAL_WINDOW_FEEL; | |
51 | + const int window_flags = ((flags & GLOW_RESIZABLE) != 0) ? | |
52 | + B_NOT_RESIZABLE : 0; | |
53 | + | |
54 | + BWindow *const b_window = new BWindow(rect, title, look, feel, window_flags); | |
55 | + BGLView *const gl_view = new BGLView(rect, "Glow", B_FOLLOW_ALL_SIDES, 0, glow_gl_view_flags); | |
56 | + b_window->AddChild(gl_view); | |
57 | + out->b_window = b_window; | |
58 | + out->gl_view = gl_view; | |
59 | +} |