Skip to content

Commit

Permalink
Merge branch 'haiku' into 'master'
Browse files Browse the repository at this point in the history
Haiku Support

See merge request glvnd/libglvnd!279
  • Loading branch information
kbrenneman committed Apr 4, 2023
2 parents 056feac + 37c244b commit 65c23a8
Show file tree
Hide file tree
Showing 17 changed files with 1,004 additions and 9 deletions.
5 changes: 4 additions & 1 deletion bin/symbols-check.py
Expand Up @@ -52,8 +52,11 @@
'_fbss',
'_fdata',
'_ftext',
'_gSharedObjectHaikuABI',
'_gSharedObjectHaikuVersion',
]


def get_symbols_nm(nm, lib):
'''
List all the (non platform-specific) symbols exported by the library
Expand All @@ -68,7 +71,7 @@ def get_symbols_nm(nm, lib):
if len(fields) == 2 or fields[1] == 'U':
continue
symbol_name = fields[0]
if platform_name == 'Linux' or platform_name == 'GNU' or platform_name.startswith('GNU/'):
if platform_name in ['Linux', 'GNU', 'Haiku'] or platform_name.startswith('GNU/'):
if symbol_name in PLATFORM_SYMBOLS:
continue
elif platform_name == 'Darwin':
Expand Down
10 changes: 10 additions & 0 deletions include/HGL/OpenGLKit.h
@@ -0,0 +1,10 @@
/*
* Master include file for the Haiku OpenGL Kit.
*/

#include <GL/gl.h>
#include <GLView.h>

// Projects needing GL/glu.h and GL/glut.h should now
// include these headers independently as glu and glut
// are no longer core parts of mesa
21 changes: 21 additions & 0 deletions include/HGL/README
@@ -0,0 +1,21 @@
These headers make up the Haiku OpenGL kit.

Headers in this directory preserve some BeOS™ compatibility
compatibility, so changes should be mentioned to the Haiku
project mailing list.

Haiku Website: http://haiku-os.org
BeOS OpenGL API Docs: https://www.haiku-os.org/legacy-docs/bebook/TheOpenGLKit_Overview.html

Normal Haiku OpenGL layout:

* headers/os/OpenGLKit.h
* headers/os/opengl/GLView.h
* headers/os/opengl/GL/gl.h
* headers/os/opengl/GL/glext.h
* headers/os/opengl/GL/osmesa.h (needed?)

Extras:

* headers/os/opengl/GL/glu.h
* headers/os/opengl/GL/glut.h
196 changes: 196 additions & 0 deletions include/HGL/opengl/GLView.h
@@ -0,0 +1,196 @@
/*
* Copyright 2008-2023, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*
* This header defines BGLView, the base class making up
* the Haiku OpenGL Kit.
*
*/
#ifndef BGLVIEW_H
#define BGLVIEW_H


#include <GL/gl.h>

#define BGL_RGB 0
#define BGL_INDEX 1
#define BGL_SINGLE 0
#define BGL_DOUBLE 2
#define BGL_DIRECT 0
#define BGL_INDIRECT 4
#define BGL_ACCUM 8
#define BGL_ALPHA 16
#define BGL_DEPTH 32
#define BGL_OVERLAY 64
#define BGL_UNDERLAY 128
#define BGL_STENCIL 512
#define BGL_SHARE_CONTEXT 1024


#ifdef __cplusplus

#include <AppKit.h>
#include <Bitmap.h>
#include <DirectWindow.h>
#include <View.h>
#include <Window.h>
#include <WindowScreen.h>


struct glview_direct_info;

class _EXPORT BGLView : public BView {
public:
BGLView(BRect rect, const char* name,
ulong resizingMode, ulong mode,
ulong options);
virtual ~BGLView();

void LockGL();
void UnlockGL();
void SwapBuffers();
void SwapBuffers(bool vSync);

BView* EmbeddedView();
void* GetGLProcAddress(const char* procName);

status_t CopyPixelsOut(BPoint source, BBitmap *dest);
status_t CopyPixelsIn(BBitmap *source, BPoint dest);

// Mesa's GLenum is uint where Be's ones was ulong!
virtual void ErrorCallback(unsigned long errorCode);

virtual void Draw(BRect updateRect);
virtual void AttachedToWindow();
virtual void AllAttached();
virtual void DetachedFromWindow();
virtual void AllDetached();

virtual void FrameResized(float newWidth, float newHeight);
virtual status_t Perform(perform_code d, void *arg);

virtual status_t Archive(BMessage *data, bool deep = true) const;

virtual void MessageReceived(BMessage *message);
virtual void SetResizingMode(uint32 mode);

virtual void Show();
virtual void Hide();

virtual BHandler* ResolveSpecifier(BMessage *msg, int32 index,
BMessage *specifier, int32 form,
const char *property);
virtual status_t GetSupportedSuites(BMessage *data);

void DirectConnected(direct_buffer_info *info);
void EnableDirectMode(bool enabled);

void* getGC() { return fGc; }

virtual void GetPreferredSize(float* width, float* height);

private:
class Display;
struct Renderer;

virtual void _ReservedGLView1();
virtual void _ReservedGLView2();
virtual void _ReservedGLView3();
virtual void _ReservedGLView4();
virtual void _ReservedGLView5();
virtual void _ReservedGLView6();
virtual void _ReservedGLView7();
virtual void _ReservedGLView8();

BGLView(const BGLView &);
BGLView &operator=(const BGLView &);

static Display sDisplay;

void _DitherFront();
bool _ConfirmDither();
void _Draw(BRect rect);
void _CallDirectConnected();

void* fGc;
uint32 fOptions;
uint32 fUnused1;
BLocker fDrawLock;
BLocker fDisplayLock;
glview_direct_info* fClipInfo;

Renderer* fRenderer;
void* fUnused2;
void* fUnused3;
BRect fUnused4;
void* fUnused5[2];
uint64 _reserved[8];

void _LockDraw();
void _UnlockDraw();

// BeOS compatibility
private:
BGLView(BRect rect, char* name,
ulong resizingMode, ulong mode,
ulong options);
};


class BGLScreen : public BWindowScreen {
public:
BGLScreen(char* name,
ulong screenMode, ulong options,
status_t *error, bool debug=false);
~BGLScreen();

void LockGL();
void UnlockGL();
void SwapBuffers();
// Mesa's GLenum is uint where Be's ones was ulong!
virtual void ErrorCallback(unsigned long errorCode);

virtual void ScreenConnected(bool connected);
virtual void FrameResized(float width, float height);
virtual status_t Perform(perform_code code, void *arg);

virtual status_t Archive(BMessage *data, bool deep = true) const;
virtual void MessageReceived(BMessage *message);

virtual void Show();
virtual void Hide();

virtual BHandler* ResolveSpecifier(BMessage *message,
int32 index,
BMessage *specifier,
int32 form,
const char *property);
virtual status_t GetSupportedSuites(BMessage *data);

private:

virtual void _ReservedGLScreen1();
virtual void _ReservedGLScreen2();
virtual void _ReservedGLScreen3();
virtual void _ReservedGLScreen4();
virtual void _ReservedGLScreen5();
virtual void _ReservedGLScreen6();
virtual void _ReservedGLScreen7();
virtual void _ReservedGLScreen8();

BGLScreen(const BGLScreen &);
BGLScreen &operator=(const BGLScreen &);

void* fGc;
long fOptions;
BLocker fDrawLock;

int32 fColorSpace;
uint32 fScreenMode;

uint64 _reserved[7];
};

#endif // __cplusplus

#endif // BGLVIEW_H
6 changes: 5 additions & 1 deletion include/Makefile.am
Expand Up @@ -44,6 +44,10 @@ EGL_HEADER_FILES = \
EGL/eglext.h \
EGL/eglplatform.h

HGL_HEADER_FILES = \
HGL/OpenGLKit.h \
HGL/opengl/GLView.h

if ENABLE_GL_HEADERS
nobase_include_HEADERS += $(GL_HEADER_FILES)
else
Expand Down Expand Up @@ -76,4 +80,4 @@ else
noinst_HEADERS += $(EGL_HEADER_FILES)
endif

EXTRA_DIST = meson.build
EXTRA_DIST = meson.build $(HGL_HEADER_FILES)
13 changes: 12 additions & 1 deletion include/meson.build
Expand Up @@ -22,6 +22,7 @@
# MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.

inc_include = include_directories('.')
inc_include_hgl = include_directories('HGL/opengl')

install_headers(
'glvnd/GLdispatchABI.h',
Expand Down Expand Up @@ -54,6 +55,17 @@ if with_glx and _headers
)
endif

if with_hgl and _headers
install_headers(
'HGL/opengl/GLView.h',
subdir : 'opengl',
)
install_headers(
'HGL/OpenGLKit.h',
subdir : '',
)
endif

if get_option('gles1') and _headers
install_headers(
'GLES/egl.h',
Expand Down Expand Up @@ -89,4 +101,3 @@ if get_option('egl') and _headers
subdir : 'EGL',
)
endif

6 changes: 6 additions & 0 deletions meson.build
Expand Up @@ -110,6 +110,12 @@ elif not get_option('glx').disabled() and dep_x11.found()
with_glx = true
endif

with_hgl = false
if get_option('hgl') and host_machine.system() in ['haiku']
add_languages('cpp')
with_hgl = true
endif

if cc.compiles('typeof(int *);', name : 'typeof')
add_project_arguments('-DHAVE_TYPEOF', language : ['c'])
endif
Expand Down
6 changes: 6 additions & 0 deletions meson_options.txt
Expand Up @@ -42,6 +42,12 @@ option(
type : 'feature',
description : 'Support the GLX platform.'
)
option(
'hgl',
type : 'boolean',
value : true,
description : 'Support the Haiku GL platform.'
)
option(
'gles1',
type : 'boolean',
Expand Down
19 changes: 16 additions & 3 deletions src/EGL/meson.build
Expand Up @@ -29,6 +29,21 @@ libegl_dispatch_stubs = static_library(
gnu_symbol_visibility : 'hidden',
)

if host_machine.system() in ['haiku']
# A booted Haiku system has a rigid directory structure.
# non-packaged prefixes are like local where the user can modify the contents.
# Anything missing "non-packaged" is read-only and populated by our software packages.
# Anything in system is system installed software, anything in home is user installed
egl_vendor_config_dirs = '/boot/home/config/non-packaged/add-ons/opengl/egl_vendor.d'
egl_vendor_config_dirs += ':/boot/home/config/add-ons/opengl/egl_vendor.d'
egl_vendor_config_dirs += ':/boot/system/non-packaged/add-ons/opengl/egl_vendor.d'
egl_vendor_config_dirs += ':/boot/system/add-ons/opengl/egl_vendor.d'
else
egl_vendor_config_dirs = '@0@/glvnd/egl_vendor.d:@1@/glvnd/egl_vendor.d'.format(
join_paths(get_option('prefix'),get_option('sysconfdir')),
join_paths(get_option('prefix'),get_option('datadir')))
endif

libEGL = shared_library(
'EGL',
[
Expand All @@ -39,9 +54,7 @@ libEGL = shared_library(
'libeglerror.c',
],
c_args : [
'-DDEFAULT_EGL_VENDOR_CONFIG_DIRS="@0@/glvnd/egl_vendor.d:@1@/glvnd/egl_vendor.d"'.format(
join_paths(get_option('prefix'), get_option('sysconfdir')),
join_paths(get_option('prefix'), get_option('datadir'))),
'-DDEFAULT_EGL_VENDOR_CONFIG_DIRS="@0@"'.format(egl_vendor_config_dirs)
],
include_directories : inc_include,
link_args : '-Wl,-Bsymbolic',
Expand Down
2 changes: 2 additions & 0 deletions src/HGL/.gitignore
@@ -0,0 +1,2 @@
g_glapi_mapi_gl_tmp.h
g_libglglxwrapper.c
17 changes: 17 additions & 0 deletions src/HGL/BitmapHook.h
@@ -0,0 +1,17 @@
/*
* Copyright 2022-2023, Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*/

#pragma once

#include <stdint.h>

class BBitmap;

class BitmapHook {
public:
virtual ~BitmapHook() {};
virtual void GetSize(uint32_t &width, uint32_t &height) = 0;
virtual BBitmap *SetBitmap(BBitmap *bmp) = 0;
};

0 comments on commit 65c23a8

Please sign in to comment.