Init context API for native display.

This commit is contained in:
BrandonSchaefer 2014-11-06 00:24:08 -08:00 committed by Camilla Berglund
parent 4295b77582
commit 49696d0134
3 changed files with 47 additions and 4 deletions

View File

@ -17,9 +17,16 @@ int _glfwPlatformInit(void)
_glfw.mir.native_display = mir_connection_get_egl_native_display(_glfw.mir.connection); _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... // 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. // Ill just hard code in my own right now to jump ahead to surface and events.
if (!_glfwInitContextAPI())
return GL_FALSE;
_glfwInitTimer();
_glfwInitJoysticks();
return GL_TRUE; return GL_TRUE;
} }

View File

@ -24,6 +24,8 @@
typedef struct _GLFWwindowMir typedef struct _GLFWwindowMir
{ {
MirSurface* surface; MirSurface* surface;
int width;
int height;
EGLSurface egl_surface; EGLSurface egl_surface;
MirEGLNativeWindowType native_window; MirEGLNativeWindowType native_window;

View File

@ -38,11 +38,15 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
if (!_glfwCreateContext(window, ctxconfig, fbconfig)) if (!_glfwCreateContext(window, ctxconfig, fbconfig))
return GL_FALSE; return GL_FALSE;
// FIXME Add a check here to ensure we are within our max width/height
window->mir.width = wndconfig->width;
window->mir.height = wndconfig->height;
MirSurfaceParameters params = MirSurfaceParameters params =
{ {
.name = "MirSurface", .name = "MirSurface",
.width = 1600, .width = wndconfig->width,
.height = 900, .height = wndconfig->height,
.pixel_format = mir_pixel_format_invalid, .pixel_format = mir_pixel_format_invalid,
.buffer_usage = mir_buffer_usage_hardware, .buffer_usage = mir_buffer_usage_hardware,
.output_id = mir_display_output_id_invalid .output_id = mir_display_output_id_invalid
@ -81,26 +85,41 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
void _glfwPlatformDestroyWindow(_GLFWwindow* window) void _glfwPlatformDestroyWindow(_GLFWwindow* window)
{ {
if (mir_surface_is_valid(window->mir.surface))
{
mir_surface_release_sync(window->mir.surface);
window->mir.surface = NULL;
}
} }
void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title) void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
{ {
_glfwInputError(GLFW_PLATFORM_ERROR,
"Mir: Unsupported Function %s!\n", __PRETTY_FUNCTION__);
} }
void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos) void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos)
{ {
_glfwInputError(GLFW_PLATFORM_ERROR,
"Mir: Unsupported Function %s!\n", __PRETTY_FUNCTION__);
} }
void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height) void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
{ {
_glfwInputError(GLFW_PLATFORM_ERROR,
"Mir: Unsupported Function %s!\n", __PRETTY_FUNCTION__);
} }
void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height) void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height)
{ {
*width = window->mir.width;
*height = window->mir.height;
} }
void _glfwPlatformIconifyWindow(_GLFWwindow* window) void _glfwPlatformIconifyWindow(_GLFWwindow* window)
{ {
_glfwInputError(GLFW_PLATFORM_ERROR,
"Mir: Unsupported Function %s!\n", __PRETTY_FUNCTION__);
} }
void _glfwPlatformRestoreWindow(_GLFWwindow* window) void _glfwPlatformRestoreWindow(_GLFWwindow* window)
@ -111,6 +130,7 @@ void _glfwPlatformHideWindow(_GLFWwindow* window)
{ {
} }
// Mir does event handling in a different thread, so windows get events directly as they happen
void _glfwPlatformPollEvents(void) void _glfwPlatformPollEvents(void)
{ {
} }
@ -125,10 +145,14 @@ void _glfwPlatformPostEmptyEvent(void)
void _glfwPlatformGetFramebufferSize(_GLFWwindow* window, int* width, int* height) void _glfwPlatformGetFramebufferSize(_GLFWwindow* window, int* width, int* height)
{ {
*width = window->mir.width;
*height = window->mir.height;
} }
void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window, int* left, int* top, int* right, int* bottom) void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window, int* left, int* top, int* right, int* bottom)
{ {
_glfwInputError(GLFW_PLATFORM_ERROR,
"Mir: Unsupported Function %s!\n", __PRETTY_FUNCTION__);
} }
void _glfwPlatformShowWindow(_GLFWwindow* window) void _glfwPlatformShowWindow(_GLFWwindow* window)
@ -145,7 +169,10 @@ void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos)
int _glfwPlatformCreateCursor(_GLFWcursor* cursor, const GLFWimage* image, int xhot, int yhot) int _glfwPlatformCreateCursor(_GLFWcursor* cursor, const GLFWimage* image, int xhot, int yhot)
{ {
return 0; _glfwInputError(GLFW_PLATFORM_ERROR,
"Mir: Unsupported Function %s!\n", __PRETTY_FUNCTION__);
return 0;
} }
void _glfwPlatformDestroyCursor(_GLFWcursor* cursor) void _glfwPlatformDestroyCursor(_GLFWcursor* cursor)
@ -158,6 +185,8 @@ void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor)
void _glfwPlatformSetCursorPos(_GLFWwindow* window, double xpos, double ypos) void _glfwPlatformSetCursorPos(_GLFWwindow* window, double xpos, double ypos)
{ {
_glfwInputError(GLFW_PLATFORM_ERROR,
"Mir: Unsupported Function %s!\n", __PRETTY_FUNCTION__);
} }
void _glfwPlatformApplyCursorMode(_GLFWwindow* window) void _glfwPlatformApplyCursorMode(_GLFWwindow* window)
@ -166,9 +195,14 @@ void _glfwPlatformApplyCursorMode(_GLFWwindow* window)
void _glfwPlatformSetClipboardString(_GLFWwindow* window, const char* string) void _glfwPlatformSetClipboardString(_GLFWwindow* window, const char* string)
{ {
_glfwInputError(GLFW_PLATFORM_ERROR,
"Mir: Unsupported Function %s!\n", __PRETTY_FUNCTION__);
} }
const char* _glfwPlatformGetClipboardString(_GLFWwindow* window) const char* _glfwPlatformGetClipboardString(_GLFWwindow* window)
{ {
return NULL; _glfwInputError(GLFW_PLATFORM_ERROR,
"Mir: Unsupported Function %s!\n", __PRETTY_FUNCTION__);
return NULL;
} }