• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Cross-Platform OpenGL Windowing Library


Commit MetaInfo

Révision8d3413fedb7a5eb55898802e9342d7a06806388d (tree)
l'heure2018-08-29 08:51:57
AuteurAlaskanEmily <emily@alas...>
CommiterAlaskanEmily

Message de Log

Add the very beginnings of Haiku support

Change Summary

Modification

--- a/GNUmakefile
+++ b/GNUmakefile
@@ -1,6 +1,32 @@
11 # Any copyright is dedicated to the Public Domain.
22 # http://creativecommons.org/publicdomain/zero/1.0/
33
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+
428 all: libglow.so libglow.a
529
630 include gcc.mk
31+
32+endif
--- a/glow.h
+++ b/glow.h
@@ -12,7 +12,7 @@
1212 extern "C" {
1313 #endif
1414
15-#ifdef __GNUC__
15+#if defined __GNUC__ && __GNUC__ >= 4
1616 #define GLOW_CONST __attribute__((const))
1717 #define GLOW_PURE __attribute__((pure))
1818 #define GLOW_RETURNS_NOT_NULL __attribute__((returns_nonnull))
@@ -109,7 +109,7 @@ GLOW_EXPORT void Glow_ViewportSize(unsigned w, unsigned h,
109109 * @brief Gets the underlying OS window for this GLow Window.
110110 *
111111 * 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)
113113 * On X11, the Window is returned.
114114 * On Cocoa, Something happens (TODO!)
115115 * On SDL2, the system's window is passed back.
@@ -128,7 +128,7 @@ GLOW_EXPORT GLOW_CONST unsigned Glow_WindowStructSize(void);
128128 * @brief Creates a Window
129129 *
130130 * The window is hidden by default.
131- *
131+ *
132132 * @sa Glow_ShowWindow
133133 */
134134 GLOW_EXPORT void Glow_CreateWindow(struct Glow_Window *out,
@@ -250,7 +250,7 @@ GLOW_EXPORT void Glow_MakeCurrent(struct Glow_Context *ctx);
250250 * @warning Unlike all the other calls for Glow, this one uses malloc to
251251 * allocate memory. You must call Glow_DestroyWindow and then free on the
252252 * returned Window to properly free the memory.
253- *
253+ *
254254 * @sa Glow_CreateLegacyContext
255255 * @sa Glow_CreateWindow
256256 */
--- /dev/null
+++ b/glow_haiku.cpp
@@ -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+}