]> Pileus Git - grits/blob - examples/info/info.c
Add depth buffer bits to info example
[grits] / examples / info / info.c
1 /*
2  * Copyright (C) 2009-2010 Andy Spencer <andy753421@gmail.com>
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  */
17
18 #include <stdio.h>
19 #include <string.h>
20 #include <GL/gl.h>
21 #include <GL/glu.h>
22 #include <GL/glut.h>
23
24 #define COUNT(arr) (sizeof(arr)/sizeof(arr[0]))
25
26 int main(int argc, char **argv)
27 {
28         glutInit(&argc, argv);
29         glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
30         glutInitWindowSize(250,250);
31         glutInitWindowPosition(100,100);
32         glutCreateWindow("Hello World!");
33
34
35         /* Query max size */
36         GLint size, bits;
37         glGetIntegerv(GL_MAX_TEXTURE_SIZE, &size);
38         glGetIntegerv(GL_DEPTH_BITS, &bits);
39         printf("\nGL_MAX_TEXTURE_SIZE = %d\n", size);
40         printf("\nGL_DEPTH_BITS = %d\n", bits);
41
42
43         /* Test extensions */
44         const char *exts[] = {
45                 "GL_ARB_texture_rectangle",
46                 "GL_ARB_texture_non_power_of_two",
47                 "GL_ARB_does_not_exist",
48         };
49         printf("\nChecking some extensions...\n");
50         const char *avail  = (char*)glGetString(GL_EXTENSIONS);
51         for (int i = 0; i < COUNT(exts); i++)
52                 printf("\t%s: %s\n", exts[i],
53                         strstr(avail,exts[i]) ? "OK" : "Error");
54
55
56         /* Test sample image */
57         GLint sizes[][2] = {
58                 { 120,   40},
59                 { 120,  120},
60                 { 128,   32},
61                 { 128,   64},
62                 { 128,  128},
63                 {3400, 1600},
64                 {1024, 1024},
65                 {4096, 4096},
66                 {8192, 8192},
67         };
68         printf("\nTrying some sizes...\n");
69         for (int i = 0; i < COUNT(sizes); i++) {
70                 GLint width  = sizes[i][0];
71                 GLint height = sizes[i][1];
72                 printf("\t%dx%d: ", width, height);
73                 glTexImage2D(GL_PROXY_TEXTURE_2D, 0, 4, width, height, 0,
74                                 GL_RGBA, GL_UNSIGNED_BYTE, NULL);
75                 glGetTexLevelParameteriv(GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_WIDTH,  &width);
76                 glGetTexLevelParameteriv(GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &height);
77                 printf("%s\n", width && height ? "OK" : "Error");
78         }
79
80
81         /* Wait */
82         printf("\nPress any key to exit..\n");
83         getchar();
84 }