2011-03-14 21:23:01 +00:00
|
|
|
|
2011-07-28 14:26:00 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2011 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
2011-03-14 21:23:01 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2011-07-28 14:26:00 +00:00
|
|
|
|
2011-03-14 21:23:01 +00:00
|
|
|
#ifndef GrGLInterface_DEFINED
|
|
|
|
#define GrGLInterface_DEFINED
|
|
|
|
|
2011-04-04 17:13:52 +00:00
|
|
|
#include "GrGLConfig.h"
|
2011-08-19 13:28:54 +00:00
|
|
|
#include "GrRefCnt.h"
|
2011-03-14 21:23:01 +00:00
|
|
|
|
|
|
|
#if !defined(GR_GL_FUNCTION_TYPE)
|
|
|
|
#define GR_GL_FUNCTION_TYPE
|
|
|
|
#endif
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Helpers for glGetString()
|
|
|
|
*/
|
2011-04-04 17:13:52 +00:00
|
|
|
|
2011-09-22 14:31:24 +00:00
|
|
|
typedef uint32_t GrGLVersion;
|
2011-09-29 14:40:26 +00:00
|
|
|
typedef uint32_t GrGLSLVersion;
|
2011-09-22 14:10:33 +00:00
|
|
|
|
2011-09-29 14:40:26 +00:00
|
|
|
#define GR_GL_VER(major, minor) ((static_cast<int>(major) << 16) | \
|
|
|
|
static_cast<int>(minor))
|
|
|
|
#define GR_GLSL_VER(major, minor) ((static_cast<int>(major) << 16) | \
|
|
|
|
static_cast<int>(minor))
|
2011-09-22 14:10:33 +00:00
|
|
|
|
2011-07-06 17:47:02 +00:00
|
|
|
// these variants assume caller already has a string from glGetString()
|
2011-09-22 14:10:33 +00:00
|
|
|
GrGLVersion GrGLGetVersionFromString(const char* versionString);
|
2011-09-29 14:40:26 +00:00
|
|
|
GrGLSLVersion GrGLGetGLSLVersionFromString(const char* versionString);
|
2011-09-22 14:10:33 +00:00
|
|
|
bool GrGLHasExtensionFromString(const char* ext, const char* extensionString);
|
2011-04-04 17:13:52 +00:00
|
|
|
|
2011-07-06 17:47:02 +00:00
|
|
|
// these variants call glGetString()
|
2011-10-19 20:43:20 +00:00
|
|
|
bool GrGLHasExtension(const GrGLInterface*, const char* ext);
|
2011-09-22 14:10:33 +00:00
|
|
|
GrGLVersion GrGLGetVersion(const GrGLInterface*);
|
2011-09-29 14:40:26 +00:00
|
|
|
GrGLSLVersion GrGLGetGLSLVersion(const GrGLInterface*);
|
2011-04-04 17:13:52 +00:00
|
|
|
|
2011-03-14 21:23:01 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2011-08-19 13:28:54 +00:00
|
|
|
/**
|
|
|
|
* Rather than depend on platform-specific GL headers and libraries, we require
|
|
|
|
* the client to provide a struct of GL function pointers. This struct can be
|
|
|
|
* specified per-GrContext as a parameter to GrContext::Create. If NULL is
|
|
|
|
* passed to Create then the "default" GL interface is used. If the default is
|
|
|
|
* also NULL GrContext creation will fail.
|
|
|
|
*
|
2011-09-16 18:51:57 +00:00
|
|
|
* The default interface is returned by GrGLDefaultInterface. This function's
|
|
|
|
* implementation is platform-specifc. Several have been provided, along with an
|
|
|
|
* implementation that simply returns NULL. It is implementation-specific
|
|
|
|
* whether the same GrGLInterface is returned or whether a new one is created
|
|
|
|
* at each call. Some platforms may not be able to use a single GrGLInterface
|
|
|
|
* because extension function ptrs vary across contexts. Note that GrGLInterface
|
|
|
|
* is ref-counted. So if the same object is returned by multiple calls to
|
|
|
|
* GrGLDefaultInterface, each should bump the ref count.
|
2011-09-01 13:28:16 +00:00
|
|
|
*
|
|
|
|
* By defining GR_GL_PER_GL_CALL_IFACE_CALLBACK to 1 the client can specify a
|
|
|
|
* callback function that will be called prior to each GL function call. See
|
|
|
|
* comments in GrGLConfig.h
|
2011-03-14 21:23:01 +00:00
|
|
|
*/
|
2011-08-19 13:28:54 +00:00
|
|
|
|
2011-03-14 21:23:01 +00:00
|
|
|
struct GrGLInterface;
|
|
|
|
|
2011-09-16 18:51:57 +00:00
|
|
|
const GrGLInterface* GrGLDefaultInterface();
|
2011-03-14 21:23:01 +00:00
|
|
|
|
2011-10-19 20:43:20 +00:00
|
|
|
const GrGLInterface* GrGLCreateNativeInterface();
|
|
|
|
|
|
|
|
const GrGLInterface* GrGLCreateMesaInterface();
|
|
|
|
|
2011-03-18 17:38:11 +00:00
|
|
|
typedef unsigned int GrGLenum;
|
|
|
|
typedef unsigned char GrGLboolean;
|
|
|
|
typedef unsigned int GrGLbitfield;
|
|
|
|
typedef signed char GrGLbyte;
|
2011-05-20 14:13:56 +00:00
|
|
|
typedef char GrGLchar;
|
2011-03-18 17:38:11 +00:00
|
|
|
typedef short GrGLshort;
|
|
|
|
typedef int GrGLint;
|
|
|
|
typedef int GrGLsizei;
|
2011-10-19 20:43:20 +00:00
|
|
|
typedef int64_t GrGLint64;
|
2011-03-18 17:38:11 +00:00
|
|
|
typedef unsigned char GrGLubyte;
|
|
|
|
typedef unsigned short GrGLushort;
|
|
|
|
typedef unsigned int GrGLuint;
|
2011-10-19 20:43:20 +00:00
|
|
|
typedef uint64_t GrGLuint64;
|
2011-03-18 17:38:11 +00:00
|
|
|
typedef float GrGLfloat;
|
|
|
|
typedef float GrGLclampf;
|
|
|
|
typedef double GrGLdouble;
|
|
|
|
typedef double GrGLclampd;
|
|
|
|
typedef void GrGLvoid;
|
2011-04-04 17:13:52 +00:00
|
|
|
typedef long GrGLintptr;
|
|
|
|
typedef long GrGLsizeiptr;
|
2011-03-18 17:38:11 +00:00
|
|
|
|
2011-03-18 20:41:44 +00:00
|
|
|
enum GrGLBinding {
|
|
|
|
kDesktop_GrGLBinding = 0x01,
|
|
|
|
kES1_GrGLBinding = 0x02,
|
|
|
|
kES2_GrGLBinding = 0x04
|
|
|
|
};
|
|
|
|
|
2011-03-14 21:23:01 +00:00
|
|
|
extern "C" {
|
2011-03-18 17:38:11 +00:00
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLActiveTextureProc)(GrGLenum texture);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLAttachShaderProc)(GrGLuint program, GrGLuint shader);
|
2011-10-19 20:43:20 +00:00
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBeginQueryProc)(GrGLenum target, GrGLuint id);
|
2011-03-18 17:38:11 +00:00
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBindAttribLocationProc)(GrGLuint program, GrGLuint index, const char* name);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBindBufferProc)(GrGLenum target, GrGLuint buffer);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBindTextureProc)(GrGLenum target, GrGLuint texture);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBlendColorProc)(GrGLclampf red, GrGLclampf green, GrGLclampf blue, GrGLclampf alpha);
|
2011-09-21 16:21:07 +00:00
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBindFragDataLocationProc)(GrGLuint program, GrGLuint colorNumber, const GrGLchar* name);
|
2011-03-18 17:38:11 +00:00
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBlendFuncProc)(GrGLenum sfactor, GrGLenum dfactor);
|
2011-04-04 17:13:52 +00:00
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBufferDataProc)(GrGLenum target, GrGLsizeiptr size, const GrGLvoid* data, GrGLenum usage);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBufferSubDataProc)(GrGLenum target, GrGLintptr offset, GrGLsizeiptr size, const GrGLvoid* data);
|
2011-03-18 17:38:11 +00:00
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLClearProc)(GrGLbitfield mask);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLClearColorProc)(GrGLclampf red, GrGLclampf green, GrGLclampf blue, GrGLclampf alpha);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLClearStencilProc)(GrGLint s);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLClientActiveTextureProc)(GrGLenum texture);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLColor4ubProc)(GrGLubyte red, GrGLubyte green, GrGLubyte blue, GrGLubyte alpha);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLColorMaskProc)(GrGLboolean red, GrGLboolean green, GrGLboolean blue, GrGLboolean alpha);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLColorPointerProc)(GrGLint size, GrGLenum type, GrGLsizei stride, const GrGLvoid* pointer);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLCompileShaderProc)(GrGLuint shader);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLCompressedTexImage2DProc)(GrGLenum target, GrGLint level, GrGLenum internalformat, GrGLsizei width, GrGLsizei height, GrGLint border, GrGLsizei imageSize, const GrGLvoid* data);
|
|
|
|
typedef GrGLuint (GR_GL_FUNCTION_TYPE *GrGLCreateProgramProc)(void);
|
|
|
|
typedef GrGLuint (GR_GL_FUNCTION_TYPE *GrGLCreateShaderProc)(GrGLenum type);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLCullFaceProc)(GrGLenum mode);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDeleteBuffersProc)(GrGLsizei n, const GrGLuint* buffers);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDeleteProgramProc)(GrGLuint program);
|
2011-10-19 20:43:20 +00:00
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDeleteQueriesProc)(GrGLsizei n, const GrGLuint *ids);
|
2011-03-18 17:38:11 +00:00
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDeleteShaderProc)(GrGLuint shader);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDeleteTexturesProc)(GrGLsizei n, const GrGLuint* textures);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDepthMaskProc)(GrGLboolean flag);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDisableProc)(GrGLenum cap);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDisableClientStateProc)(GrGLenum array);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDisableVertexAttribArrayProc)(GrGLuint index);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDrawArraysProc)(GrGLenum mode, GrGLint first, GrGLsizei count);
|
2011-08-02 19:29:03 +00:00
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDrawBufferProc)(GrGLenum mode);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDrawBuffersProc)(GrGLsizei n, const GrGLenum* bufs);
|
2011-03-18 17:38:11 +00:00
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDrawElementsProc)(GrGLenum mode, GrGLsizei count, GrGLenum type, const GrGLvoid* indices);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLEnableProc)(GrGLenum cap);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLEnableClientStateProc)(GrGLenum cap);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLEnableVertexAttribArrayProc)(GrGLuint index);
|
2011-10-19 20:43:20 +00:00
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLEndQueryProc)(GrGLenum target);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLFinishProc)();
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLFlushProc)();
|
2011-03-18 17:38:11 +00:00
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLFrontFaceProc)(GrGLenum mode);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGenBuffersProc)(GrGLsizei n, GrGLuint* buffers);
|
2011-10-19 20:43:20 +00:00
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGenQueriesProc)(GrGLsizei n, GrGLuint *ids);
|
2011-03-18 17:38:11 +00:00
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGenTexturesProc)(GrGLsizei n, GrGLuint* textures);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetBufferParameterivProc)(GrGLenum target, GrGLenum pname, GrGLint* params);
|
2011-10-19 20:43:20 +00:00
|
|
|
typedef GrGLenum (GR_GL_FUNCTION_TYPE *GrGLGetErrorProc)();
|
2011-03-18 17:38:11 +00:00
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetIntegervProc)(GrGLenum pname, GrGLint* params);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetProgramInfoLogProc)(GrGLuint program, GrGLsizei bufsize, GrGLsizei* length, char* infolog);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetProgramivProc)(GrGLuint program, GrGLenum pname, GrGLint* params);
|
2011-10-19 20:43:20 +00:00
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetQueryivProc)(GrGLenum GLtarget, GrGLenum pname, GrGLint *params);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetQueryObjecti64vProc)(GrGLuint id, GrGLenum pname, GrGLint64 *params);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetQueryObjectivProc)(GrGLuint id, GrGLenum pname, GrGLint *params);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetQueryObjectui64vProc)(GrGLuint id, GrGLenum pname, GrGLuint64 *params);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetQueryObjectuivProc)(GrGLuint id, GrGLenum pname, GrGLuint *params);
|
2011-03-18 17:38:11 +00:00
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetShaderInfoLogProc)(GrGLuint shader, GrGLsizei bufsize, GrGLsizei* length, char* infolog);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetShaderivProc)(GrGLuint shader, GrGLenum pname, GrGLint* params);
|
|
|
|
typedef const GrGLubyte* (GR_GL_FUNCTION_TYPE *GrGLGetStringProc)(GrGLenum name);
|
2011-10-19 20:43:20 +00:00
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetTexLevelParameterivProc)(GrGLenum target, GrGLint level, GrGLenum pname, GrGLint* params);
|
2011-03-18 17:38:11 +00:00
|
|
|
typedef GrGLint (GR_GL_FUNCTION_TYPE *GrGLGetUniformLocationProc)(GrGLuint program, const char* name);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLLineWidthProc)(GrGLfloat width);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLLinkProgramProc)(GrGLuint program);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLLoadMatrixfProc)(const GrGLfloat* m);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLMatrixModeProc)(GrGLenum mode);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLPixelStoreiProc)(GrGLenum pname, GrGLint param);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLPointSizeProc)(GrGLfloat size);
|
2011-10-19 20:43:20 +00:00
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLQueryCounterProc)(GrGLuint id, GrGLenum target);
|
2011-08-03 14:22:30 +00:00
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLReadBufferProc)(GrGLenum src);
|
2011-03-18 17:38:11 +00:00
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLReadPixelsProc)(GrGLint x, GrGLint y, GrGLsizei width, GrGLsizei height, GrGLenum format, GrGLenum type, GrGLvoid* pixels);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLScissorProc)(GrGLint x, GrGLint y, GrGLsizei width, GrGLsizei height);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLShadeModelProc)(GrGLenum mode);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLShaderSourceProc)(GrGLuint shader, GrGLsizei count, const char** str, const GrGLint* length);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLStencilFuncProc)(GrGLenum func, GrGLint ref, GrGLuint mask);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLStencilFuncSeparateProc)(GrGLenum face, GrGLenum func, GrGLint ref, GrGLuint mask);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLStencilMaskProc)(GrGLuint mask);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLStencilMaskSeparateProc)(GrGLenum face, GrGLuint mask);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLStencilOpProc)(GrGLenum fail, GrGLenum zfail, GrGLenum zpass);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLStencilOpSeparateProc)(GrGLenum face, GrGLenum fail, GrGLenum zfail, GrGLenum zpass);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLTexCoordPointerProc)(GrGLint size, GrGLenum type, GrGLsizei stride, const GrGLvoid* pointer);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLTexEnviProc)(GrGLenum target, GrGLenum pname, GrGLint param);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLTexImage2DProc)(GrGLenum target, GrGLint level, GrGLint internalformat, GrGLsizei width, GrGLsizei height, GrGLint border, GrGLenum format, GrGLenum type, const GrGLvoid* pixels);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLTexParameteriProc)(GrGLenum target, GrGLenum pname, GrGLint param);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLTexSubImage2DProc)(GrGLenum target, GrGLint level, GrGLint xoffset, GrGLint yoffset, GrGLsizei width, GrGLsizei height, GrGLenum format, GrGLenum type, const GrGLvoid* pixels);
|
2011-05-04 12:35:39 +00:00
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform1fProc)(GrGLint location, GrGLfloat v0);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform1iProc)(GrGLint location, GrGLint v0);
|
2011-03-18 17:38:11 +00:00
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform1fvProc)(GrGLint location, GrGLsizei count, const GrGLfloat* v);
|
2011-05-04 12:35:39 +00:00
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform1ivProc)(GrGLint location, GrGLsizei count, const GrGLint* v);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform2fProc)(GrGLint location, GrGLfloat v0, GrGLfloat v1);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform2iProc)(GrGLint location, GrGLint v0, GrGLint v1);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform2fvProc)(GrGLint location, GrGLsizei count, const GrGLfloat* v);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform2ivProc)(GrGLint location, GrGLsizei count, const GrGLint* v);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform3fProc)(GrGLint location, GrGLfloat v0, GrGLfloat v1, GrGLfloat v2);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform3iProc)(GrGLint location, GrGLint v0, GrGLint v1, GrGLint v2);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform3fvProc)(GrGLint location, GrGLsizei count, const GrGLfloat* v);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform3ivProc)(GrGLint location, GrGLsizei count, const GrGLint* v);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform4fProc)(GrGLint location, GrGLfloat v0, GrGLfloat v1, GrGLfloat v2, GrGLfloat v3);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform4iProc)(GrGLint location, GrGLint v0, GrGLint v1, GrGLint v2, GrGLint v3);
|
2011-03-18 17:38:11 +00:00
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform4fvProc)(GrGLint location, GrGLsizei count, const GrGLfloat* v);
|
2011-05-04 12:35:39 +00:00
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniform4ivProc)(GrGLint location, GrGLsizei count, const GrGLint* v);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniformMatrix2fvProc)(GrGLint location, GrGLsizei count, GrGLboolean transpose, const GrGLfloat* value);
|
2011-03-18 17:38:11 +00:00
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniformMatrix3fvProc)(GrGLint location, GrGLsizei count, GrGLboolean transpose, const GrGLfloat* value);
|
2011-05-04 12:35:39 +00:00
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUniformMatrix4fvProc)(GrGLint location, GrGLsizei count, GrGLboolean transpose, const GrGLfloat* value);
|
2011-03-18 17:38:11 +00:00
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLUseProgramProc)(GrGLuint program);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLVertexAttrib4fvProc)(GrGLuint indx, const GrGLfloat* values);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLVertexAttribPointerProc)(GrGLuint indx, GrGLint size, GrGLenum type, GrGLboolean normalized, GrGLsizei stride, const GrGLvoid* ptr);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLVertexPointerProc)(GrGLint size, GrGLenum type, GrGLsizei stride, const GrGLvoid* pointer);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLViewportProc)(GrGLint x, GrGLint y, GrGLsizei width, GrGLsizei height);
|
2011-03-14 21:23:01 +00:00
|
|
|
|
|
|
|
// FBO Extension Functions
|
2011-03-18 17:38:11 +00:00
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBindFramebufferProc)(GrGLenum target, GrGLuint framebuffer);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBindRenderbufferProc)(GrGLenum target, GrGLuint renderbuffer);
|
|
|
|
typedef GrGLenum (GR_GL_FUNCTION_TYPE *GrGLCheckFramebufferStatusProc)(GrGLenum target);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDeleteFramebuffersProc)(GrGLsizei n, const GrGLuint *framebuffers);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLDeleteRenderbuffersProc)(GrGLsizei n, const GrGLuint *renderbuffers);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLFramebufferRenderbufferProc)(GrGLenum target, GrGLenum attachment, GrGLenum renderbuffertarget, GrGLuint renderbuffer);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLFramebufferTexture2DProc)(GrGLenum target, GrGLenum attachment, GrGLenum textarget, GrGLuint texture, GrGLint level);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGenFramebuffersProc)(GrGLsizei n, GrGLuint *framebuffers);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGenRenderbuffersProc)(GrGLsizei n, GrGLuint *renderbuffers);
|
2011-07-26 12:32:36 +00:00
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetFramebufferAttachmentParameterivProc)(GrGLenum target, GrGLenum attachment, GrGLenum pname, GrGLint* params);
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLGetRenderbufferParameterivProc)(GrGLenum target, GrGLenum pname, GrGLint* params);
|
2011-03-18 17:38:11 +00:00
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLRenderbufferStorageProc)(GrGLenum target, GrGLenum internalformat, GrGLsizei width, GrGLsizei height);
|
2011-03-14 21:23:01 +00:00
|
|
|
|
|
|
|
// Multisampling Extension Functions
|
|
|
|
// same prototype for ARB_FBO, EXT_FBO, GL 3.0, & Apple ES extension
|
2011-03-18 17:38:11 +00:00
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLRenderbufferStorageMultisampleProc)(GrGLenum target, GrGLsizei samples, GrGLenum internalformat, GrGLsizei width, GrGLsizei height);
|
2011-03-14 21:23:01 +00:00
|
|
|
// desktop: ext_fbo_blit, arb_fbo, gl 3.0
|
2011-03-18 17:38:11 +00:00
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBlitFramebufferProc)(GrGLint srcX0, GrGLint srcY0, GrGLint srcX1, GrGLint srcY1, GrGLint dstX0, GrGLint dstY0, GrGLint dstX1, GrGLint dstY1, GrGLbitfield mask, GrGLenum filter);
|
2011-03-14 21:23:01 +00:00
|
|
|
// apple's es extension
|
2011-03-18 17:38:11 +00:00
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLResolveMultisampleFramebufferProc)();
|
2011-03-14 21:23:01 +00:00
|
|
|
|
|
|
|
// Buffer mapping (extension in ES).
|
2011-03-18 17:38:11 +00:00
|
|
|
typedef GrGLvoid* (GR_GL_FUNCTION_TYPE *GrGLMapBufferProc)(GrGLenum target, GrGLenum access);
|
|
|
|
typedef GrGLboolean (GR_GL_FUNCTION_TYPE *GrGLUnmapBufferProc)(GrGLenum target);
|
2011-05-20 14:13:56 +00:00
|
|
|
|
|
|
|
// Dual source blending
|
|
|
|
typedef GrGLvoid (GR_GL_FUNCTION_TYPE *GrGLBindFragDataLocationIndexedProc)(GrGLuint program, GrGLuint colorNumber, GrGLuint index, const GrGLchar * name);
|
2011-05-04 12:35:39 +00:00
|
|
|
} // extern "C"
|
|
|
|
|
2011-09-01 13:28:16 +00:00
|
|
|
#if GR_GL_PER_GL_FUNC_CALLBACK
|
|
|
|
typedef void (*GrGLInterfaceCallbackProc)(const GrGLInterface*);
|
|
|
|
typedef intptr_t GrGLInterfaceCallbackData;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2011-06-16 14:08:04 +00:00
|
|
|
enum GrGLCapability {
|
|
|
|
kProbe_GrGLCapability = -1
|
2011-06-15 19:41:46 +00:00
|
|
|
};
|
|
|
|
|
2011-05-04 12:35:39 +00:00
|
|
|
/*
|
|
|
|
* The following interface exports the OpenGL entry points used by the system.
|
|
|
|
* Use of OpenGL calls is disallowed. All calls should be invoked through
|
|
|
|
* the global instance of this struct, defined above.
|
|
|
|
*
|
|
|
|
* IMPORTANT NOTE: The OpenGL entry points exposed here include both core GL
|
|
|
|
* functions, and extensions. The system assumes that the address of the
|
|
|
|
* extension pointer will be valid across contexts.
|
|
|
|
*/
|
2011-08-19 13:28:54 +00:00
|
|
|
struct GR_API GrGLInterface : public GrRefCnt {
|
|
|
|
|
|
|
|
GrGLInterface();
|
|
|
|
|
2011-05-04 12:35:39 +00:00
|
|
|
bool validate(GrEngine engine) const;
|
2011-08-19 13:28:54 +00:00
|
|
|
bool supportsDesktop() const {
|
|
|
|
return 0 != (kDesktop_GrGLBinding & fBindingsExported);
|
|
|
|
}
|
|
|
|
bool supportsES1() const {
|
|
|
|
return 0 != (kES1_GrGLBinding & fBindingsExported);
|
|
|
|
}
|
|
|
|
bool supportsES2() const {
|
|
|
|
return 0 != (kES2_GrGLBinding & fBindingsExported);
|
|
|
|
}
|
|
|
|
bool supportsES() const {
|
|
|
|
return 0 != ((kES1_GrGLBinding | kES2_GrGLBinding) &
|
|
|
|
fBindingsExported);
|
|
|
|
}
|
2011-03-14 21:23:01 +00:00
|
|
|
|
2011-03-18 20:41:44 +00:00
|
|
|
// Indicator variable specifying the type of GL implementation
|
|
|
|
// exported: GLES{1|2} or Desktop.
|
|
|
|
GrGLBinding fBindingsExported;
|
|
|
|
|
2011-06-14 18:16:52 +00:00
|
|
|
/// Does this GL support NPOT textures on FBOs?
|
2011-06-16 14:08:04 +00:00
|
|
|
/// boolean value, or kProbe_GrGLCapability to probe (slowly) at context creation.
|
2011-06-14 18:16:52 +00:00
|
|
|
int fNPOTRenderTargetSupport;
|
|
|
|
|
|
|
|
/// Some GL implementations (PowerVR SGX devices like the iPhone 4)
|
|
|
|
/// have restrictions on the size of small render targets.
|
2011-06-16 14:08:04 +00:00
|
|
|
/// kProbe_GrGLCapability to probe (slowly) at context creation.
|
2011-06-14 18:16:52 +00:00
|
|
|
int fMinRenderTargetHeight;
|
|
|
|
int fMinRenderTargetWidth;
|
|
|
|
|
2011-03-14 21:23:01 +00:00
|
|
|
GrGLActiveTextureProc fActiveTexture;
|
|
|
|
GrGLAttachShaderProc fAttachShader;
|
2011-10-19 20:43:20 +00:00
|
|
|
GrGLBeginQueryProc fBeginQuery;
|
2011-03-14 21:23:01 +00:00
|
|
|
GrGLBindAttribLocationProc fBindAttribLocation;
|
|
|
|
GrGLBindBufferProc fBindBuffer;
|
2011-09-21 16:21:07 +00:00
|
|
|
GrGLBindFragDataLocationProc fBindFragDataLocation;
|
2011-03-14 21:23:01 +00:00
|
|
|
GrGLBindTextureProc fBindTexture;
|
2011-03-15 19:09:25 +00:00
|
|
|
GrGLBlendColorProc fBlendColor;
|
2011-04-04 17:13:52 +00:00
|
|
|
GrGLBlendFuncProc fBlendFunc;
|
2011-03-14 21:23:01 +00:00
|
|
|
GrGLBufferDataProc fBufferData;
|
|
|
|
GrGLBufferSubDataProc fBufferSubData;
|
|
|
|
GrGLClearProc fClear;
|
|
|
|
GrGLClearColorProc fClearColor;
|
|
|
|
GrGLClearStencilProc fClearStencil;
|
|
|
|
GrGLClientActiveTextureProc fClientActiveTexture;
|
|
|
|
GrGLColor4ubProc fColor4ub;
|
|
|
|
GrGLColorMaskProc fColorMask;
|
|
|
|
GrGLColorPointerProc fColorPointer;
|
|
|
|
GrGLCompileShaderProc fCompileShader;
|
|
|
|
GrGLCompressedTexImage2DProc fCompressedTexImage2D;
|
|
|
|
GrGLCreateProgramProc fCreateProgram;
|
|
|
|
GrGLCreateShaderProc fCreateShader;
|
|
|
|
GrGLCullFaceProc fCullFace;
|
|
|
|
GrGLDeleteBuffersProc fDeleteBuffers;
|
|
|
|
GrGLDeleteProgramProc fDeleteProgram;
|
2011-10-19 20:43:20 +00:00
|
|
|
GrGLDeleteQueriesProc fDeleteQueries;
|
2011-03-14 21:23:01 +00:00
|
|
|
GrGLDeleteShaderProc fDeleteShader;
|
|
|
|
GrGLDeleteTexturesProc fDeleteTextures;
|
|
|
|
GrGLDepthMaskProc fDepthMask;
|
|
|
|
GrGLDisableProc fDisable;
|
|
|
|
GrGLDisableClientStateProc fDisableClientState;
|
|
|
|
GrGLDisableVertexAttribArrayProc fDisableVertexAttribArray;
|
|
|
|
GrGLDrawArraysProc fDrawArrays;
|
2011-08-02 19:29:03 +00:00
|
|
|
GrGLDrawBufferProc fDrawBuffer;
|
|
|
|
GrGLDrawBuffersProc fDrawBuffers;
|
2011-03-14 21:23:01 +00:00
|
|
|
GrGLDrawElementsProc fDrawElements;
|
|
|
|
GrGLEnableProc fEnable;
|
|
|
|
GrGLEnableClientStateProc fEnableClientState;
|
|
|
|
GrGLEnableVertexAttribArrayProc fEnableVertexAttribArray;
|
2011-10-19 20:43:20 +00:00
|
|
|
GrGLEndQueryProc fEndQuery;
|
|
|
|
GrGLFinishProc fFinish;
|
|
|
|
GrGLFlushProc fFlush;
|
2011-03-14 21:23:01 +00:00
|
|
|
GrGLFrontFaceProc fFrontFace;
|
|
|
|
GrGLGenBuffersProc fGenBuffers;
|
2011-10-19 20:43:20 +00:00
|
|
|
GrGLGenQueriesProc fGenQueries;
|
2011-03-14 21:23:01 +00:00
|
|
|
GrGLGenTexturesProc fGenTextures;
|
|
|
|
GrGLGetBufferParameterivProc fGetBufferParameteriv;
|
|
|
|
GrGLGetErrorProc fGetError;
|
|
|
|
GrGLGetIntegervProc fGetIntegerv;
|
2011-10-19 20:43:20 +00:00
|
|
|
GrGLGetQueryObjecti64vProc fGetQueryObjecti64v;
|
|
|
|
GrGLGetQueryObjectivProc fGetQueryObjectiv;
|
|
|
|
GrGLGetQueryObjectui64vProc fGetQueryObjectui64v;
|
|
|
|
GrGLGetQueryObjectuivProc fGetQueryObjectuiv;
|
|
|
|
GrGLGetQueryivProc fGetQueryiv;
|
2011-03-14 21:23:01 +00:00
|
|
|
GrGLGetProgramInfoLogProc fGetProgramInfoLog;
|
|
|
|
GrGLGetProgramivProc fGetProgramiv;
|
|
|
|
GrGLGetShaderInfoLogProc fGetShaderInfoLog;
|
|
|
|
GrGLGetShaderivProc fGetShaderiv;
|
|
|
|
GrGLGetStringProc fGetString;
|
2011-10-19 20:43:20 +00:00
|
|
|
GrGLGetTexLevelParameterivProc fGetTexLevelParameteriv;
|
2011-03-14 21:23:01 +00:00
|
|
|
GrGLGetUniformLocationProc fGetUniformLocation;
|
|
|
|
GrGLLineWidthProc fLineWidth;
|
|
|
|
GrGLLinkProgramProc fLinkProgram;
|
|
|
|
GrGLLoadMatrixfProc fLoadMatrixf;
|
|
|
|
GrGLMatrixModeProc fMatrixMode;
|
|
|
|
GrGLPixelStoreiProc fPixelStorei;
|
|
|
|
GrGLPointSizeProc fPointSize;
|
2011-10-19 20:43:20 +00:00
|
|
|
GrGLQueryCounterProc fQueryCounter;
|
2011-08-03 14:22:30 +00:00
|
|
|
GrGLReadBufferProc fReadBuffer;
|
2011-03-14 21:23:01 +00:00
|
|
|
GrGLReadPixelsProc fReadPixels;
|
|
|
|
GrGLScissorProc fScissor;
|
|
|
|
GrGLShadeModelProc fShadeModel;
|
|
|
|
GrGLShaderSourceProc fShaderSource;
|
|
|
|
GrGLStencilFuncProc fStencilFunc;
|
|
|
|
GrGLStencilFuncSeparateProc fStencilFuncSeparate;
|
|
|
|
GrGLStencilMaskProc fStencilMask;
|
|
|
|
GrGLStencilMaskSeparateProc fStencilMaskSeparate;
|
|
|
|
GrGLStencilOpProc fStencilOp;
|
|
|
|
GrGLStencilOpSeparateProc fStencilOpSeparate;
|
|
|
|
GrGLTexCoordPointerProc fTexCoordPointer;
|
|
|
|
GrGLTexEnviProc fTexEnvi;
|
|
|
|
GrGLTexImage2DProc fTexImage2D;
|
|
|
|
GrGLTexParameteriProc fTexParameteri;
|
|
|
|
GrGLTexSubImage2DProc fTexSubImage2D;
|
2011-05-04 12:35:39 +00:00
|
|
|
GrGLUniform1fProc fUniform1f;
|
2011-03-14 21:23:01 +00:00
|
|
|
GrGLUniform1iProc fUniform1i;
|
2011-05-04 12:35:39 +00:00
|
|
|
GrGLUniform1fvProc fUniform1fv;
|
|
|
|
GrGLUniform1ivProc fUniform1iv;
|
|
|
|
GrGLUniform2fProc fUniform2f;
|
|
|
|
GrGLUniform2iProc fUniform2i;
|
|
|
|
GrGLUniform2fvProc fUniform2fv;
|
|
|
|
GrGLUniform2ivProc fUniform2iv;
|
|
|
|
GrGLUniform3fProc fUniform3f;
|
|
|
|
GrGLUniform3iProc fUniform3i;
|
|
|
|
GrGLUniform3fvProc fUniform3fv;
|
|
|
|
GrGLUniform3ivProc fUniform3iv;
|
|
|
|
GrGLUniform4fProc fUniform4f;
|
|
|
|
GrGLUniform4iProc fUniform4i;
|
2011-03-14 21:23:01 +00:00
|
|
|
GrGLUniform4fvProc fUniform4fv;
|
2011-05-04 12:35:39 +00:00
|
|
|
GrGLUniform4ivProc fUniform4iv;
|
|
|
|
GrGLUniformMatrix2fvProc fUniformMatrix2fv;
|
2011-03-14 21:23:01 +00:00
|
|
|
GrGLUniformMatrix3fvProc fUniformMatrix3fv;
|
2011-05-04 12:35:39 +00:00
|
|
|
GrGLUniformMatrix4fvProc fUniformMatrix4fv;
|
2011-03-14 21:23:01 +00:00
|
|
|
GrGLUseProgramProc fUseProgram;
|
|
|
|
GrGLVertexAttrib4fvProc fVertexAttrib4fv;
|
|
|
|
GrGLVertexAttribPointerProc fVertexAttribPointer;
|
|
|
|
GrGLVertexPointerProc fVertexPointer;
|
|
|
|
GrGLViewportProc fViewport;
|
|
|
|
|
|
|
|
// FBO Extension Functions
|
|
|
|
GrGLBindFramebufferProc fBindFramebuffer;
|
|
|
|
GrGLBindRenderbufferProc fBindRenderbuffer;
|
|
|
|
GrGLCheckFramebufferStatusProc fCheckFramebufferStatus;
|
|
|
|
GrGLDeleteFramebuffersProc fDeleteFramebuffers;
|
|
|
|
GrGLDeleteRenderbuffersProc fDeleteRenderbuffers;
|
|
|
|
GrGLFramebufferRenderbufferProc fFramebufferRenderbuffer;
|
|
|
|
GrGLFramebufferTexture2DProc fFramebufferTexture2D;
|
|
|
|
GrGLGenFramebuffersProc fGenFramebuffers;
|
|
|
|
GrGLGenRenderbuffersProc fGenRenderbuffers;
|
2011-07-26 12:32:36 +00:00
|
|
|
GrGLGetFramebufferAttachmentParameterivProc fGetFramebufferAttachmentParameteriv;
|
|
|
|
GrGLGetRenderbufferParameterivProc fGetRenderbufferParameteriv;
|
2011-03-14 21:23:01 +00:00
|
|
|
GrGLRenderbufferStorageProc fRenderbufferStorage;
|
|
|
|
|
|
|
|
// Multisampling Extension Functions
|
|
|
|
// same prototype for ARB_FBO, EXT_FBO, GL 3.0, & Apple ES extension
|
|
|
|
GrGLRenderbufferStorageMultisampleProc fRenderbufferStorageMultisample;
|
|
|
|
// desktop: ext_fbo_blit, arb_fbo, gl 3.0
|
|
|
|
GrGLBlitFramebufferProc fBlitFramebuffer;
|
|
|
|
// apple's es extension
|
|
|
|
GrGLResolveMultisampleFramebufferProc fResolveMultisampleFramebuffer;
|
|
|
|
|
|
|
|
// Buffer mapping (extension in ES).
|
|
|
|
GrGLMapBufferProc fMapBuffer;
|
|
|
|
GrGLUnmapBufferProc fUnmapBuffer;
|
2011-04-04 17:13:52 +00:00
|
|
|
|
2011-05-20 14:13:56 +00:00
|
|
|
// Dual Source Blending
|
|
|
|
GrGLBindFragDataLocationIndexedProc fBindFragDataLocationIndexed;
|
|
|
|
|
2011-09-01 13:28:16 +00:00
|
|
|
// Per-GL func callback
|
|
|
|
#if GR_GL_PER_GL_FUNC_CALLBACK
|
|
|
|
GrGLInterfaceCallbackProc fCallback;
|
|
|
|
GrGLInterfaceCallbackData fCallbackData;
|
|
|
|
#endif
|
|
|
|
|
2011-05-04 12:35:39 +00:00
|
|
|
private:
|
|
|
|
bool validateShaderFunctions() const;
|
|
|
|
bool validateFixedFunctions() const;
|
|
|
|
};
|
2011-03-14 21:23:01 +00:00
|
|
|
|
|
|
|
#endif
|