Skip to content

Commit b80a9c2

Browse files
committed
add Luminance and Luminance Alpha support to textures
1 parent 7bfe602 commit b80a9c2

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

src/quadFeature.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -441,14 +441,13 @@ var quadFeature = function (arg) {
441441
var textureImage = {
442442
width: d.texture.width,
443443
height: d.texture.height,
444+
type: d.texture.type || 'RGBA',
444445
data: d.texture.data
445446
};
446447
quad.imageTexture = textureImage; // Store as imageTexture for WebGL
447448
imgQuads.push(quad);
448449
quadinfo.imgquad = quad;
449-
}
450-
451-
if (img) {
450+
} else if (img) {
452451
quadinfo.imageEntry = img;
453452
/* Handle image quads */
454453
image = m_this._objectListGet(m_images, img);

src/vgl/texture.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)