WebGLExtensionDepthTexture.cpp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #include "WebGLExtensions.h"
  6. #include "GLContext.h"
  7. #include "mozilla/dom/WebGLRenderingContextBinding.h"
  8. #include "WebGLContext.h"
  9. namespace mozilla {
  10. WebGLExtensionDepthTexture::WebGLExtensionDepthTexture(WebGLContext* webgl)
  11. : WebGLExtensionBase(webgl)
  12. {
  13. auto& fua = webgl->mFormatUsage;
  14. const auto fnAdd = [&fua](webgl::EffectiveFormat effFormat, GLenum unpackFormat,
  15. GLenum unpackType)
  16. {
  17. auto usage = fua->EditUsage(effFormat);
  18. usage->isFilterable = true;
  19. usage->SetRenderable();
  20. const webgl::PackingInfo pi = {unpackFormat, unpackType};
  21. const webgl::DriverUnpackInfo dui = {unpackFormat, unpackFormat, unpackType};
  22. fua->AddTexUnpack(usage, pi, dui);
  23. fua->AllowUnsizedTexFormat(pi, usage);
  24. };
  25. fnAdd(webgl::EffectiveFormat::DEPTH_COMPONENT16, LOCAL_GL_DEPTH_COMPONENT,
  26. LOCAL_GL_UNSIGNED_SHORT);
  27. fnAdd(webgl::EffectiveFormat::DEPTH_COMPONENT24, LOCAL_GL_DEPTH_COMPONENT,
  28. LOCAL_GL_UNSIGNED_INT);
  29. fnAdd(webgl::EffectiveFormat::DEPTH24_STENCIL8, LOCAL_GL_DEPTH_STENCIL,
  30. LOCAL_GL_UNSIGNED_INT_24_8);
  31. }
  32. WebGLExtensionDepthTexture::~WebGLExtensionDepthTexture()
  33. {
  34. }
  35. IMPL_WEBGL_EXTENSION_GOOP(WebGLExtensionDepthTexture, WEBGL_depth_texture)
  36. } // namespace mozilla