From: Bergmann89 Date: Tue, 16 Dec 2014 17:35:36 +0000 (+0100) Subject: * added compiler defines to set used core version X-Git-Url: https://git.delphigl.com/?a=commitdiff_plain;h=refs%2Fheads%2Fmaster;p=dglOpenGLES.git * added compiler defines to set used core version --- diff --git a/dglOpenGLES.pas b/dglOpenGLES.pas index e625dde..c878f5a 100644 --- a/dglOpenGLES.pas +++ b/dglOpenGLES.pas @@ -35,6 +35,21 @@ ============================================================================== } +{ 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 @@ -141,8 +156,9 @@ type 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; @@ -641,7 +657,10 @@ const GL_DOT3_RGB = $86AE; GL_DOT3_RGBA = $86AF; +{$ENDIF} +{$IFDEF OPENGLES_CORE_2_0} +const { ============================================== OpenGL ES 2.0 ======================================================= } { BlendEquationSeparate } GL_FUNC_ADD = $8006; @@ -815,7 +834,10 @@ const 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; @@ -1122,7 +1144,10 @@ const 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; @@ -1296,9 +1321,11 @@ const 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} @@ -1446,7 +1473,10 @@ type 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} @@ -1532,7 +1562,10 @@ type 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} @@ -1638,7 +1671,10 @@ type 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} @@ -1708,9 +1744,11 @@ type 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; @@ -1858,7 +1896,10 @@ var glTranslatex: TglTranslatex; glVertexPointer: TglVertexPointer; glViewport: TglViewport; +{$ENDIF} +{$IFDEF OPENGLES_CORE_2_0} +var { ============================================== OpenGL ES 2.0 ======================================================= } glAttachShader: TglAttachShader; glBindAttribLocation: TglBindAttribLocation; @@ -1944,8 +1985,11 @@ var glVertexAttrib4f: TglVertexAttrib4f; glVertexAttrib4fv: TglVertexAttrib4fv; glVertexAttribPointer: TglVertexAttribPointer; +{$ENDIF} +{$IFDEF OPENGLES_CORE_3_0} { ============================================== OpenGL ES 3.0 ======================================================= } +var glReadBuffer: TglReadBuffer; glDrawRangeElements: TglDrawRangeElements; glTexImage3D: TglTexImage3D; @@ -2050,8 +2094,11 @@ var glTexStorage2D: TglTexStorage2D; glTexStorage3D: TglTexStorage3D; glGetInternalformativ: TglGetInternalformativ; +{$ENDIF} +{$IFDEF OPENGLES_CORE_3_1} { ============================================== OpenGL ES 3.1 ======================================================= } +var glDispatchCompute: TglDispatchCompute; glDispatchComputeIndirect: TglDispatchComputeIndirect; glDrawArraysIndirect: TglDrawArraysIndirect; @@ -2120,7 +2167,9 @@ var glVertexAttribIFormat: TglVertexAttribIFormat; glVertexAttribBinding: TglVertexAttribBinding; glVertexBindingDivisor: TglVertexBindingDivisor; +{$ENDIF} +{$IFDEF OPENGLES_EXTENSIONS} { =============================================== Extensions ========================================================= } { GL_KHR_blend_equation_advanced } const @@ -2520,7 +2569,7 @@ var glIsVertexArrayOES: TglIsVertexArrayOES; { GL_OES_vertex_half_float } - // none + // none {$IFDEF OPENGLES_EXTENSIONS} { GL_OES_vertex_type_10_10_10_2 } const @@ -4315,6 +4364,7 @@ const { GL_VIV_shader_binary } const GL_SHADER_BINARY_VIV = $8FC4; +{$ENDIF} { ================================================== EGL ============================================================= } type @@ -4603,7 +4653,8 @@ var 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, @@ -4781,7 +4832,9 @@ var 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); @@ -4821,6 +4874,7 @@ procedure ReadExtensions; procedure ReadCoreVersion; procedure ReadImplementationProperties; +{$IFDEF OPENGLES_EXTENSIONS} procedure Read_GL_KHR_blend_equation_advanced; procedure Read_GL_KHR_debug; procedure Read_GL_KHR_robustness; @@ -4887,6 +4941,7 @@ procedure Read_GL_QCOM_driver_control; procedure Read_GL_QCOM_extended_get; procedure Read_GL_QCOM_extended_get2; procedure Read_GL_QCOM_tiled_rendering; +{$ENDIF} implementation @@ -5061,7 +5116,8 @@ end; 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'); @@ -5209,7 +5265,9 @@ begin 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'); @@ -5295,7 +5353,9 @@ begin 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'); @@ -5401,7 +5461,9 @@ begin 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'); @@ -5471,10 +5533,12 @@ begin 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; @@ -5541,6 +5605,7 @@ begin Read_GL_QCOM_extended_get; Read_GL_QCOM_extended_get2; Read_GL_QCOM_tiled_rendering; +{$ENDIF} end; procedure ReadCoreVersion; @@ -5595,6 +5660,7 @@ begin GL_VERSION_3_1 := (GLmajor >= 3) and (GLminor >= 1); end; +{$IFDEF OPENGLES_EXTENSIONS} procedure ReadImplementationProperties; function GetExtensions: String; @@ -5608,6 +5674,7 @@ procedure ReadImplementationProperties; 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'); @@ -5622,6 +5689,7 @@ procedure ReadImplementationProperties; end; end; end; +{$ENDIF} result := #$20 + result + #$20; end; @@ -5846,7 +5914,14 @@ begin // 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'); @@ -6430,6 +6505,7 @@ begin glStartTilingQCOM := dglGetProcAddress('glStartTilingQCOM'); glEndTilingQCOM := dglGetProcAddress('glEndTilingQCOM'); end; +{$ENDIF} constructor EeglError.Create(const msg: string; const aErrorCode: EGLint); begin