Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Proof of Concept] MacOS Platform Layer #21

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions c++/palanteer.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,12 @@
// Exit function when a crash occurs, called after logging the crash in Palanteer, flushing the recording and restoring signals
// Default is a call to abort().
#ifndef PL_IMPL_CRASH_EXIT_FUNC
#ifdef __APPLE__
#define PL_IMPL_CRASH_EXIT_FUNC() abort()
#else
#define PL_IMPL_CRASH_EXIT_FUNC() quick_exit(1)
#endif
#endif

// Print error function (assertions, signals).
// On Windows, shall probably be redirected on a MessageBox
Expand Down
3 changes: 3 additions & 0 deletions server/base/bsGl.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
#ifdef __linux__
#include "bsOsGlLnx.h"
#endif
#ifdef __APPLE__
#include "bsOsGlMac.h"
#endif
#ifdef _WIN32
#include "bsOsGlWin.h"
#endif
Expand Down
11 changes: 11 additions & 0 deletions server/base/bsNetwork.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@
typedef int bsSocket_t;
#endif

// MacOS
#ifdef __APPLE__
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#define bsIsSocketValid(s) ((s)>=0)
#define bsSocketError -1
typedef int bsSocket_t;
#endif

// Windows
#ifdef _WIN32
#include <winsock2.h>
Expand Down
5 changes: 3 additions & 2 deletions server/base/bsOs.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,11 @@ class bsOsHandler {
virtual void eventChar(char16_t codepoint) = 0;
virtual void eventKeyPressed (bsKeycode keycode, bsKeyModState kms) = 0;
virtual void eventKeyReleased(bsKeycode keycode, bsKeyModState kms) = 0;
virtual void eventButtonPressed (int buttonId, int x, int y, bsKeyModState kms) = 0; // 0=left, 1=middle, 2=right
virtual void eventButtonPressed (int buttonId, int x, int y, bsKeyModState kms) = 0; // 1=left, 2=middle, 3=right
virtual void eventButtonReleased(int buttonId, int x, int y, bsKeyModState kms) = 0;
virtual void eventMouseMotion (int x, int y) = 0;
virtual void eventWheelScrolled (int x, int y, int steps, bsKeyModState kms) = 0;
virtual void eventModifiersChanged (bsKeyModState kms) = 0;
// Others
virtual bool isVisible(void) const = 0;
virtual void quit(void) = 0;
Expand Down Expand Up @@ -130,7 +131,7 @@ const char* strcasestr(const char* s, const char* sToFind);
#define bsOsFseek _fseeki64
#define bsOsFtell _ftelli64

#else // Linux case
#else // Linux/Mac case

#define PL_DIR_SEP "/"
#define PL_DIR_SEP_CHAR '/'
Expand Down
27 changes: 27 additions & 0 deletions server/base/bsOsGlMac.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// The MIT License (MIT)
//
// Copyright(c) 2021, Damien Feneyrou <dfeneyrou@gmail.com>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files(the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions :
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

#pragma once

#define GL_SILENCE_DEPRECATION
#define GL_GLEXT_PROTOTYPES 1
#include <OpenGL/gl3.h>
Loading