1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
|
/* QuesoGLC
* A free implementation of the OpenGL Character Renderer (GLC)
* Copyright (c) 2002, 2004-2007, Bertrand Coconnier
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* $Id: testcontex.c 679 2007-12-20 21:42:13Z bcoconni $ */
/** \file
* Test the GLC functions of the context group and the default state of the
* contexts.
*/
#include "GL/glc.h"
#include <stdio.h>
#if defined __APPLE__ && defined __MACH__
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif
int main(int argc, char **argv)
{
int ctx = 0;
GLCenum error = GLC_NONE;
/* Needed to initialize an OpenGL context */
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutCreateWindow("testcontex");
error = glcGetError();
if (error) {
printf("Unexpected error #0x%X\n", error);
return -1;
}
glcDisable(GLC_AUTO_FONT);
error = glcGetError();
if (error != GLC_STATE_ERROR) {
printf("GLC_STATE_ERROR expected. Error #0x%X instead\n", error);
return -1;
}
error = glcGetError();
if (error) {
printf("Error state should have been reset.\nError #0x%X instead\n",
error);
return -1;
}
ctx = glcGenContext();
glcContext(ctx);
error = glcGetError();
if (error) {
printf("Unexpected error #0x%X\n", error);
return -1;
}
if (!glcIsEnabled(GLC_AUTO_FONT)) {
printf("GLC_AUTO_FONT should be enabled by default\n");
return -1;
}
if (!glcIsEnabled(GLC_GL_OBJECTS)) {
printf("GLC_GL_OBJECTS should be enabled by default\n");
return -1;
}
if (!glcIsEnabled(GLC_MIPMAP)) {
printf("GLC_MIPMAP should be enabled by default\n");
return -1;
}
glcDisable(GLC_AUTO_FONT);
if (glcIsEnabled(GLC_AUTO_FONT)) {
printf("GLC_AUTO_FONT should be disabled now\n");
return -1;
}
if (!glcIsEnabled(GLC_GL_OBJECTS)) {
printf("GLC_GL_OBJECTS should be enabled\n");
return -1;
}
if (!glcIsEnabled(GLC_MIPMAP)) {
printf("GLC_MIPMAP should be enabled\n");
return -1;
}
glcDisable(GLC_GL_OBJECTS);
if (glcIsEnabled(GLC_AUTO_FONT)) {
printf("GLC_AUTO_FONT should be disabled now\n");
return -1;
}
if (glcIsEnabled(GLC_GL_OBJECTS)) {
printf("GLC_GL_OBJECTS should be disbled\n");
return -1;
}
if (!glcIsEnabled(GLC_MIPMAP)) {
printf("GLC_MIPMAP should be enabled\n");
return -1;
}
error = glcGetError();
if (error) {
printf("Unexpected error #0x%X\n", error);
return -1;
}
glcDisable(0);
error = glcGetError();
if (error != GLC_PARAMETER_ERROR) {
printf("GLC_PARAMETER_ERROR expected. Error #0x%X instead\n", error);
return -1;
}
printf("Tests successful!\n");
return 0;
}
|