view tests/test_resources.nim @ 211:744285b47a4d

did: refactor image handling
author Sam <sam@basx.dev>
date Tue, 09 May 2023 19:52:57 +0700
parents 81fab407a479
children b5d9410a8184
line wrap: on
line source

import std/times

import semicongine

proc main() =
  var scene = newScene("main", root=newEntity("rect", rect()))
  var engine = initEngine("Test materials")
  const
    vertexInput = @[
      attr[Vec3f]("position", memoryPerformanceHint=PreferFastRead),
    ]
    fragOutput = @[attr[Vec4f]("color")]
    vertexCode = compileGlslShader(
      stage=VK_SHADER_STAGE_VERTEX_BIT,
      inputs=vertexInput,
      main="""gl_Position = vec4(position, 1.0);"""
    )
    fragmentCode = compileGlslShader(
      stage=VK_SHADER_STAGE_FRAGMENT_BIT,
      outputs=fragOutput,
      main="""color = vec4(1, 0, 0, 1);"""
    )
  engine.setRenderer(engine.gpuDevice.simpleForwardRenderPass(vertexCode, fragmentCode))
  engine.addScene(scene, vertexInput)
  var t = cpuTime()
  while engine.updateInputs() == Running and not engine.keyIsDown(Escape):
    engine.renderScene(scene)
  engine.destroy()


when isMainModule:
  main()