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
28 #include <GLES2/gl2.h>
33 * Verify that GL commands up to this point have not produced any errors.
38 GLint err = glGetError(); \
41 printf("GL error 0x%x (%d) at %s:%d\n", err, err, __FILE__, __LINE__); \
47 * Verify that EGL commands up to this point have not produced any errors.
49 #define ASSERT_EGL() \
52 EGLint err = eglGetError(); \
53 if (err != EGL_SUCCESS) \
55 printf("EGL error 0x%x (%d) at %s:%d\n", err, err, __FILE__, __LINE__); \
61 * EGL context objects available to all tests
65 EGLNativeDisplayType nativeDisplay;
67 EGLNativeWindowType win;
73 extern struct Context ctx;
76 * Indicate that a frame is complete
81 * Load a texture from a binary file
83 * @param target Texture target (usually GL_TEXTURE_2D)
84 * @param level Mipmap level
85 * @param internalFormat Internal texture format
86 * @param width Texture width in pixels
87 * @param height Texture height in pixels
88 * @param type Data type
89 * @param fileName File containing the texture data
91 * @returns true on success, false on failure
93 bool loadRawTexture(GLenum target, int level, GLenum internalFormat, int width,
94 int height, GLenum format, GLenum type, const std::string& fileName);
97 * Load a compressed texture from a binary file
99 * @param target Texture target (usually GL_TEXTURE_2D)
100 * @param internalFormat Internal texture format
101 * @param width Texture width in pixels
102 * @param height Texture height in pixels
103 * @param fileName File containing the texture data
105 * @returns true on success, false on failure
107 bool loadCompressedTexture(GLenum target, int level, GLenum internalFormat, int width,
108 int height, const std::string& fileName);
111 * Check whether an EGL extension is supported
113 * @param name Extension name
115 * @returns true if extension is supported
117 bool isEGLExtensionSupported(const std::string& name);
120 * Check whether an OpenGL ES extension is supported
122 * @param name Extension name
124 * @returns true if extension is supported
126 bool isGLExtensionSupported(const std::string& name);
129 * Compile a vertex and fragment shader and create a new program from the
132 * @param vertSrc Vertex program source
133 * @param fragSrc Fragment program source
135 * @returns new program handle
137 GLint createProgram(const std::string& vertSrc, const std::string& fragSrc);
140 * Describe a texture format and type combination
142 * @param format Texture format
143 * @param type Texture type
145 std::string textureFormatName(GLenum format, GLenum type);
148 * Print EGL config attributes on the terminal
150 * @param dpy EGL display
151 * @param config EGL config
153 void dumpConfig(EGLDisplay dpy, EGLConfig config);