program.h (1129B)
1 /* Copyright 2013 Brian Swetland <swetland@frotz.net> 2 * 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef _PROGRAM_H_ 17 #define _PROGRAM_H_ 18 19 class Program { 20 GLuint pobj, vobj, fobj; 21 const char *vsrc, *fsrc; 22 int status; 23 24 public: 25 Program(); 26 27 int compile(const char *vfn, const char *ffn); 28 int compileStr(const char *vsc, const char *fsc); 29 30 int ready() { return status == 0; } 31 32 void use(void) { 33 glUseProgram(pobj); 34 } 35 unsigned getAttribID(const char *name) { 36 return glGetAttribLocation(pobj, name); 37 } 38 unsigned getUniformID(const char *name) { 39 return glGetUniformLocation(pobj, name); 40 } 41 }; 42 43 #endif