mirror of
https://github.com/glfw/glfw.git
synced 2026-09-22 08:50:15 +00:00
Set up the Mir connection.
Set up the first of the Mir surface.
This commit is contained in:
committed by
Camilla Berglund
parent
46c9663ed7
commit
4295b77582
+68
-1
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user