|
3 | 3 | #include "./buffer.hpp" |
4 | 4 | #include "./program.hpp" |
5 | 5 | #include "./vertex_array.hpp" |
| 6 | +#include "./texture.hpp" |
6 | 7 |
|
7 | 8 | namespace endor |
8 | 9 | { |
@@ -417,6 +418,7 @@ namespace endor |
417 | 418 | // Enhanced framebuffer operations |
418 | 419 | ADD_WEBGL2_METHOD("blitFramebuffer", BlitFramebuffer) |
419 | 420 | ADD_WEBGL2_METHOD("renderbufferStorageMultisample", RenderbufferStorageMultisample) |
| 421 | + ADD_WEBGL2_METHOD("framebufferTextureLayer", FramebufferTextureLayer) |
420 | 422 |
|
421 | 423 | // Enhanced texture operations |
422 | 424 | ADD_WEBGL2_METHOD("texImage3D", TexImage3D) |
@@ -1701,6 +1703,81 @@ namespace endor |
1701 | 1703 | args.GetReturnValue().SetUndefined(); |
1702 | 1704 | } |
1703 | 1705 |
|
| 1706 | + void WebGL2RenderingContext::FramebufferTextureLayer(const v8::FunctionCallbackInfo<v8::Value> &args) |
| 1707 | + { |
| 1708 | + Isolate *isolate = args.GetIsolate(); |
| 1709 | + HandleScope scope(isolate); |
| 1710 | + Local<Context> context = isolate->GetCurrentContext(); |
| 1711 | + |
| 1712 | + if (args.Length() < 5) |
| 1713 | + { |
| 1714 | + isolate->ThrowException(Exception::TypeError( |
| 1715 | + MakeMethodArgCountError(isolate, "framebufferTextureLayer", 5, args.Length()))); |
| 1716 | + return; |
| 1717 | + } |
| 1718 | + if (!args[0]->IsNumber()) |
| 1719 | + { |
| 1720 | + isolate->ThrowException(Exception::TypeError( |
| 1721 | + MakeMethodArgTypeError(isolate, "framebufferTextureLayer", 0, "number", args[0]))); |
| 1722 | + return; |
| 1723 | + } |
| 1724 | + if (!args[1]->IsNumber()) |
| 1725 | + { |
| 1726 | + isolate->ThrowException(Exception::TypeError( |
| 1727 | + MakeMethodArgTypeError(isolate, "framebufferTextureLayer", 1, "number", args[1]))); |
| 1728 | + return; |
| 1729 | + } |
| 1730 | + if (!args[2]->IsNull() && !WebGLTexture::IsInstanceOf(isolate, args[2])) |
| 1731 | + { |
| 1732 | + isolate->ThrowException(Exception::TypeError( |
| 1733 | + MakeMethodArgTypeError(isolate, "framebufferTextureLayer", 2, "WebGLTexture or null", args[2]))); |
| 1734 | + return; |
| 1735 | + } |
| 1736 | + if (!args[3]->IsNumber()) |
| 1737 | + { |
| 1738 | + isolate->ThrowException(Exception::TypeError( |
| 1739 | + MakeMethodArgTypeError(isolate, "framebufferTextureLayer", 3, "number", args[3]))); |
| 1740 | + return; |
| 1741 | + } |
| 1742 | + if (!args[4]->IsNumber()) |
| 1743 | + { |
| 1744 | + isolate->ThrowException(Exception::TypeError( |
| 1745 | + MakeMethodArgTypeError(isolate, "framebufferTextureLayer", 4, "number", args[4]))); |
| 1746 | + return; |
| 1747 | + } |
| 1748 | + |
| 1749 | + client_graphics::WebGLFramebufferBindingTarget target; |
| 1750 | + { |
| 1751 | + int value = args[0]->Int32Value(context).ToChecked(); |
| 1752 | + target = static_cast<client_graphics::WebGLFramebufferBindingTarget>(value); |
| 1753 | + } |
| 1754 | + client_graphics::WebGLFramebufferAttachment attachment; |
| 1755 | + { |
| 1756 | + int value = args[1]->Int32Value(context).ToChecked(); |
| 1757 | + attachment = static_cast<client_graphics::WebGLFramebufferAttachment>(value); |
| 1758 | + } |
| 1759 | + int level = args[3]->Int32Value(context).ToChecked(); |
| 1760 | + int layer = args[4]->Int32Value(context).ToChecked(); |
| 1761 | + |
| 1762 | + if (args[2]->IsNull()) |
| 1763 | + { |
| 1764 | + handle()->framebufferTextureLayer(target, attachment, nullptr, level, layer); |
| 1765 | + } |
| 1766 | + else |
| 1767 | + { |
| 1768 | + auto textureObj = args[2].As<Object>(); |
| 1769 | + auto textureBinding = WebGLTexture::Unwrap(isolate, textureObj); |
| 1770 | + if (textureBinding == nullptr || !textureBinding->hasData()) |
| 1771 | + { |
| 1772 | + isolate->ThrowException(Exception::TypeError( |
| 1773 | + MakeMethodError(isolate, "framebufferTextureLayer", "Invalid WebGLTexture object"))); |
| 1774 | + return; |
| 1775 | + } |
| 1776 | + handle()->framebufferTextureLayer(target, attachment, textureBinding->handle(), level, layer); |
| 1777 | + } |
| 1778 | + args.GetReturnValue().SetUndefined(); |
| 1779 | + } |
| 1780 | + |
1704 | 1781 | // Enhanced texture operations |
1705 | 1782 | void WebGL2RenderingContext::TexImage3D(const FunctionCallbackInfo<Value> &args) |
1706 | 1783 | { |
|
0 commit comments