2 * OpenGL ES 2.0 memory performance estimator
3 * Copyright (C) 2009 Nokia
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 * \author Sami Kyöstilä <sami.kyostila@nokia.com>
21 * EGL and OpenGL ES utility functions
27 #include <GLES2/gl2.h>
32 * Verify that GL commands up to this point have not produced any errors.
37 GLint err = glGetError(); \
40 printf("GL error 0x%x (%d) at %s:%d\n", err, err, __FILE__, __LINE__); \
46 * Verify that EGL commands up to this point have not produced any errors.
48 #define ASSERT_EGL() \
51 EGLint err = eglGetError(); \
52 if (err != EGL_SUCCESS) \
54 printf("EGL error 0x%x (%d) at %s:%d\n", err, err, __FILE__, __LINE__); \
60 * EGL context objects available to all tests
64 EGLNativeDisplayType nativeDisplay;
66 EGLNativeWindowType win;
72 extern struct Context ctx;
75 * Indicate that a frame is complete
80 * Load a texture from a binary file
82 * @param target Texture target (usually GL_TEXTURE_2D)
83 * @param level Mipmap level
84 * @param internalFormat Internal texture format
85 * @param width Texture width in pixels
86 * @param height Texture height in pixels
87 * @param type Data type
88 * @param fileName File containing the texture data
90 * @returns true on success, false on failure
92 bool loadRawTexture(GLenum target, int level, GLenum internalFormat, int width,
93 int height, GLenum format, GLenum type, const std::string& fileName);
96 * Load a compressed texture from a binary file
98 * @param target Texture target (usually GL_TEXTURE_2D)
99 * @param internalFormat Internal texture format
100 * @param width Texture width in pixels
101 * @param height Texture height in pixels
102 * @param fileName File containing the texture data
104 * @returns true on success, false on failure
106 bool loadCompressedTexture(GLenum target, int level, GLenum internalFormat, int width,
107 int height, const std::string& fileName);
110 * Check whether an EGL extension is supported
112 * @param name Extension name
114 * @returns true if extension is supported
116 bool isEGLExtensionSupported(const std::string& name);
119 * Check whether an OpenGL ES extension is supported
121 * @param name Extension name
123 * @returns true if extension is supported
125 bool isGLExtensionSupported(const std::string& name);
128 * Compile a vertex and fragment shader and create a new program from the
131 * @param vertSrc Vertex program source
132 * @param fragSrc Fragment program source
134 * @returns new program handle
136 GLint createProgram(const std::string& vertSrc, const std::string& fragSrc);
139 * Describe a texture format and type combination
141 * @param format Texture format
142 * @param type Texture type
144 std::string textureFormatName(GLenum format, GLenum type);
147 * Print EGL config attributes on the terminal
149 * @param dpy EGL display
150 * @param config EGL config
152 void dumpConfig(EGLDisplay dpy, EGLConfig config);