-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
157 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
// mrv2 | ||
// Copyright Contributors to the mrv2 Project. All rights reserved. | ||
|
||
#include <FL/platform.H> | ||
|
||
#ifdef FLTK_USE_X11 | ||
# include <X11/Xlib.h> | ||
# include <GL/glx.h> | ||
#endif | ||
|
||
#ifdef FLTK_USE_WAYLAND | ||
# include <EGL/egl.h> | ||
#endif | ||
|
||
#include "mrvGL/mrvGLWindow.h" | ||
|
||
namespace | ||
{ | ||
const char* kModule = "gl"; | ||
} | ||
|
||
namespace mrv | ||
{ | ||
|
||
GLWindow::GLWindow(int X, int Y, int W, int H, const char* L) : | ||
Fl_Gl_Window(X, Y, W, H, L) | ||
{ | ||
} | ||
|
||
GLWindow::GLWindow(int W, int H, const char* L) : | ||
Fl_Gl_Window(W, H, L) | ||
{ | ||
} | ||
|
||
#ifndef __APPLE__ | ||
void GLWindow::make_current() | ||
{ | ||
GLContext ctx = this->context(); | ||
if (!ctx) | ||
return Fl_Gl_Window::make_current(); | ||
|
||
# ifdef _WIN32 | ||
HGLRC cur_hglrc = wglGetCurrentContext(); | ||
HGLRC hglrc = fl_win32_glcontext(ctx); | ||
if (hglrc == cur_hglrc) | ||
return; | ||
|
||
HWND hwnd = fl_win32_xid(this); | ||
assert(hwnd); | ||
HDC hdc = fl_GetDC(hwnd); | ||
assert(hdc); | ||
assert(hglrc); | ||
wglMakeCurrent(hdc, hglrc); | ||
# endif | ||
|
||
# ifdef __linux__ | ||
# ifdef FLTK_USE_X11 | ||
auto dpy = fl_x11_display(); | ||
if (dpy) | ||
{ | ||
auto win = fl_x11_xid(this); | ||
assert(win); | ||
glXMakeCurrent(dpy, win, (GLXContext)ctx); | ||
} | ||
# endif | ||
# ifdef FLTK_USE_WAYLAND | ||
auto wldpy = fl_wl_display(); | ||
if (wldpy) | ||
{ | ||
auto eglctx = fl_wl_glcontext(ctx); | ||
EGLContext currentContext = eglGetCurrentContext(); | ||
if (currentContext == eglctx) | ||
return; | ||
|
||
auto win = fl_wl_xid(this); | ||
assert(win); | ||
|
||
auto surface = fl_wl_surface(win); | ||
eglMakeCurrent(wldpy, surface, surface, eglctx); | ||
} | ||
# endif | ||
# endif | ||
} | ||
#endif | ||
|
||
} // namespace mrv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
// mrv2 | ||
// Copyright Contributors to the mrv2 Project. All rights reserved. | ||
|
||
#pragma once | ||
|
||
#include <FL/Fl_Gl_Window.H> | ||
|
||
namespace mrv | ||
{ | ||
|
||
// | ||
// This class implements coomon OpenGL functionality | ||
// | ||
class GLWindow : public Fl_Gl_Window | ||
{ | ||
|
||
public: | ||
GLWindow(int X, int Y, int W, int H, const char* L = 0); | ||
GLWindow(int W, int H, const char* L = 0); | ||
|
||
void make_current(); | ||
}; | ||
} // namespace mrv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
|
||
#import <Cocoa/Cocoa.h> | ||
#import <OpenGL/OpenGL.h> | ||
|
||
#include "mrvGL/mrvGLWindow.h" | ||
|
||
namespace mrv | ||
{ | ||
void GLWindow::make_current() | ||
{ | ||
[(NSOpenGLContext*)this->context() makeCurrentContext]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters