mirror of
https://github.com/gwm17/glfw.git
synced 2024-11-27 04:28:52 -05:00
Set up the Mir connection.
Set up the first of the Mir surface.
This commit is contained in:
parent
46c9663ed7
commit
4295b77582
|
@ -6,11 +6,26 @@
|
|||
|
||||
int _glfwPlatformInit(void)
|
||||
{
|
||||
return 0;
|
||||
_glfw.mir.connection = mir_connect_sync(NULL, __PRETTY_FUNCTION__);
|
||||
|
||||
if (!mir_connection_is_valid(_glfw.mir.connection))
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Mir: Unable to connect to Server\n");
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
_glfw.mir.native_display = mir_connection_get_egl_native_display(_glfw.mir.connection);
|
||||
|
||||
// TODO Add in bits to get the correct monitors and screen sizes...
|
||||
// Ill just hard code in my own right now to jump ahead to surface and events.
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
void _glfwPlatformTerminate(void)
|
||||
{
|
||||
mir_connection_release(_glfw.mir.connection);
|
||||
}
|
||||
|
||||
const char* _glfwPlatformGetVersionString(void)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "internal.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////// GLFW platform API //////
|
||||
|
@ -8,7 +9,10 @@
|
|||
|
||||
_GLFWmonitor** _glfwPlatformGetMonitors(int* count)
|
||||
{
|
||||
return NULL;
|
||||
// FIXME Work out the best way to get this from mir, as we'll end up looping
|
||||
// through all of that info... best to store it before we get here.
|
||||
_GLFWmonitor** monitors = calloc(1, sizeof(_GLFWmonitor*));
|
||||
return monitors;
|
||||
}
|
||||
|
||||
GLboolean _glfwPlatformIsSameMonitor(_GLFWmonitor* first, _GLFWmonitor* second)
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
#error "The Mir backend depends on EGL platform support"
|
||||
#endif
|
||||
|
||||
#define _GLFW_EGL_NATIVE_WINDOW NULL
|
||||
#define _GLFW_EGL_NATIVE_DISPLAY NULL
|
||||
#define _GLFW_EGL_NATIVE_WINDOW window->mir.native_window
|
||||
#define _GLFW_EGL_NATIVE_DISPLAY _glfw.mir.native_display
|
||||
|
||||
#define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowMir mir;
|
||||
#define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorMir mir;
|
||||
|
@ -23,6 +23,11 @@
|
|||
|
||||
typedef struct _GLFWwindowMir
|
||||
{
|
||||
MirSurface* surface;
|
||||
|
||||
EGLSurface egl_surface;
|
||||
MirEGLNativeWindowType native_window;
|
||||
|
||||
} _GLFWwindowMir;
|
||||
|
||||
typedef struct _GLFWmonitorMir
|
||||
|
@ -33,6 +38,9 @@ typedef struct _GLFWlibraryMir
|
|||
{
|
||||
MirConnection* connection;
|
||||
|
||||
MirEGLNativeDisplayType native_display;
|
||||
|
||||
|
||||
} _GLFWlibraryMir;
|
||||
|
||||
typedef struct _GLFWcursorMir
|
||||
|
|
|
@ -1,5 +1,31 @@
|
|||
#include "internal.h"
|
||||
|
||||
MirPixelFormat FindValidPixelFormat()
|
||||
{
|
||||
unsigned int pf_size = 32;
|
||||
unsigned int valid_formats;
|
||||
unsigned int f;
|
||||
|
||||
MirPixelFormat formats[pf_size];
|
||||
mir_connection_get_available_surface_formats(_glfw.mir.connection, formats,
|
||||
pf_size, &valid_formats);
|
||||
|
||||
for (f = 0; f < valid_formats; f++)
|
||||
{
|
||||
MirPixelFormat cur_pf = formats[f];
|
||||
|
||||
if (cur_pf == mir_pixel_format_abgr_8888 ||
|
||||
cur_pf == mir_pixel_format_xbgr_8888 ||
|
||||
cur_pf == mir_pixel_format_argb_8888 ||
|
||||
cur_pf == mir_pixel_format_xrgb_8888)
|
||||
{
|
||||
return cur_pf;
|
||||
}
|
||||
}
|
||||
|
||||
return mir_pixel_format_invalid;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////// GLFW platform API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
@ -9,7 +35,48 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
|
|||
const _GLFWctxconfig* ctxconfig,
|
||||
const _GLFWfbconfig* fbconfig)
|
||||
{
|
||||
return 0;
|
||||
if (!_glfwCreateContext(window, ctxconfig, fbconfig))
|
||||
return GL_FALSE;
|
||||
|
||||
MirSurfaceParameters params =
|
||||
{
|
||||
.name = "MirSurface",
|
||||
.width = 1600,
|
||||
.height = 900,
|
||||
.pixel_format = mir_pixel_format_invalid,
|
||||
.buffer_usage = mir_buffer_usage_hardware,
|
||||
.output_id = mir_display_output_id_invalid
|
||||
};
|
||||
|
||||
/* // Add the HandleInput function somewhere... to handle events from the windows
|
||||
MirEventDelegate delegate =
|
||||
{
|
||||
HandleInput,
|
||||
NULL
|
||||
};
|
||||
|
||||
mir_surface_set_event_handler(window->mir.surface, &delegate);
|
||||
*/
|
||||
|
||||
params.pixel_format = FindValidPixelFormat();
|
||||
if (params.pixel_format == mir_pixel_format_invalid)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Mir: Unable to find a correct pixel format!\n");
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
window->mir.surface = mir_connection_create_surface_sync(_glfw.mir.connection, ¶ms);
|
||||
if (!mir_surface_is_valid(window->mir.surface))
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Mir: Unable to create surface!\n");
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
window->mir.native_window = mir_surface_get_egl_native_window(window->mir.surface);
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
void _glfwPlatformDestroyWindow(_GLFWwindow* window)
|
||||
|
|
Loading…
Reference in New Issue
Block a user