// common.js // John Breaux 2022-06-30 // Common functions and global variables for Pendulum.js "use strict"; // // Global variables // // Point size of the anchor var POINT_SIZE = 5; // Radius of the bob var BOB_RADIUS = 0.1; // length of the wire var PEN_LENGTH = 0.8; // Rotation angle (degrees/second) var A_VELOCITY = 45.0; // Enable or disable real pendulum mode var REAL_PENDULUM_MODE = false; // // Common functions: // // acquire_buffer: Get a vertex buffer object from gl function acquire_buffer(gl) { // Create a buffer object var vertexBuffer = gl.createBuffer(); if (!vertexBuffer) { console.log('Failed to create the buffer object'); return -1; } return vertexBuffer; } function enable_attribute(gl, name, size, type) { // Acquire a reference to named attr var attr = gl.getAttribLocation(gl.program, name); if (attr < 0) { console.log(`Failed to get the storage location of ${name}`); return -1; } gl.vertexAttribPointer(attr, size, type, false, 0, 0); // Switch GL state machine to use named attr gl.enableVertexAttribArray(attr); } function acquire_uniform(gl, name) { // Acquire a reference to named attr var ret = gl.getUniformLocation(gl.program, name); if (!ret) { console.log(`Failed to get the storage location of ${name}`); return -1; } return ret; }