============================================================================== }
+{ enable OpenGL ES 1.1 Core functions }
+{$DEFINE OPENGLES_CORE_1_1}
+
+{ enable OpenGL ES 2.0 Core functions }
+{$DEFINE OPENGLES_CORE_2_0}
+
+{ enable OpenGL ES 3.0 Core functions }
+{$DEFINE OPENGLES_CORE_3_0}
+
+{ enable OpenGL ES 3.1 Core functions }
+{$DEFINE OPENGLES_CORE_3_1}
+
+{ enable all OpenGL ES extensions }
+{$DEFINE OPENGLES_EXTENSIONS}
+
unit dglOpenGLES;
interface
TGLvectorp3 = array[0..2] of PGLvoid;
TGLvectorp4 = array[0..3] of PGLvoid;
+{$IFDEF OPENGLES_CORE_1_1}
const
-{ ============================================== OpenGL ES 1.0 ======================================================= }
+{ ============================================== OpenGL ES 1.1 ======================================================= }
{ ClearBufferMask }
GL_DEPTH_BUFFER_BIT = $00000100;
GL_STENCIL_BUFFER_BIT = $00000400;
GL_DOT3_RGB = $86AE;
GL_DOT3_RGBA = $86AF;
+{$ENDIF}
+{$IFDEF OPENGLES_CORE_2_0}
+const
{ ============================================== OpenGL ES 2.0 ======================================================= }
{ BlendEquationSeparate }
GL_FUNC_ADD = $8006;
GL_MAX_RENDERBUFFER_SIZE = $84E8;
GL_INVALID_FRAMEBUFFER_OPERATION = $0506;
+{$ENDIF}
+{$IFDEF OPENGLES_CORE_3_0}
+const
{ ============================================== OpenGL ES 3.0 ======================================================= }
GL_READ_BUFFER = $0C02;
GL_UNPACK_ROW_LENGTH = $0CF2;
GL_MAX_ELEMENT_INDEX = $8D6B;
GL_NUM_SAMPLE_COUNTS = $9380;
GL_TEXTURE_IMMUTABLE_LEVELS = $82DF;
+{$ENDIF}
+{$IFDEF OPENGLES_CORE_3_1}
+const
{ ============================================== OpenGL ES 3.1 ======================================================= }
GL_COMPUTE_SHADER = $91B9;
GL_MAX_COMPUTE_UNIFORM_BLOCKS = $91BB;
GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET = $82D9;
GL_MAX_VERTEX_ATTRIB_BINDINGS = $82DA;
GL_MAX_VERTEX_ATTRIB_STRIDE = $82E5;
+{$ENDIF}
+{$IFDEF OPENGLES_CORE_1_1}
type
-{ ============================================== OpenGL ES 1.0 ======================================================= }
+{ ============================================== OpenGL ES 1.1 ======================================================= }
{ Available only in Common profile }
TglAlphaFunc = procedure(aFunc: GLenum; aRef: GLclampf); {$IFDEF DGL_WIN}stdcall;{$ELSE}cdecl;{$ENDIF}
TglClearColor = procedure(aRed: GLclampf; aGreen: GLclampf; aBlue: GLclampf; aAlpha: GLclampf); {$IFDEF DGL_WIN}stdcall;{$ELSE}cdecl;{$ENDIF}
TglTranslatex = procedure(x: GLfixed; y: GLfixed; z: GLfixed); {$IFDEF DGL_WIN}stdcall;{$ELSE}cdecl;{$ENDIF}
TglVertexPointer = procedure(aSize: GLint; aType: GLenum; aStride: GLsizei; const aPointer: PGLvoid); {$IFDEF DGL_WIN}stdcall;{$ELSE}cdecl;{$ENDIF}
TglViewport = procedure(x: GLint; y: GLint; aWidth: GLsizei; aHeight: GLsizei); {$IFDEF DGL_WIN}stdcall;{$ELSE}cdecl;{$ENDIF}
+{$ENDIF}
+{$IFDEF OPENGLES_CORE_2_0}
+type
{ ============================================== OpenGL ES 2.0 ======================================================= }
TglAttachShader = procedure(aProgram: GLuint; aShader: GLuint); {$IFDEF DGL_WIN}stdcall;{$ELSE}cdecl;{$ENDIF}
TglBindAttribLocation = procedure(aProgram: GLuint; aIndex: GLuint; const aName: PGLchar); {$IFDEF DGL_WIN}stdcall;{$ELSE}cdecl;{$ENDIF}
TglVertexAttrib4f = procedure(aIndex: GLuint; x: GLfloat; y: GLfloat; z: GLfloat; w: GLfloat); {$IFDEF DGL_WIN}stdcall;{$ELSE}cdecl;{$ENDIF}
TglVertexAttrib4fv = procedure(aIndex: GLuint; const aValues: PGLfloat); {$IFDEF DGL_WIN}stdcall;{$ELSE}cdecl;{$ENDIF}
TglVertexAttribPointer = procedure(aIndex: GLuint; aSize: GLint; aType: GLenum; aNormalized: GLboolean; aStride: GLsizei; const aPtr: PGLvoid); {$IFDEF DGL_WIN}stdcall;{$ELSE}cdecl;{$ENDIF}
+{$ENDIF}
+{$IFDEF OPENGLES_CORE_3_0}
+type
{ ============================================== OpenGL ES 3.0 ======================================================= }
TglReadBuffer = procedure(aSrc: GLenum); {$IFDEF DGL_WIN}stdcall;{$ELSE}cdecl;{$ENDIF}
TglDrawRangeElements = procedure(aMode: GLenum; aStart: GLuint; aEnd: GLuint; aCount: GLsizei; aType: GLenum; const aIndices: PGLvoid); {$IFDEF DGL_WIN}stdcall;{$ELSE}cdecl;{$ENDIF}
TglTexStorage2D = procedure(aTarget: GLenum; aLevels: GLsizei; aInternalformat: GLenum; aWidth: GLsizei; aHeight: GLsizei); {$IFDEF DGL_WIN}stdcall;{$ELSE}cdecl;{$ENDIF}
TglTexStorage3D = procedure(aTarget: GLenum; aLevels: GLsizei; aInternalformat: GLenum; aWidth: GLsizei; aHeight: GLsizei; aDepth: GLsizei); {$IFDEF DGL_WIN}stdcall;{$ELSE}cdecl;{$ENDIF}
TglGetInternalformativ = procedure(aTarget: GLenum; aInternalformat: GLenum; aPname: GLenum; aBufSize: GLsizei; aParams: PGLint); {$IFDEF DGL_WIN}stdcall;{$ELSE}cdecl;{$ENDIF}
+{$ENDIF}
+{$IFDEF OPENGLES_CORE_3_1}
+type
{ ============================================== OpenGL ES 3.1 ======================================================= }
TglDispatchCompute = procedure(aNumGroupsX: GLuint; aNumGroupsY: GLuint; aNumGroupsZ: GLuint); {$IFDEF DGL_WIN}stdcall;{$ELSE}cdecl;{$ENDIF}
TglDispatchComputeIndirect = procedure(aIndirect: GLintptr); {$IFDEF DGL_WIN}stdcall;{$ELSE}cdecl;{$ENDIF}
TglVertexAttribIFormat = procedure(aAttribindex: GLuint; aSize: GLint; aType: GLenum; aRelativeoffset: GLuint); {$IFDEF DGL_WIN}stdcall;{$ELSE}cdecl;{$ENDIF}
TglVertexAttribBinding = procedure(aAttribindex: GLuint; aBindingindex: GLuint); {$IFDEF DGL_WIN}stdcall;{$ELSE}cdecl;{$ENDIF}
TglVertexBindingDivisor = procedure(aBindingindex: GLuint; aDivisor: GLuint); {$IFDEF DGL_WIN}stdcall;{$ELSE}cdecl;{$ENDIF}
+{$ENDIF}
+{$IFDEF OPENGLES_CORE_1_1}
var
-{ ============================================== OpenGL ES 1.0 ======================================================= }
+{ ============================================== OpenGL ES 1.1 ======================================================= }
{ Available only in Common profile }
glAlphaFunc: TglAlphaFunc;
glClearColor: TglClearColor;
glTranslatex: TglTranslatex;
glVertexPointer: TglVertexPointer;
glViewport: TglViewport;
+{$ENDIF}
+{$IFDEF OPENGLES_CORE_2_0}
+var
{ ============================================== OpenGL ES 2.0 ======================================================= }
glAttachShader: TglAttachShader;
glBindAttribLocation: TglBindAttribLocation;
glVertexAttrib4f: TglVertexAttrib4f;
glVertexAttrib4fv: TglVertexAttrib4fv;
glVertexAttribPointer: TglVertexAttribPointer;
+{$ENDIF}
+{$IFDEF OPENGLES_CORE_3_0}
{ ============================================== OpenGL ES 3.0 ======================================================= }
+var
glReadBuffer: TglReadBuffer;
glDrawRangeElements: TglDrawRangeElements;
glTexImage3D: TglTexImage3D;
glTexStorage2D: TglTexStorage2D;
glTexStorage3D: TglTexStorage3D;
glGetInternalformativ: TglGetInternalformativ;
+{$ENDIF}
+{$IFDEF OPENGLES_CORE_3_1}
{ ============================================== OpenGL ES 3.1 ======================================================= }
+var
glDispatchCompute: TglDispatchCompute;
glDispatchComputeIndirect: TglDispatchComputeIndirect;
glDrawArraysIndirect: TglDrawArraysIndirect;
glVertexAttribIFormat: TglVertexAttribIFormat;
glVertexAttribBinding: TglVertexAttribBinding;
glVertexBindingDivisor: TglVertexBindingDivisor;
+{$ENDIF}
+{$IFDEF OPENGLES_EXTENSIONS}
{ =============================================== Extensions ========================================================= }
{ GL_KHR_blend_equation_advanced }
const
glIsVertexArrayOES: TglIsVertexArrayOES;
{ GL_OES_vertex_half_float }
- // none
+ // none {$IFDEF OPENGLES_EXTENSIONS}
{ GL_OES_vertex_type_10_10_10_2 }
const
{ GL_VIV_shader_binary }
const
GL_SHADER_BINARY_VIV = $8FC4;
+{$ENDIF}
{ ================================================== EGL ============================================================= }
type
GL_VERSION_1_1,
GL_VERSION_2_0,
GL_VERSION_3_0,
- GL_VERSION_3_1,
+ GL_VERSION_3_1
+{$IFDEF OPENGLES_EXTENSIONS},
GL_KHR_blend_equation_advanced,
GL_KHR_blend_equation_advanced_coherent,
GL_KHR_context_flush_control,
GL_QCOM_perfmon_global_mode,
GL_QCOM_tiled_rendering,
GL_QCOM_writeonly_rendering,
- GL_VIV_shader_binary: Boolean;
+ GL_VIV_shader_binary
+{$ENDIF}
+ : Boolean;
type
EdglOpenGLES = class(Exception);
procedure ReadCoreVersion;
procedure ReadImplementationProperties;
+{$IFDEF OPENGLES_EXTENSIONS}
procedure Read_GL_KHR_blend_equation_advanced;
procedure Read_GL_KHR_debug;
procedure Read_GL_KHR_robustness;
procedure Read_GL_QCOM_extended_get;
procedure Read_GL_QCOM_extended_get2;
procedure Read_GL_QCOM_tiled_rendering;
+{$ENDIF}
implementation
procedure ReadOpenGLCore;
begin
- { ============================================= OpenGL ES 1.0 ====================================================== }
+{$IFDEF OPENGLES_CORE_1_1}
+ { ============================================= OpenGL ES 1.1 ====================================================== }
{ Available only in Common profile }
glAlphaFunc := dglGetProcAddress('glAlphaFunc');
glClearColor := dglGetProcAddress('glClearColor');
glTranslatex := dglGetProcAddress('glTranslatex');
glVertexPointer := dglGetProcAddress('glVertexPointer');
glViewport := dglGetProcAddress('glViewport');
+{$ENDIF}
+{$IFDEF OPENGLES_CORE_2_0}
{ ============================================= OpenGL ES 2.0 ====================================================== }
glAttachShader := dglGetProcAddress('glAttachShader');
glBindAttribLocation := dglGetProcAddress('glBindAttribLocation');
glVertexAttrib4f := dglGetProcAddress('glVertexAttrib4f');
glVertexAttrib4fv := dglGetProcAddress('glVertexAttrib4fv');
glVertexAttribPointer := dglGetProcAddress('glVertexAttribPointer');
+{$ENDIF}
+{$IFDEF OPENGLES_CORE_3_0}
{ ============================================= OpenGL ES 3.0 ====================================================== }
glReadBuffer := dglGetProcAddress('glReadBuffer');
glDrawRangeElements := dglGetProcAddress('glDrawRangeElements');
glTexStorage2D := dglGetProcAddress('glTexStorage2D');
glTexStorage3D := dglGetProcAddress('glTexStorage3D');
glGetInternalformativ := dglGetProcAddress('glGetInternalformativ');
+{$ENDIF}
+{$IFDEF OPENGLES_CORE_3_1}
{ ============================================= OpenGL ES 3.1 ====================================================== }
glDispatchCompute := dglGetProcAddress('glDispatchCompute');
glDispatchComputeIndirect := dglGetProcAddress('glDispatchComputeIndirect');
glVertexAttribIFormat := dglGetProcAddress('glVertexAttribIFormat');
glVertexAttribBinding := dglGetProcAddress('glVertexAttribBinding');
glVertexBindingDivisor := dglGetProcAddress('glVertexBindingDivisor');
+{$ENDIF}
end;
procedure ReadExtensions;
begin
+{$IFDEF OPENGLES_EXTENSIONS}
Read_GL_KHR_blend_equation_advanced;
Read_GL_KHR_debug;
Read_GL_KHR_robustness;
Read_GL_QCOM_extended_get;
Read_GL_QCOM_extended_get2;
Read_GL_QCOM_tiled_rendering;
+{$ENDIF}
end;
procedure ReadCoreVersion;
GL_VERSION_3_1 := (GLmajor >= 3) and (GLminor >= 1);
end;
+{$IFDEF OPENGLES_EXTENSIONS}
procedure ReadImplementationProperties;
function GetExtensions: String;
if Assigned(glGetString) then
result := String(PAnsiChar(glGetString(GL_EXTENSIONS)));
+{$IFDEF OPENGLES_CORE_3_0}
if (result = '') then begin
if not Assigned(glGetIntegerv) then
glGetIntegerv := dglGetProcAddress('glGetIntegerv');
end;
end;
end;
+{$ENDIF}
result := #$20 + result + #$20;
end;
// VIV
GL_VIV_shader_binary := CheckEx(Buffer, 'GL_VIV_shader_binary');
end;
+{$ELSE}
+procedure ReadImplementationProperties;
+begin
+ // nothing to do here
+end;
+{$ENDIF}
+{$IFDEF OPENGLES_EXTENSIONS}
procedure Read_GL_KHR_blend_equation_advanced;
begin
glBlendBarrierKHR := dglGetProcAddress('glBlendBarrierKHR');
glStartTilingQCOM := dglGetProcAddress('glStartTilingQCOM');
glEndTilingQCOM := dglGetProcAddress('glEndTilingQCOM');
end;
+{$ENDIF}
constructor EeglError.Create(const msg: string; const aErrorCode: EGLint);
begin