hostsupport/hostopengles11/inc/GLESContext.h
author Matt Plumtree <matt.plumtree@nokia.com>
Wed, 06 Oct 2010 17:59:01 +0100
branchbug235_bringup_0
changeset 53 c2ef9095503a
child 67 ca7e6949bf7a
permissions -rw-r--r--
Copy code from the holdingarea into the target locations. Some initial rework of CMakeLists.txt files, but not yet tested.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
53
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
     1
/* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
     2
 *
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
     3
 * Permission is hereby granted, free of charge, to any person obtaining a
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
     4
 * copy of this software and /or associated documentation files
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
     5
 * (the "Materials "), to deal in the Materials without restriction,
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
     6
 * including without limitation the rights to use, copy, modify, merge,
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
     7
 * publish, distribute, sublicense, and/or sell copies of the Materials,
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
     8
 * and to permit persons to whom the Materials are furnished to do so,
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
     9
 * subject to the following conditions:
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    10
 *
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    11
 * The above copyright notice and this permission notice shall be included
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    12
 * in all copies or substantial portions of the Materials.
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    13
 *
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    14
 * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    15
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    16
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    17
 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    18
 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    19
 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    20
 * THE USE OR OTHER DEALINGS IN THE MATERIALS.
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    21
 *
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    22
 * Initial Contributors:
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    23
 * Nokia Corporation - initial contribution.
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    24
 *
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    25
 * Contributors:
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    26
 *
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    27
 * Description:
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    28
 *
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    29
 */
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    30
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    31
#ifndef _GLESCONTEXT_H_
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    32
#define _GLESCONTEXT_H_
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    33
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    34
#include <GLES/gl.h>
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    35
#include <map>
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    36
#include <iostream>
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    37
#include "GLESArray.h"
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    38
#include "glesInternal.h"
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    39
#include "GLESDesktopGL.h"
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    40
#include "glesOS.h"
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    41
#include "EGLInterface.h"
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    42
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    43
struct GLESBuffer;
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    44
class GLESTexture;
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    45
struct GLESTextureLevel;
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    46
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    47
namespace
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    48
{
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    49
typedef std::map<unsigned int, GLESBuffer*> BufferMap;
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    50
typedef std::map<unsigned int, GLESTexture*> TextureMap;
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    51
}
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    52
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    53
enum GLESArrayFlag
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    54
{
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    55
	GLES_INVALID_ARRAY			= 0,
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    56
	GLES_VERTEX_ARRAY			= 1 << 0,
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    57
	GLES_NORMAL_ARRAY			= 1 << 1,
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    58
	GLES_COLOR_ARRAY			= 1 << 2,
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    59
	GLES_POINT_SIZE_ARRAY		= 1 << 3,
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    60
	GLES_TEXTURE_COORD_ARRAY	= 1 << 4
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    61
};
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    62
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    63
class GLESContext {
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    64
public:
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    65
	GLESContext(void* nativeContext);
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    66
	~GLESContext();
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    67
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    68
	bool Initialize();
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    69
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    70
	bool IsInitialized() const { return m_initialized; }
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    71
	const GLESDesktopGL& DGL() const { return m_dgl; }
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    72
	void* NativeContext() const { return m_nativeContext; }
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    73
	GLenum Error() const { return m_error; }
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    74
	GLenum GetHostError();
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    75
	unsigned int MaxTextureLevel() const { return m_maxTextureLevel; }
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    76
	unsigned int MaxTextureUnits() const { return m_maxTextureUnits; }
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    77
	unsigned int MaxClipPlanes() const { return m_maxClipPlanes; }
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    78
	unsigned int MaxLights() const { return m_maxLights; }
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    79
	int ClientActiveTexture() const { return m_clientActiveTexture; }
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    80
	GLESArray& VertexArray() { return m_vertexArray; }
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    81
	const GLESArray& VertexArray() const { return m_vertexArray; }
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    82
	GLESArray& NormalArray() { return m_normalArray; }
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    83
	const GLESArray& NormalArray() const { return m_normalArray; }
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    84
	GLESArray& ColorArray() { return m_colorArray; }
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    85
	const GLESArray& ColorArray() const { return m_colorArray; }
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    86
	const GLESArray& PointSizeArray() const { return m_pointSizeArray; }
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    87
	GLESArray& TexCoordArray(unsigned int texture);
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    88
	GLESArray& TexCoordArray();
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    89
	const GLESArray& TexCoordArray(unsigned int texture) const;
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    90
	const GLESArray& TexCoordArray() const;
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    91
	unsigned int ArrayBufferBinding() const { return m_arrayBufferBinding; }
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    92
	GLESBuffer* ArrayBuffer();
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    93
	unsigned int ElementArrayBufferBinding() const { return m_elementArrayBufferBinding; }
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    94
	GLESBuffer* ElementArrayBuffer();
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    95
	const GLESBuffer* Buffer(unsigned int buffer) const;
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    96
	unsigned int TextureBinding() const { return m_textureBinding; }
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    97
	GLESTexture* Texture(unsigned int name);
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    98
	const GLESTextureLevel* TextureLevel(GLint level) const;
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
    99
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   100
	bool IsArrayEnabled(GLESArrayFlag array) const { return !!(m_enabledArrays & array); }
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   101
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   102
	void SetError(GLenum error) { m_error = error; }
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   103
	void SetClientActiveTexture(int texture) { m_clientActiveTexture = texture; }
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   104
	void SetVertexArray(int size, GLenum type, int stride, const void *pointer);
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   105
	void SetNormalArray(GLenum type, int stride, const void *pointer);
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   106
	void SetColorArray(int size, GLenum type, int stride, const void *pointer);
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   107
	void SetPointerSizeArray(GLenum type, int stride, const void *pointer);
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   108
	void SetTexCoordArray(int size, GLenum type, int stride, const void *pointer);
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   109
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   110
	void EnableArray(GLESArrayFlag array) { m_enabledArrays |= array; }
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   111
	void DisableArray(GLESArrayFlag array) { m_enabledArrays &= ~array; }
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   112
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   113
	void ReserveBufferNames(int num, unsigned int* names);
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   114
	void DeleteBuffer(unsigned int buffer);
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   115
	
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   116
	bool BindArrayBuffer(unsigned int buffer);
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   117
	bool BindElementArrayBuffer(unsigned int buffer);
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   118
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   119
	void DeleteTexture(unsigned int texture);
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   120
	bool BindTexture(unsigned int texture);
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   121
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   122
private:
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   123
	bool m_initialized;
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   124
	void* m_nativeContext;
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   125
	GLESDesktopGL m_dgl;
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   126
	GLenum m_error;
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   127
	unsigned int m_maxTextureLevel;
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   128
	unsigned int m_maxTextureUnits;
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   129
	unsigned int m_maxClipPlanes;
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   130
	unsigned int m_maxLights;
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   131
	int m_clientActiveTexture;
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   132
	GLESArray m_vertexArray;
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   133
	GLESArray m_normalArray;
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   134
	GLESArray m_colorArray;
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   135
	GLESArray m_pointSizeArray;
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   136
	GLESArray* m_texCoordArray;
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   137
	unsigned int m_enabledArrays;
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   138
	unsigned int m_arrayBufferBinding;
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   139
	unsigned int m_elementArrayBufferBinding;
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   140
	unsigned int m_textureBinding;
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   141
	BufferMap m_buffers;
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   142
	TextureMap m_textures;
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   143
};
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   144
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   145
void* glesGetCurrentGLESContext();
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   146
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   147
#define GLES_ENTER_RET(RETVAL) \
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   148
	GLESContext* ctx; \
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   149
	do \
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   150
	{ \
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   151
		glesGetLock(); \
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   152
		ctx = (GLESContext*)glesGetCurrentGLESContext(); \
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   153
		if(!ctx) \
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   154
		{ \
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   155
			glesReleaseLock(); \
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   156
			return RETVAL; \
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   157
		} \
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   158
		if(!ctx->IsInitialized()) \
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   159
		{ \
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   160
			if(!ctx->Initialize()) \
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   161
			{ \
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   162
				std::cerr << "Failed to initialize context" << std::endl; \
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   163
				exit(1); \
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   164
			} \
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   165
		} \
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   166
	} while(0)
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   167
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   168
#define GLES_ENTER() GLES_ENTER_RET(GLES_NO_RETVAL)
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   169
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   170
// Check the host error after every API function call so that the error flag
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   171
// in the wrapper always contains the latest error.
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   172
#define GLES_LEAVE_RET(RETVAL) \
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   173
	do \
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   174
	{ \
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   175
		ctx->GetHostError(); \
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   176
		glesReleaseLock(); \
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   177
		return RETVAL; \
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   178
	} while(0)
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   179
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   180
#define GLES_LEAVE() GLES_LEAVE_RET(GLES_NO_RETVAL)
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   181
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   182
#define GLES_LEAVE_NO_ERROR_CHECK_RET(RETVAL) \
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   183
	do \
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   184
	{ \
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   185
		glesReleaseLock(); \
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   186
		return RETVAL; \
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   187
	} while(0)
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   188
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   189
#define GLES_LEAVE_NO_ERROR_CHECK() GLES_LEAVE_NO_ERROR_CHECK_RET(GLES_NO_RETVAL)
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   190
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   191
#define GLES_ERROR_IF_RET(COND, ERROR, RETVAL) \
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   192
	do \
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   193
	{ \
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   194
		if(COND) \
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   195
		{ \
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   196
			ctx->SetError(ERROR); \
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   197
			return RETVAL; \
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   198
		} \
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   199
	} while(0)
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   200
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   201
#define GLES_ERROR_IF(COND, ERROR) GLES_ERROR_IF_RET(COND, ERROR, GLES_NO_RETVAL)
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   202
#define GLES_ERROR_RET(ERROR, RETVAL) GLES_ERROR_IF_RET(true, ERROR, RETVAL)
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   203
#define GLES_ERROR(ERROR) GLES_ERROR_IF(true, ERROR)
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   204
c2ef9095503a Copy code from the holdingarea into the target locations.
Matt Plumtree <matt.plumtree@nokia.com>
parents:
diff changeset
   205
#endif // _GLESCONTEXT_H_