Skip to content

Commit

Permalink
Strip GL_EXT_texture_norm16 extension
Browse files Browse the repository at this point in the history
Fixes 10-bit videos for electron 2.x.
Closes #44.
  • Loading branch information
Kagami committed Jan 1, 2019
1 parent 7f00352 commit ff07e7d
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion index.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,29 @@

using pp::Var;

// Strip GL_EXT_texture_norm16 because it doesn't work but reported as
// available in Chrome 61-64 (electron 2.x) thus broking e.g. 10-bit
// videos in mpv.
// Note that we have a small memory leak here because no one frees copy
// of extension string but it shouldn't be a problem because this is
// only called once at start.
const GLubyte* myGetString(GLenum name) {
if (name == GL_EXTENSIONS) {
const char* exts = reinterpret_cast<const char*>(glGetString(name));
const char* sub = strstr(exts, " GL_EXT_texture_norm16");
if (!sub)
return reinterpret_cast<const GLubyte*>(exts);
char* my_exts = strdup(exts);
strcpy(my_exts + (sub - exts), sub + 22/*len of ext + space*/);
return reinterpret_cast<const GLubyte*>(my_exts);
} else {
return glGetString(name);
}
}

// PPAPI GLES implementation doesn't provide getProcAddress.
static const std::unordered_map<std::string, void*> GL_CALLBACKS = {
GLCB(GetString),
{ "glGetString", reinterpret_cast<void*>(myGetString) },
GLCB(ActiveTexture),
GLCB(AttachShader),
GLCB(BindAttribLocation),
Expand Down

2 comments on commit ff07e7d

@Feverqwe
Copy link

@Feverqwe Feverqwe commented on ff07e7d May 30, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this fix crash win x32 plugin, x64 fine.

#49

@Kagami
Copy link
Owner Author

@Kagami Kagami commented on ff07e7d May 30, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind to create issue for that?

Please sign in to comment.