Skip to content

Commit 2e6d41f

Browse files
committed
Implemented compressedTexImage2d
1 parent aba745f commit 2e6d41f

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

plask_bindings.mm

+26
Original file line numberDiff line numberDiff line change
@@ -1173,6 +1173,7 @@ static void RewriteWebGLSLtoGLSL(char* p, int len) {
11731173
METHOD_ENTRY( stencilOpSeparate ),
11741174
METHOD_ENTRY( texImage2D ),
11751175
METHOD_ENTRY( texImage2DSkCanvasB ),
1176+
METHOD_ENTRY( compressedTexImage2D ),
11761177
METHOD_ENTRY( texParameterf ),
11771178
METHOD_ENTRY( texParameteri ),
11781179
METHOD_ENTRY( texSubImage2D ),
@@ -2774,6 +2775,31 @@ static void getVertexAttribOffset(
27742775
static void texImage2DSkCanvasB(const v8::FunctionCallbackInfo<v8::Value>& args);
27752776
static void drawSkCanvas(const v8::FunctionCallbackInfo<v8::Value>& args);
27762777

2778+
// void compressedTexImage2D(GLenum target, GLint level, GLenum internalformat,
2779+
// GLsizei width, GLsizei height, GLint border,
2780+
// ArrayBufferView data)
2781+
DEFINE_METHOD(compressedTexImage2D, 7)
2782+
GLvoid* data = NULL;
2783+
GLsizeiptr size = 0; // FIXME use size
2784+
2785+
if (!args[6]->IsNull()) {
2786+
// TODO(deanm): Check size / format. For now just use it correctly.
2787+
if (!GetTypedArrayBytes(args[6], &data, &size))
2788+
return v8_utils::ThrowError(isolate, "Data must be a TypedArray.");
2789+
}
2790+
2791+
// TODO(deanm): Support more than just the zero initialization case.
2792+
glCompressedTexImage2D(args[0]->Uint32Value(), // target
2793+
args[1]->Int32Value(), // level
2794+
args[2]->Int32Value(), // internalFormat
2795+
args[3]->Int32Value(), // width
2796+
args[4]->Int32Value(), // height
2797+
args[5]->Int32Value(), // border
2798+
size, // size
2799+
data); // data
2800+
return args.GetReturnValue().SetUndefined();
2801+
}
2802+
27772803
// void texParameterf(GLenum target, GLenum pname, GLfloat param)
27782804
DEFINE_METHOD(texParameterf, 3)
27792805
glTexParameterf(args[0]->Uint32Value(),

webgl_constants.h

+5
Original file line numberDiff line numberDiff line change
@@ -707,6 +707,11 @@ WEBGL_CONSTANTS_EACH(TEXTURE_IMMUTABLE_LEVELS, 0x82DF)
707707
WEBGL_CONSTANTS_EACH(UNSIGNED_INT_24_8_WEBGL, 0x84FA) // Same as GL_UNSIGNED_INT_24_8
708708
// OES_standard_derivatives
709709
WEBGL_CONSTANTS_EACH(FRAGMENT_SHADER_DERIVATIVE_HINT_OES, 0x8B8B) // Same as FRAGMENT_SHADER_DERIVATIVE_HINT
710+
//WEBGL_compressed_texture_s3tc
711+
WEBGL_CONSTANTS_EACH(COMPRESSED_RGB_S3TC_DXT1_EXT, 0x83F0)
712+
WEBGL_CONSTANTS_EACH(COMPRESSED_RGBA_S3TC_DXT1_EXT, 0x83F1)
713+
WEBGL_CONSTANTS_EACH(COMPRESSED_RGBA_S3TC_DXT3_EXT, 0x83F2)
714+
WEBGL_CONSTANTS_EACH(COMPRESSED_RGBA_S3TC_DXT5_EXT, 0x83F3)
710715

711716
// Some Plask non-WebGL enums, some of which are likely a bad idea.
712717
#if PLASK_OSX

0 commit comments

Comments
 (0)