Skip to content

Commit

Permalink
Merge branch 'master' into stencilMask
Browse files Browse the repository at this point in the history
* master:
  Move GL_CHECK to GL callsites.
  make sure depth textures are resolved as well when blitting frameBuffer
  Cleanup.
  Adjust integer texture format enums for desktop OpenGL < 4.0
  Revert back to using GL_HALF_FLOAT (that is GL_HALF_FLOAT_OES)
  Fix OpenGL ES texture formats and remove runtime texture probing on WebGL.
  Cleanup.
  Create WebGL 2 context if available. Work around Chrome performance bug https://bugs.chromium.org/p/chromium/issues/detail?id=1045643
  Optimize glUniform1iv and glUniform4fv to use faster glUniform1i and glUniform4f on WebGL.
  Avoid redundant GL calls to glEnableVertexAttribArray() and glDisableVertexAttribArray(). bkaradzic#1960
  • Loading branch information
pigpigyyy committed Mar 31, 2020
2 parents bbdc546 + f2290c1 commit a6ac1c7
Show file tree
Hide file tree
Showing 3 changed files with 441 additions and 68 deletions.
40 changes: 19 additions & 21 deletions src/glcontext_html5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,37 +108,35 @@ namespace bgfx { namespace gl
{
emscripten_webgl_init_context_attributes(&s_attrs);

s_attrs.alpha = false;
// Work around bug https://bugs.chromium.org/p/chromium/issues/detail?id=1045643 in Chrome
// by having alpha always enabled.
s_attrs.alpha = true;
s_attrs.premultipliedAlpha = false;
s_attrs.depth = true;
s_attrs.stencil = true;
s_attrs.enableExtensionsByDefault = true;
s_attrs.antialias = false;

// let emscripten figure out the best WebGL context to create
s_attrs.majorVersion = 0;
s_attrs.majorVersion = 0;

s_attrs.minorVersion = 0;
const char* canvas = (const char*) _nwh;

int context = emscripten_webgl_create_context(canvas, &s_attrs);

if (context <= 0)
{
BX_TRACE("Failed to create WebGL context. (Canvas handle: '%s', error %d)", canvas, (int)context);
return NULL;
}

int result = emscripten_webgl_make_context_current(context);
if (EMSCRIPTEN_RESULT_SUCCESS != result)
for(int version = 2; version >= 1; --version)
{
BX_TRACE("emscripten_webgl_make_context_current failed (%d)", result);
return NULL;
}
s_attrs.majorVersion = version;
EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context = emscripten_webgl_create_context(canvas, &s_attrs);
if (context > 0)
{
emscripten_webgl_make_context_current(context);

SwapChainGL* swapChain = BX_NEW(g_allocator, SwapChainGL)(context, canvas);
SwapChainGL* swapChain = BX_NEW(g_allocator, SwapChainGL)(context, canvas);

import(1);
import(1);

return swapChain;
return swapChain;
}
}
BX_TRACE("Failed to create WebGL context. (Canvas handle: '%s', error %d)", canvas, (int)context);
return NULL;
}

uint64_t GlContext::getCaps() const
Expand Down
Loading

0 comments on commit a6ac1c7

Please sign in to comment.