hostsupport/hostopengles20/src/context.h
author Matt Plumtree <matt.plumtree@nokia.com>
Fri, 12 Nov 2010 17:56:05 +0000
branchbug235_bringup_0
changeset 76 24381b61de5c
parent 55 09263774e342
permissions -rw-r--r--
Host OpenGL ES 2.0 code now building without warning or error using GCC.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
24
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
     1
/* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
     2
 *
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
     3
 * Permission is hereby granted, free of charge, to any person obtaining a
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
     4
 * copy of this software and associated documentation files (the "Software"),
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
     5
 * to deal in the Software without restriction, including without limitation
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
     6
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
     7
 * and/or sell copies of the Software, and to permit persons to whom the
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
     8
 * Software is furnished to do so, subject to the following conditions:
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
     9
 *
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    10
 * The above copyright notice and this permission notice shall be included
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    11
 * in all copies or substantial portions of the Software.
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    12
 *
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    13
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    14
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    15
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    16
 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    17
 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    18
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    19
 *
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    20
 * Initial Contributors:
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    21
 * Nokia Corporation - initial contribution.
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    22
 *
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    23
 * Contributors:
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    24
 *
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    25
 * Description:
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    26
 *
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    27
 */
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    28
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    29
#ifndef _GLESCONTEXT_H_
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    30
#define _GLESCONTEXT_H_
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    31
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    32
#include "platform.h"
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    33
#include "degl.h"
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    34
#include "vertex.h"
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    35
#include "buffer.h"
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    36
#include "shader.h"
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    37
#include "program.h"
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    38
#include "texture.h"
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    39
#include "fbo.h"
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    40
76
24381b61de5c Host OpenGL ES 2.0 code now building without warning or error using GCC.
Matt Plumtree <matt.plumtree@nokia.com>
parents: 55
diff changeset
    41
#ifdef __cplusplus
24381b61de5c Host OpenGL ES 2.0 code now building without warning or error using GCC.
Matt Plumtree <matt.plumtree@nokia.com>
parents: 55
diff changeset
    42
extern "C" {
24381b61de5c Host OpenGL ES 2.0 code now building without warning or error using GCC.
Matt Plumtree <matt.plumtree@nokia.com>
parents: 55
diff changeset
    43
#endif
24381b61de5c Host OpenGL ES 2.0 code now building without warning or error using GCC.
Matt Plumtree <matt.plumtree@nokia.com>
parents: 55
diff changeset
    44
24
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    45
typedef struct DGLContext
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    46
{
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    47
    GLboolean	initialized;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    48
    void*		native_context;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    49
    HGL			hgl;	// Extension procedure addresses are context-specific on WGL.
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    50
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    51
    unsigned int max_vertex_attribs;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    52
    int max_texture_level;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    53
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    54
    GLenum error;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    55
    GLuint buffer_binding;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    56
    GLuint texture_binding_2d;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    57
    GLuint texture_binding_cube_map;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    58
	GLuint framebuffer_binding;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    59
	GLuint renderbuffer_binding;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    60
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    61
    GLfloat attrib_zero[4];	// Attribute zero can't be set in desktop GL.
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    62
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    63
    DGLVertexArray*		vertex_arrays;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    64
    DGLBuffer*			buffers;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    65
    DGLShader*			shaders;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    66
    DGLProgram*			programs;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    67
    DGLTexture*			textures;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    68
	DGLRenderbuffer*	renderbuffers;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    69
} DGLContext;
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    70
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    71
DGLContext* DGLContext_create(void* native_context);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    72
GLboolean	DGLContext_initialize(DGLContext* ctx);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    73
void		DGLContext_destroy(DGLContext* ctx);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    74
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    75
void		DGLContext_setError(DGLContext* ctx, GLenum error);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    76
GLenum		DGLContext_getHostError(DGLContext* ctx);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    77
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    78
GLboolean	DGLContext_createBuffer(DGLContext* ctx, GLuint buffer);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    79
void		DGLContext_destroyBuffer(DGLContext* ctx, GLuint buffer);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    80
DGLBuffer*	DGLContext_findBuffer(DGLContext* ctx, GLuint buffer);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    81
GLboolean	DGLContext_bindBuffer(DGLContext* ctx, GLuint buffer);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    82
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    83
GLboolean	DGLContext_createShader(DGLContext* ctx, GLuint shader);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    84
void		DGLContext_destroyShader(DGLContext* ctx, GLuint shader);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    85
DGLShader*	DGLContext_findShader(DGLContext* ctx, GLuint shader);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    86
GLboolean	DGLContext_setShaderSource(DGLContext* ctx, GLuint shader, const char* source, int length);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    87
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    88
GLboolean	DGLContext_createProgram(DGLContext* ctx, GLuint program);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    89
void		DGLContext_destroyProgram(DGLContext* ctx, GLuint program);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    90
DGLProgram*	DGLContext_findProgram(DGLContext* ctx, GLuint program);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    91
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    92
GLboolean			DGLContext_createTexture(DGLContext* ctx, GLuint texture, DGLTextureType type);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    93
void				DGLContext_destroyTexture(DGLContext* ctx, GLuint texture);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    94
DGLTexture*			DGLContext_findTexture(DGLContext* ctx, GLuint texture);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    95
GLboolean			DGLContext_bindTexture(DGLContext* ctx, GLenum target, GLuint name);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    96
DGLTexture*			DGLContext_getTexture(DGLContext* ctx, GLenum target);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    97
DGLTextureLevel*	DGLContext_getTextureLevel(DGLContext* ctx, GLenum target, GLint level);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    98
GLboolean			DGLContext_specifyTextureFromEGLImage(DGLContext* ctx, GLeglImageOES image, GLenum target);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
    99
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
   100
GLboolean			DGLContext_createRenderbuffer(DGLContext* ctx, GLuint buffer);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
   101
void				DGLContext_destroyRenderbuffer(DGLContext* ctx, GLuint buffer);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
   102
DGLRenderbuffer*	DGLContext_getColorRenderbuffer(DGLContext* ctx);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
   103
DGLRenderbuffer*	DGLContext_findRenderbuffer(DGLContext* ctx, GLuint buffer);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
   104
GLboolean			DGLContext_bindRenderbuffer(DGLContext* ctx, GLuint buffer);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
   105
GLboolean			DGLContext_specifyRenderbufferFromEGLImage(DGLContext* ctx, GLeglImageOES image);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
   106
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
   107
void	DGLContext_updateFBOAttachmentSiblings(DGLContext* ctx);
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
   108
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
   109
#ifdef __cplusplus
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
   110
}
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
   111
#endif
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
   112
a3f46bb01be2 Fix line endings
Faisal Memon <faisal.memon@nokia.com>
parents: 20
diff changeset
   113
#endif // _GLESCONTEXT_H_