michael@0: michael@0: /* michael@0: * Copyright 2012 Google Inc. michael@0: * michael@0: * Use of this source code is governed by a BSD-style license that can be michael@0: * found in the LICENSE file. michael@0: */ michael@0: michael@0: michael@0: #include "gl/GrGLInterface.h" michael@0: michael@0: #ifndef GL_GLEXT_PROTOTYPES michael@0: #define GL_GLEXT_PROTOTYPES michael@0: #endif michael@0: michael@0: #include "GLES2/gl2.h" michael@0: #include "GLES2/gl2ext.h" michael@0: #include "EGL/egl.h" michael@0: michael@0: #define GET_PROC(name) \ michael@0: interface->fFunctions.f ## name = (GrGL ## name ## Proc) GetProcAddress(ghANGLELib, "gl" #name); michael@0: michael@0: const GrGLInterface* GrGLCreateANGLEInterface() { michael@0: michael@0: static HMODULE ghANGLELib = NULL; michael@0: michael@0: if (NULL == ghANGLELib) { michael@0: // We load the ANGLE library and never let it go michael@0: ghANGLELib = LoadLibrary("libGLESv2.dll"); michael@0: } michael@0: if (NULL == ghANGLELib) { michael@0: // We can't setup the interface correctly w/o the DLL michael@0: return NULL; michael@0: } michael@0: michael@0: GrGLInterface* interface = SkNEW(GrGLInterface); michael@0: interface->fStandard = kGLES_GrGLStandard; michael@0: michael@0: GrGLInterface::Functions* functions = &interface->fFunctions; michael@0: michael@0: GET_PROC(ActiveTexture); michael@0: GET_PROC(AttachShader); michael@0: GET_PROC(BindAttribLocation); michael@0: GET_PROC(BindBuffer); michael@0: GET_PROC(BindTexture); michael@0: functions->fBindVertexArray = michael@0: (GrGLBindVertexArrayProc) eglGetProcAddress("glBindVertexArrayOES"); michael@0: GET_PROC(BlendColor); michael@0: GET_PROC(BlendFunc); michael@0: GET_PROC(BufferData); michael@0: GET_PROC(BufferSubData); michael@0: GET_PROC(Clear); michael@0: GET_PROC(ClearColor); michael@0: GET_PROC(ClearStencil); michael@0: GET_PROC(ColorMask); michael@0: GET_PROC(CompileShader); michael@0: GET_PROC(CompressedTexImage2D); michael@0: GET_PROC(CopyTexSubImage2D); michael@0: GET_PROC(CreateProgram); michael@0: GET_PROC(CreateShader); michael@0: GET_PROC(CullFace); michael@0: GET_PROC(DeleteBuffers); michael@0: GET_PROC(DeleteProgram); michael@0: GET_PROC(DeleteShader); michael@0: GET_PROC(DeleteTextures); michael@0: functions->fDeleteVertexArrays = michael@0: (GrGLDeleteVertexArraysProc) eglGetProcAddress("glDeleteVertexArraysOES"); michael@0: GET_PROC(DepthMask); michael@0: GET_PROC(Disable); michael@0: GET_PROC(DisableVertexAttribArray); michael@0: GET_PROC(DrawArrays); michael@0: GET_PROC(DrawElements); michael@0: GET_PROC(Enable); michael@0: GET_PROC(EnableVertexAttribArray); michael@0: GET_PROC(Finish); michael@0: GET_PROC(Flush); michael@0: GET_PROC(FrontFace); michael@0: GET_PROC(GenBuffers); michael@0: GET_PROC(GenerateMipmap); michael@0: GET_PROC(GenTextures); michael@0: functions->fGenVertexArrays = michael@0: (GrGLGenVertexArraysProc) eglGetProcAddress("glGenVertexArraysOES"); michael@0: GET_PROC(GetBufferParameteriv); michael@0: GET_PROC(GetError); michael@0: GET_PROC(GetIntegerv); michael@0: GET_PROC(GetProgramInfoLog); michael@0: GET_PROC(GetProgramiv); michael@0: GET_PROC(GetShaderInfoLog); michael@0: GET_PROC(GetShaderiv); michael@0: GET_PROC(GetString); michael@0: GET_PROC(GetUniformLocation); michael@0: GET_PROC(LineWidth); michael@0: GET_PROC(LinkProgram); michael@0: GET_PROC(PixelStorei); michael@0: GET_PROC(ReadPixels); michael@0: GET_PROC(Scissor); michael@0: GET_PROC(ShaderSource); michael@0: GET_PROC(StencilFunc); michael@0: GET_PROC(StencilFuncSeparate); michael@0: GET_PROC(StencilMask); michael@0: GET_PROC(StencilMaskSeparate); michael@0: GET_PROC(StencilOp); michael@0: GET_PROC(StencilOpSeparate); michael@0: GET_PROC(TexImage2D); michael@0: GET_PROC(TexParameteri); michael@0: GET_PROC(TexParameteriv); michael@0: GET_PROC(TexSubImage2D); michael@0: #if GL_ARB_texture_storage michael@0: GET_PROC(TexStorage2D); michael@0: #elif GL_EXT_texture_storage michael@0: functions->fTexStorage2D = (GrGLTexStorage2DProc) eglGetProcAddress("glTexStorage2DEXT"); michael@0: #endif michael@0: GET_PROC(Uniform1f); michael@0: GET_PROC(Uniform1i); michael@0: GET_PROC(Uniform1fv); michael@0: GET_PROC(Uniform1iv); michael@0: michael@0: GET_PROC(Uniform2f); michael@0: GET_PROC(Uniform2i); michael@0: GET_PROC(Uniform2fv); michael@0: GET_PROC(Uniform2iv); michael@0: michael@0: GET_PROC(Uniform3f); michael@0: GET_PROC(Uniform3i); michael@0: GET_PROC(Uniform3fv); michael@0: GET_PROC(Uniform3iv); michael@0: michael@0: GET_PROC(Uniform4f); michael@0: GET_PROC(Uniform4i); michael@0: GET_PROC(Uniform4fv); michael@0: GET_PROC(Uniform4iv); michael@0: michael@0: GET_PROC(UniformMatrix2fv); michael@0: GET_PROC(UniformMatrix3fv); michael@0: GET_PROC(UniformMatrix4fv); michael@0: GET_PROC(UseProgram); michael@0: GET_PROC(VertexAttrib4fv); michael@0: GET_PROC(VertexAttribPointer); michael@0: GET_PROC(Viewport); michael@0: GET_PROC(BindFramebuffer); michael@0: GET_PROC(BindRenderbuffer); michael@0: GET_PROC(CheckFramebufferStatus); michael@0: GET_PROC(DeleteFramebuffers); michael@0: GET_PROC(DeleteRenderbuffers); michael@0: GET_PROC(FramebufferRenderbuffer); michael@0: GET_PROC(FramebufferTexture2D); michael@0: GET_PROC(GenFramebuffers); michael@0: GET_PROC(GenRenderbuffers); michael@0: GET_PROC(GetFramebufferAttachmentParameteriv); michael@0: GET_PROC(GetRenderbufferParameteriv); michael@0: GET_PROC(RenderbufferStorage); michael@0: michael@0: functions->fMapBuffer = (GrGLMapBufferProc) eglGetProcAddress("glMapBufferOES"); michael@0: functions->fUnmapBuffer = (GrGLUnmapBufferProc) eglGetProcAddress("glUnmapBufferOES"); michael@0: michael@0: #if GL_EXT_debug_marker michael@0: functions->fInsertEventMarker = (GrGLInsertEventMarkerProc) eglGetProcAddress("glInsertEventMarkerEXT"); michael@0: functions->fPushGroupMarker = (GrGLInsertEventMarkerProc) eglGetProcAddress("glPushGroupMarkerEXT"); michael@0: functions->fPopGroupMarker = (GrGLPopGroupMarkerProc) eglGetProcAddress("glPopGropuMarkerEXT"); michael@0: #endif michael@0: michael@0: interface->fExtensions.init(kGLES_GrGLStandard, michael@0: interface->fFunctions.fGetString, michael@0: interface->fFunctions.fGetStringi, michael@0: interface->fFunctions.fGetIntegerv); michael@0: return interface; michael@0: }