<commit_before>﻿(*
Render2TexturePrimitiveChangeableSizes.fsx

This examples demonstrates how to render to textures in an imperative style. No dependencies are tracked here between the
processing steps. In contrast to the next tutorial we use a rather low level API and construct render tasks manually.
After creation, we run the render tasks by executing the side effecting function task.Run(null, fbo)...

*)

#if INTERACTIVE
#I @"../../../bin/Debug"
#I @"../../../bin/Release"
#load "LoadReferences.fsx"
#else
namespace Examples
#endif

module Render2TexturePrimiviteChangeableSize = 

    open System
    open Aardvark.Base
    open Aardvark.Rendering.Interactive

    Aardvark.Rendering.Interactive.FsiSetup.init (Path.combine [__SOURCE_DIRECTORY__; ".."; ".."; ".."; "bin";"Debug"])
    open Default // makes viewTrafo and other tutorial specicific default creators visible

    open Aardvark.Base.Incremental
    open Aardvark.SceneGraph
    open Aardvark.Application
    open Aardvark.Base.Incremental.Operators // loads operators such as ~~ and %+ for conveniently creating and modifying mods
    open Aardvark.SceneGraph.Semantics


    let runtime = win.Runtime // the runtime instance provides functions for creating resources (lower abstraction than sg)

    let size = V2i(1024,768)
    let sizeM = Mod.init size
    let color = 
        ChangeableResources.createTexture runtime ~~1 sizeM ~~TextureFormat.Rgba8
    let depth = 
        ChangeableResources.createRenderbuffer runtime ~~1 sizeM ~~RenderbufferFormat.Depth24Stencil8

    // Signatures are required to compile render tasks. Signatures can be seen as the `type` of a framebuffer
    // It describes the instances which can be used to exectute the render task (in other words
    // the signature describes the formats and of all render targets which are subsequently used for rendering)
    let signature =
        runtime.CreateFramebufferSignature [
            DefaultSemantic.Colors, { format = RenderbufferFormat.Rgba8; samples = 1 }
            DefaultSemantic.Depth, { format = RenderbufferFormat.Depth24Stencil8; samples = 1 }
        ]

    // Create a framebuffer matching signature and capturing the render to texture targets
    let fbo = 
        ChangeableResources.createFramebufferFromTexture runtime signature color depth None

  
    // Default scene graph setup with static camera
    let render2TextureSg =
        quadSg<commit_msg>Demo: made render2texture more interactive<commit_after>﻿(*
Render2TexturePrimitiveChangeableSizes.fsx

This examples demonstrates how to render to textures in an imperative style. No dependencies are tracked here between the
processing steps. In contrast to the next tutorial we use a rather low level API and construct render tasks manually.
After creation, we run the render tasks by executing the side effecting function task.Run(null, fbo)...

*)

#if INTERACTIVE
#I @"../../../bin/Debug"
#I @"../../../bin/Release"
#load "LoadReferences.fsx"
#else
namespace Examples
#endif


open System
open Aardvark.Base
open Aardvark.Rendering.Interactive

open Default // makes viewTrafo and other tutorial specicific default creators visible

open Aardvark.Base.Incremental
open Aardvark.SceneGraph
open Aardvark.Application
open Aardvark.Base.Incremental.Operators // loads operators such as ~~ and %+ for conveniently creating and modifying mods
open Aardvark.SceneGraph.Semantics

module Render2TexturePrimiviteChangeableSize = 
    Aardvark.Rendering.Interactive.FsiSetup.init (Path.combine [__SOURCE_DIRECTORY__; ".."; ".."; ".."; "bin";"Debug"])

    let runtime = win.Runtime // the runtime instance provides functions for creating resources (lower abstraction than sg)

    let size = V2i(1024,768)
    let sizeM = Mod.init size
    let color = 
        ChangeableResources.createTexture runtime ~~1 sizeM ~~TextureFormat.Rgba8
    let depth = 
        ChangeableResources.createRenderbuffer runtime ~~1 sizeM ~~RenderbufferFormat.Depth24Stencil8

    // Signatures are required to compile render tasks. Signatures can be seen as the `type` of a framebuffer
    // It describes the instances which can be used to exectute the render task (in other words
    // the signature describes the formats and of all render targets which are subsequently used for rendering)
    let signature =
        runtime.CreateFramebufferSignature [
            DefaultSemantic.Colors, { format = RenderbufferFormat.Rgba8; samples = 1 }
            DefaultSemantic.Depth, { format = RenderbufferFormat.Depth24Stencil8; samples = 1 }
        ]

    // Create a framebuffer matching signature and capturing the render to texture targets
    let fbo = 
        ChangeableResources.createFramebufferFromTexture runtime signature color depth None

  
    // Default scene graph setup with static camera
    let render2TextureSg =
        quadSg
{'fraction_non_alphanumeric': 0.07026581495981866, 'fraction_numerical': 0.009684731094168555, 'mean_word_length': 3.653883029721956, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7247624', 'n_tokens_mistral': 1312, 'n_tokens_neox': 1251, 'n_words': 483}