webgl-framework
Advanced tools
Comparing version 2.3.0 to 2.3.1
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DiffuseShader = exports.CombinedAnimation = exports.TextureUtils = exports.FrameBuffer = exports.BaseRenderer = exports.BaseShader = exports.FullModel = exports.UncompressedTextureLoader = exports.CompressedTextureLoader = exports.BinaryDataLoader = exports.FullScreenUtils = void 0; | ||
exports.DiffuseShader = exports.CombinedAnimation = exports.TextureUtils = exports.MsaaFrameBuffer = exports.FrameBuffer = exports.BaseRenderer = exports.BaseShader = exports.FullModel = exports.UncompressedTextureLoader = exports.CompressedTextureLoader = exports.BinaryDataLoader = exports.FullScreenUtils = void 0; | ||
var FullScreenUtils_1 = require("./utils/FullScreenUtils"); | ||
@@ -20,2 +20,4 @@ Object.defineProperty(exports, "FullScreenUtils", { enumerable: true, get: function () { return FullScreenUtils_1.FullScreenUtils; } }); | ||
Object.defineProperty(exports, "FrameBuffer", { enumerable: true, get: function () { return FrameBuffer_1.FrameBuffer; } }); | ||
var MsaaFramebuffer_1 = require("./MsaaFramebuffer"); | ||
Object.defineProperty(exports, "MsaaFrameBuffer", { enumerable: true, get: function () { return MsaaFramebuffer_1.MsaaFrameBuffer; } }); | ||
var TextureUtils_1 = require("./TextureUtils"); | ||
@@ -22,0 +24,0 @@ Object.defineProperty(exports, "TextureUtils", { enumerable: true, get: function () { return TextureUtils_1.TextureUtils; } }); |
@@ -9,4 +9,5 @@ export { FullScreenUtils } from "./utils/FullScreenUtils"; | ||
export { FrameBuffer } from "./FrameBuffer"; | ||
export { MsaaFrameBuffer } from "./MsaaFramebuffer"; | ||
export { TextureUtils } from "./TextureUtils"; | ||
export { CombinedAnimation } from "./CombinedAnimation"; | ||
export { DiffuseShader } from "./shaders/DiffuseShader"; |
@@ -1656,2 +1656,121 @@ class FullScreenUtils { | ||
class MsaaFrameBuffer { | ||
/** Constructor. */ | ||
constructor(gl) { | ||
this.gl = gl; | ||
this.m_textureHandle = null; | ||
this.m_depthTextureHandle = null; | ||
this.m_framebufferHandle = null; | ||
this.m_framebufferMsaaHandle = null; | ||
this.m_depthBufferHandle = null; | ||
this.m_depthBufferMsaaHandle = null; | ||
this.m_colorBufferHandle = null; | ||
} | ||
/** Creates OpenGL objects */ | ||
createGLData(width, height) { | ||
this.m_width = width; | ||
this.m_height = height; | ||
if (this.m_textureHandle !== null && this.m_width > 0 && this.m_height > 0) { | ||
this.m_framebufferHandle = this.gl.createFramebuffer(); // alternative to GLES20.glGenFramebuffers() | ||
if (this.m_textureHandle !== null) { | ||
this.gl.bindTexture(this.gl.TEXTURE_2D, this.m_textureHandle); | ||
this.gl.bindFramebuffer(this.gl.FRAMEBUFFER, this.m_framebufferHandle); | ||
this.gl.framebufferTexture2D(this.gl.FRAMEBUFFER, this.gl.COLOR_ATTACHMENT0, this.gl.TEXTURE_2D, this.m_textureHandle, 0); | ||
this.checkGlError("FB"); | ||
} | ||
if (this.m_depthTextureHandle === null) { | ||
this.m_depthBufferHandle = this.gl.createRenderbuffer(); | ||
this.gl.bindRenderbuffer(this.gl.RENDERBUFFER, this.m_depthBufferHandle); | ||
this.checkGlError("FB - glBindRenderbuffer"); | ||
this.gl.renderbufferStorage(this.gl.RENDERBUFFER, this.gl.DEPTH_COMPONENT16, this.m_width, this.m_height); | ||
// this.gl.renderbufferStorageMultisample(this.gl.RENDERBUFFER, 4, this.gl.DEPTH_COMPONENT16, this.m_width, this.m_height); | ||
this.checkGlError("FB - glRenderbufferStorage"); | ||
// this.gl.framebufferRenderbuffer(this.gl.FRAMEBUFFER, this.gl.DEPTH_ATTACHMENT, this.gl.RENDERBUFFER, this.m_depthbufferHandle); | ||
this.gl.framebufferRenderbuffer(this.gl.FRAMEBUFFER, this.gl.DEPTH_ATTACHMENT, this.gl.RENDERBUFFER, this.m_depthBufferHandle); | ||
this.checkGlError("FB - glFramebufferRenderbuffer"); | ||
} | ||
else { | ||
this.gl.bindTexture(this.gl.TEXTURE_2D, this.m_depthTextureHandle); | ||
this.gl.bindFramebuffer(this.gl.FRAMEBUFFER, this.m_framebufferHandle); | ||
this.gl.framebufferTexture2D(this.gl.FRAMEBUFFER, this.gl.DEPTH_ATTACHMENT, this.gl.TEXTURE_2D, this.m_depthTextureHandle, 0); | ||
this.checkGlError("FB depth"); | ||
} | ||
const result = this.gl.checkFramebufferStatus(this.gl.FRAMEBUFFER); | ||
if (result != this.gl.FRAMEBUFFER_COMPLETE) { | ||
console.error(`Error creating framebufer: ${result}`); | ||
} | ||
this.gl.bindRenderbuffer(this.gl.RENDERBUFFER, null); | ||
// this.gl.bindTexture(this.gl.TEXTURE_2D, 0); | ||
this.gl.bindFramebuffer(this.gl.FRAMEBUFFER, null); | ||
this.m_depthBufferMsaaHandle = this.gl.createRenderbuffer(); | ||
this.m_framebufferMsaaHandle = this.gl.createFramebuffer(); // alternative to GLES20.glGenFramebuffers() | ||
this.gl.bindFramebuffer(this.gl.FRAMEBUFFER, this.m_framebufferMsaaHandle); | ||
this.m_colorBufferHandle = this.gl.createRenderbuffer(); | ||
this.gl.bindRenderbuffer(this.gl.RENDERBUFFER, this.m_colorBufferHandle); | ||
this.gl.renderbufferStorageMultisample(this.gl.RENDERBUFFER, 4, this.gl.RGB8, this.m_width, this.m_height); | ||
this.gl.framebufferRenderbuffer(this.gl.FRAMEBUFFER, this.gl.COLOR_ATTACHMENT0, this.gl.RENDERBUFFER, this.m_colorBufferHandle); | ||
this.gl.bindRenderbuffer(this.gl.RENDERBUFFER, this.m_depthBufferMsaaHandle); | ||
// this.gl.renderbufferStorage(this.gl.RENDERBUFFER, this.gl.DEPTH_COMPONENT16, this.m_width, this.m_height); | ||
this.gl.renderbufferStorageMultisample(this.gl.RENDERBUFFER, 4, this.gl.DEPTH_COMPONENT16, this.m_width, this.m_height); | ||
this.checkGlError("FB - glRenderbufferStorage"); | ||
this.gl.framebufferRenderbuffer(this.gl.FRAMEBUFFER, this.gl.DEPTH_ATTACHMENT, this.gl.RENDERBUFFER, this.m_depthBufferMsaaHandle); | ||
const result2 = this.gl.checkFramebufferStatus(this.gl.FRAMEBUFFER); | ||
if (result2 != this.gl.FRAMEBUFFER_COMPLETE) { | ||
console.error(`Error creating MSAA framebufer: ${result2}`); | ||
} | ||
this.gl.bindRenderbuffer(this.gl.RENDERBUFFER, null); | ||
// this.gl.bindTexture(this.gl.TEXTURE_2D, 0); | ||
this.gl.bindFramebuffer(this.gl.FRAMEBUFFER, null); | ||
} | ||
} | ||
checkGlError(op) { | ||
let error; | ||
while ((error = this.gl.getError()) !== this.gl.NO_ERROR) { | ||
console.error(`${op}: glError ${error}`); | ||
} | ||
} | ||
get width() { | ||
return this.m_width; | ||
} | ||
set width(value) { | ||
this.m_width = value; | ||
} | ||
get height() { | ||
return this.m_height; | ||
} | ||
set height(value) { | ||
this.m_height = value; | ||
} | ||
get textureHandle() { | ||
return this.m_textureHandle; | ||
} | ||
set textureHandle(value) { | ||
this.m_textureHandle = value; | ||
} | ||
get depthbufferHandle() { | ||
return this.m_depthBufferHandle; | ||
} | ||
set depthbufferHandle(value) { | ||
this.m_depthBufferHandle = value; | ||
} | ||
get framebufferHandle() { | ||
return this.m_framebufferHandle; | ||
} | ||
set framebufferHandle(value) { | ||
this.m_framebufferHandle = value; | ||
} | ||
get depthTextureHandle() { | ||
return this.m_depthTextureHandle; | ||
} | ||
set depthTextureHandle(value) { | ||
this.m_depthTextureHandle = value; | ||
} | ||
get colorBufferHandle() { | ||
return this.m_colorBufferHandle; | ||
} | ||
get framebufferMsaaHandle() { | ||
return this.m_framebufferMsaaHandle; | ||
} | ||
} | ||
/** Utilities to create various textures. */ | ||
@@ -1799,3 +1918,3 @@ class TextureUtils { | ||
export { FullScreenUtils, BinaryDataLoader, CompressedTextureLoader, UncompressedTextureLoader, FullModel, BaseShader, BaseRenderer, FrameBuffer, TextureUtils, CombinedAnimation, DiffuseShader }; | ||
export { FullScreenUtils, BinaryDataLoader, CompressedTextureLoader, UncompressedTextureLoader, FullModel, BaseShader, BaseRenderer, FrameBuffer, MsaaFrameBuffer, TextureUtils, CombinedAnimation, DiffuseShader }; | ||
//# sourceMappingURL=webgl-framework.es6.js.map |
{ | ||
"name": "webgl-framework", | ||
"version": "2.3.0", | ||
"version": "2.3.1", | ||
"description": "Basic low-level WebGL framework", | ||
@@ -5,0 +5,0 @@ "author": "Oleksandr Popov (github.com/keaukraine/)", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
720244
5143