Path: blob/21.2-virgl/src/glx/apple/apple_glapi.c
4560 views
/*1* GLX implementation that uses Apple's OpenGL.framework2*3* Copyright (c) 2007-2011 Apple Inc.4* Copyright (c) 2004 Torrey T. Lyons. All Rights Reserved.5* Copyright (c) 2002 Greg Parker. All Rights Reserved.6*7* Portions of this file are copied from Mesa's xf86glx.c,8* which contains the following copyright:9*10* Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.11* All Rights Reserved.12*13* Permission is hereby granted, free of charge, to any person obtaining a14* copy of this software and associated documentation files (the "Software"),15* to deal in the Software without restriction, including without limitation16* the rights to use, copy, modify, merge, publish, distribute, sublicense,17* and/or sell copies of the Software, and to permit persons to whom the18* Software is furnished to do so, subject to the following conditions:19*20* The above copyright notice and this permission notice shall be included in21* all copies or substantial portions of the Software.22*23* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR24* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,25* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL26* THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR27* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,28* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER29* DEALINGS IN THE SOFTWARE.30*/3132#include <assert.h>33#include <dlfcn.h>34#include <stdlib.h>35#include <string.h>36#include <stdio.h>3738#include <GL/gl.h>3940#include "main/glheader.h"41#include "glapi.h"42#include "glapitable.h"4344#include "apple_glx.h"45#include "apple_xgl_api.h"46#include "apple_cgl.h"4748struct _glapi_table * __ogl_framework_api = NULL;49struct _glapi_table * __applegl_api = NULL;5051static void _apple_glapi_create_table(void) {52if (__applegl_api)53return;5455__ogl_framework_api = _glapi_create_table_from_handle(apple_cgl_get_dl_handle(), "gl");56assert(__ogl_framework_api);5758__applegl_api = malloc(sizeof(struct _glapi_table));59assert(__applegl_api);60memcpy(__applegl_api, __ogl_framework_api, sizeof(struct _glapi_table));6162_glapi_table_patch(__applegl_api, "ReadPixels", __applegl_glReadPixels);63_glapi_table_patch(__applegl_api, "CopyPixels", __applegl_glCopyPixels);64_glapi_table_patch(__applegl_api, "CopyColorTable", __applegl_glCopyColorTable);65_glapi_table_patch(__applegl_api, "DrawBuffers", __applegl_glDrawBuffer);66_glapi_table_patch(__applegl_api, "Viewport", __applegl_glViewport);67}6869void apple_glapi_set_dispatch(void) {70_apple_glapi_create_table();71_glapi_set_dispatch(__applegl_api);72}7374void apple_glapi_oglfw_viewport_scissor(GLint x, GLint y, GLsizei width, GLsizei height) {75_apple_glapi_create_table();76__ogl_framework_api->Viewport(x, y, width, height);77__ogl_framework_api->Scissor(x, y, width, height);78}798081