@@ -72,9 +72,6 @@ vgl.texture = function () {
7272 this . updateDimensions ( ) ;
7373 this . computeInternalFormatUsingImage ( ) ;
7474
75- // console.log('m_internalFormat ' + this.m_internalFormat);
76- // console.log('m_pixelFormat ' + this.m_pixelFormat);
77- // console.log('m_pixelDataType ' + this.m_pixelDataType);
7875
7976 // FOR now support only 2D textures
8077 renderState . m_context . texImage2D ( vgl . GL . TEXTURE_2D , 0 , this . m_internalFormat ,
@@ -160,6 +157,16 @@ vgl.texture = function () {
160157 this . setTexture = function ( texture ) {
161158 if ( texture !== null ) {
162159 this . m_texture = texture ;
160+ if ( texture . type === 'Luminance' ) {
161+ this . m_internalFormat = vgl . GL . LUMINANCE ;
162+ this . m_pixelFormat = vgl . GL . LUMINANCE ;
163+ } else if ( texture . type === 'LuminanceAlpha' ) {
164+ this . m_internalFormat = vgl . GL . LUMINANCE_ALPHA ;
165+ this . m_pixelFormat = vgl . GL . LUMINANCE_ALPHA ;
166+ } else {
167+ this . m_internalFormat = vgl . GL . RGBA ;
168+ this . m_pixelFormat = vgl . GL . RGBA ;
169+ }
163170 this . updateDimensions ( ) ;
164171 this . modified ( ) ;
165172 return true ;
@@ -243,9 +250,11 @@ vgl.texture = function () {
243250 // };
244251
245252 // TODO Fix this
246- this . m_internalFormat = vgl . GL . RGBA ;
247- this . m_pixelFormat = vgl . GL . RGBA ;
248- this . m_pixelDataType = vgl . GL . UNSIGNED_BYTE ;
253+ if ( ! this . m_internalFormat || ! this . m_pixelFormat || ! this . m_pixelDataType ) {
254+ this . m_internalFormat = vgl . GL . RGBA ;
255+ this . m_pixelFormat = vgl . GL . RGBA ;
256+ this . m_pixelDataType = vgl . GL . UNSIGNED_BYTE ;
257+ }
249258 } ;
250259
251260 /**
0 commit comments