首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >打印图像到基于染料的应用程序

打印图像到基于染料的应用程序
EN

Stack Overflow用户
提问于 2019-03-16 12:35:52
回答 1查看 53关注 0票数 2

我正在学习流体力学(和Haxe),并遇到了令人敬畏的项目,并认为我会尝试扩展到它,以帮助我学习。这里可以看到原始项目的演示。

到目前为止,我已经创建了一个包含不同形状的项目的边菜单。当用户单击其中一个形状时,单击画布,所选图像应印在染料上。然后,用户将移动鼠标,探索艺术等。

为了实现这一点,我做了以下工作:

代码语言:javascript
复制
import js.html.webgl.RenderingContext;

function imageSelection(): Void{        

    document.querySelector('.myscrollbar1').addEventListener('click', function() {
    // twilight image clicked
    closeNav(); 
    reset(); 
    var image:js.html.ImageElement = cast document.querySelector('img[src="images/twilight.jpg"]');
    gl.current_context.texSubImage2D(cast fluid.dyeRenderTarget.writeToTexture, 0, Math.round(mouse.x), Math.round(mouse.y), RenderingContext.RGB, RenderingContext.UNSIGNED_BYTE, image);
    TWILIGHT = true;  

});

在此调用之后,在update函数中,我有以下内容:

代码语言:javascript
复制
override function update( dt:Float ){

        time = haxe.Timer.stamp() - initTime;
        performanceMonitor.recordFrameTime(dt);
        //Smaller number creates a bigger ripple, was 0.016
        dt = 0.090;//@!
        //Physics
        //interaction
        updateDyeShader.isMouseDown.set(isMouseDown && lastMousePointKnown);
        mouseForceShader.isMouseDown.set(isMouseDown && lastMousePointKnown);

        //step physics
        fluid.step(dt);

        particles.flowVelocityField = fluid.velocityRenderTarget.readFromTexture;

        if(renderParticlesEnabled){
            particles.step(dt);
        }

//Below handles the cycling of colours once the mouse is moved and then the image should be disrupted into the set dye colours.

}

然而,尽管该项目构建,我似乎无法将图像印在画布上。我检查了控制台日志,可以看到以下错误:

WebGL: INVALID_ENUM: texSubImage2D:无效纹理目标

假设我的第一个配角是不允许的,这是安全的吗?

我已经读过,纹理目标是第一个参数,特别是INVALID_ENUM,这意味着gl.XXX中的一个参数对于特定的函数来说是完全错误的。

查看文件writeToTexture被声明为:public var writeToTexture (default, null):GLTexture;WriteToTexture是一个常规webgl句柄的包装器。

我使用Haxe version 3.2.1Snow来构建这个项目。WriteToTextureHaxeToolkit\haxe\lib\gltoolbox\git\gltoolbox\render中定义

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-03-16 13:16:32

writeToTexture in gltoolboxGLTexture。对于snowsnow_web,在snow.modules.opengl.GL中将其定义为:

代码语言:javascript
复制
typedef GLTexture = js.html.webgl.Texture;

因此,我们只是在这里处理一个js.html.webgl.Texture,或者在本地JS中处理WebGLTexture

这意味着,是的,这绝对不是texSubImage2D()target常量的有效值。

指定活动纹理的绑定点(目标)的GLenum

从这个描述中可以明显看出,这个参数实际上并不适用于纹理本身--它只是提供了一些关于如何使用活动纹理的信息。

接下来的问题是如何设置“活动”纹理。bindTexture()可用于此。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55196844

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档