Explorar el Código

webgl tweaks

- export getBuffer
- add glEnumToString helper
Alexander Rose hace 1 año
padre
commit
f264e4d6b8
Se han modificado 2 ficheros con 11 adiciones y 1 borrados
  1. 1 1
      src/mol-gl/webgl/buffer.ts
  2. 10 0
      src/mol-gl/webgl/context.ts

+ 1 - 1
src/mol-gl/webgl/buffer.ts

@@ -102,7 +102,7 @@ export interface Buffer {
     destroy: () => void
     destroy: () => void
 }
 }
 
 
-function getBuffer(gl: GLRenderingContext) {
+export function getBuffer(gl: GLRenderingContext) {
     const buffer = gl.createBuffer();
     const buffer = gl.createBuffer();
     if (buffer === null) {
     if (buffer === null) {
         throw new Error('Could not create WebGL buffer');
         throw new Error('Could not create WebGL buffer');

+ 10 - 0
src/mol-gl/webgl/context.ts

@@ -52,6 +52,16 @@ export function checkError(gl: GLRenderingContext) {
     }
     }
 }
 }
 
 
+export function glEnumToString(gl: GLRenderingContext, value: number) {
+    const keys: string[] = [];
+    for (const key in gl) {
+        if ((gl as any)[key] === value) {
+            keys.push(key);
+        }
+    }
+    return keys.length ? keys.join(' | ') : `0x${value.toString(16)}`;
+}
+
 function unbindResources(gl: GLRenderingContext) {
 function unbindResources(gl: GLRenderingContext) {
     // bind null to all texture units
     // bind null to all texture units
     const maxTextureImageUnits = gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS);
     const maxTextureImageUnits = gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS);