1ca86eba8Smrg/* 2ca86eba8Smrg * Copyright 2018 Emmanuele Bassi 3ca86eba8Smrg * 4ca86eba8Smrg * Permission is hereby granted, free of charge, to any person obtaining a 5ca86eba8Smrg * copy of this software and associated documentation files (the "Software"), 6ca86eba8Smrg * to deal in the Software without restriction, including without limitation 7ca86eba8Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8ca86eba8Smrg * and/or sell copies of the Software, and to permit persons to whom the 9ca86eba8Smrg * Software is furnished to do so, subject to the following conditions: 10ca86eba8Smrg * 11ca86eba8Smrg * The above copyright notice and this permission notice (including the next 12ca86eba8Smrg * paragraph) shall be included in all copies or substantial portions of the 13ca86eba8Smrg * Software. 14ca86eba8Smrg * 15ca86eba8Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16ca86eba8Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17ca86eba8Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18ca86eba8Smrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19ca86eba8Smrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20ca86eba8Smrg * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21ca86eba8Smrg * IN THE SOFTWARE. 22ca86eba8Smrg */ 23ca86eba8Smrg 24ca86eba8Smrg/** 25ca86eba8Smrg * @file cgl_epoxy_api.c 26ca86eba8Smrg * 27ca86eba8Smrg * Tests the Epoxy API using the CoreGraphics OpenGL framework. 28ca86eba8Smrg */ 29ca86eba8Smrg 30ca86eba8Smrg#include <epoxy/gl.h> 31ca86eba8Smrg#include <Carbon/Carbon.h> 32ca86eba8Smrg#include <OpenGL/OpenGL.h> 33ca86eba8Smrg#include <OpenGL/CGLTypes.h> 34ca86eba8Smrg#include <OpenGL/CGLCurrent.h> 35ca86eba8Smrg#include <OpenGL/CGLContext.h> 36ca86eba8Smrg 37ca86eba8Smrgint 38ca86eba8Smrgmain (void) 39ca86eba8Smrg{ 40ca86eba8Smrg CGLPixelFormatAttribute attribs[] = {0}; 41ca86eba8Smrg CGLPixelFormatObj pix; 42ca86eba8Smrg CGLContextObj ctx; 43ca86eba8Smrg const char *string; 44ca86eba8Smrg bool pass = true; 45ca86eba8Smrg int npix; 46ca86eba8Smrg GLint shader; 47ca86eba8Smrg 48ca86eba8Smrg CGLChoosePixelFormat(attribs, &pix, &npix); 49ca86eba8Smrg CGLCreateContext(pix, (void *) 0, &ctx); 50ca86eba8Smrg CGLSetCurrentContext(ctx); 51ca86eba8Smrg 52ca86eba8Smrg if (!epoxy_is_desktop_gl()) { 53ca86eba8Smrg fputs("Claimed not to be desktop\n", stderr); 54ca86eba8Smrg pass = false; 55ca86eba8Smrg } 56ca86eba8Smrg 57ca86eba8Smrg if (epoxy_gl_version() < 20) { 58ca86eba8Smrg fprintf(stderr, "Claimed to be GL version %d\n", 59ca86eba8Smrg epoxy_gl_version()); 60ca86eba8Smrg pass = false; 61ca86eba8Smrg } 62ca86eba8Smrg 63ca86eba8Smrg if (epoxy_glsl_version() < 100) { 64ca86eba8Smrg fprintf(stderr, "Claimed to have GLSL version %d\n", 65ca86eba8Smrg epoxy_glsl_version()); 66ca86eba8Smrg pass = false; 67ca86eba8Smrg } 68ca86eba8Smrg 69ca86eba8Smrg string = (const char *)glGetString(GL_VERSION); 70ca86eba8Smrg printf("GL version: %s - Epoxy: %d\n", string, epoxy_gl_version()); 71ca86eba8Smrg 72ca86eba8Smrg string = (const char *)glGetString(GL_SHADING_LANGUAGE_VERSION); 73ca86eba8Smrg printf("GLSL version: %s - Epoxy: %d\n", string, epoxy_glsl_version()); 74ca86eba8Smrg 75ca86eba8Smrg shader = glCreateShader(GL_FRAGMENT_SHADER); 76ca86eba8Smrg pass = glIsShader(shader); 77ca86eba8Smrg 78ca86eba8Smrg CGLSetCurrentContext(NULL); 79ca86eba8Smrg CGLReleaseContext(ctx); 80ca86eba8Smrg CGLReleasePixelFormat(pix); 81ca86eba8Smrg 82ca86eba8Smrg return pass != true; 83ca86eba8Smrg} 84