Home | History | Annotate | Download | only in libOpenglRender
      1 /*
      2 * Copyright (C) 2011 The Android Open Source Project
      3 *
      4 * Licensed under the Apache License, Version 2.0 (the "License");
      5 * you may not use this file except in compliance with the License.
      6 * You may obtain a copy of the License at
      7 *
      8 * http://www.apache.org/licenses/LICENSE-2.0
      9 *
     10 * Unless required by applicable law or agreed to in writing, software
     11 * distributed under the License is distributed on an "AS IS" BASIS,
     12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13 * See the License for the specific language governing permissions and
     14 * limitations under the License.
     15 */
     16 #ifdef WITH_GLES2
     17 #include "GL2Dispatch.h"
     18 #include <stdio.h>
     19 #include <stdlib.h>
     20 #include "osDynLibrary.h"
     21 
     22 gl2_decoder_context_t s_gl2;
     23 int                   s_gl2_enabled;
     24 
     25 static osUtils::dynLibrary *s_gles2_lib = NULL;
     26 
     27 #define DEFAULT_GLES_V2_LIB EMUGL_LIBNAME("GLES_V2_translator")
     28 
     29 //
     30 // This function is called only once during initialiation before
     31 // any thread has been created - hence it should NOT be thread safe.
     32 //
     33 bool init_gl2_dispatch()
     34 {
     35     const char *libName = getenv("ANDROID_GLESv2_LIB");
     36     if (!libName) libName = DEFAULT_GLES_V2_LIB;
     37 
     38     //
     39     // Load the GLES library
     40     //
     41     s_gles2_lib = osUtils::dynLibrary::open(libName);
     42     if (!s_gles2_lib) return false;
     43 
     44     //
     45     // init the GLES dispatch table
     46     //
     47     s_gl2.initDispatchByName( gl2_dispatch_get_proc_func, NULL );
     48     s_gl2_enabled = true;
     49     return true;
     50 }
     51 
     52 //
     53 // This function is called only during initialiation before
     54 // any thread has been created - hence it should NOT be thread safe.
     55 //
     56 void *gl2_dispatch_get_proc_func(const char *name, void *userData)
     57 {
     58     if (!s_gles2_lib) {
     59         return NULL;
     60     }
     61     return (void *)s_gles2_lib->findSymbol(name);
     62 }
     63 
     64 #endif
     65