1 /* 2 Copyright (c) 2008 Seneca College 3 Licenced under the MIT License (http://www.c3dl.org/index.php/mit-license/) 4 */ 5 6 /** 7 @class base class for OpenGLES20. 8 */ 9 c3dl.Renderer = function() 10 { 11 // use an invalid value which must be overwritten. 12 this.version = 0.0; 13 14 // a detailed description of the renderer 15 this.versionString = "Renderer interface."; 16 17 // by default we fill in the models, wireframe is mostly for debugging. 18 this.fillMode = c3dl.FILL; 19 20 this.lightingOn = true; 21 22 // these will be set by the derived renderer on initialization. 23 this.contextWidth = 0; 24 this.contextHeight = 0; 25 26 /** 27 */ 28 this.getLighting = function() 29 { 30 return this.lightingOn; 31 } 32 33 /** 34 Get the maximum line width supported which is implementation dependent. 35 36 @returns {int} maximum line width supported. 37 */ 38 this.getMaxLineWidth = function() 39 { 40 // derived classes must implement this function. 41 } 42 43 /** 44 Get the version of the renderer as a number. 45 46 @returns { 0.0 | 2.0 } A value of 0.0 is returned if the class was instantiated incorrectly. 47 */ 48 this.getVersion = function() 49 { 50 return this.version; 51 } 52 53 /** 54 Get the OpenGL ES Version string. 55 56 @returns {"Renderer interface" | "OpenGL ES 2.0"} "Renderer interface" is returned if the Renderer was not instantiated correctly. 57 */ 58 this.getVersionString = function() 59 { 60 return this.versionString; 61 } 62 63 64 /** 65 Are objects filled in or are they rendered using wireframe? 66 67 @returns {int} either c3dl.FILL or c3dl.WIRE_FRAME. 68 */ 69 this.getFillMode = function() 70 { 71 return this.fillMode; 72 } 73 74 /** 75 @private 76 Set the color the canvas will be cleared to each frame. 77 78 @param {Array} clearColor Array of 4 values in the order [r,g,b,a] which must 79 be in the range [0.0 - 1.0]. 80 */ 81 this.setClearColor = function(clearColor) 82 { 83 // derived classes must implement this function. 84 } 85 86 /** 87 Set how objects will be rendered, either filled in or using wireframe. 88 89 @param {c3dl.FILL | c3dl.WIRE_FRAME} mode 90 */ 91 this.setFillMode = function(mode) 92 { 93 if(mode == c3dl.FILL || mode == c3dl.WIRE_FRAME) 94 { 95 this.fillMode = mode; 96 } 97 else 98 { 99 c3dl.debug.logWarning('Invalid value "' + mode + '" passed to setFillMode()'); 100 } 101 } 102 103 /** 104 */ 105 this.setLighting = function(isOn) 106 { 107 this.lightingOn = isOn; 108 } 109 110 /** 111 */ 112 this.getContextWidth = function() 113 { 114 return this.contextWidth; 115 } 116 117 /** 118 */ 119 this.getContextHeight = function() 120 { 121 return this.contextHeight; 122 } 123 } 124