Skip to content

Instantly share code, notes, and snippets.

@dmitrykolesnikovich
Last active May 18, 2023 05:20
Show Gist options
  • Save dmitrykolesnikovich/96148482e52d49e53fcbd015e88ae3c6 to your computer and use it in GitHub Desktop.
Save dmitrykolesnikovich/96148482e52d49e53fcbd015e88ae3c6 to your computer and use it in GitHub Desktop.
Shader - Program - Graphics
const val multipleLightsShader: String = """
TBD
"""
class MultipleLightsProgram : Program(multipleLightsShader) {
var projection: Matrix by uniforms["Matrices.projection"]
var view: Matrix by uniforms["Matrices.view"]
var model: Matrix by uniforms["model"]
var cameraPosition: Vector by uniforms["cameraPosition"]
var atmosphere: Atmosphere by uniforms["atmosphere"]
}
fun obj() = example {
val gl: Opengl = import()
val graphics: MultipleLightsProgram = MultipleLightsProgram()
val model: ObjModel = ObjModel("models/backpack/backpack.obj", flipped = true)
val modelPosition: Matrix = Matrix()
val camera: Camera = setupCamera().apply { position.z = 10f }
val atmosphere: Atmosphere = setupAtmosphere()
init {
load(graphics)
load(model)
gl.clearColor(atmosphere.backgroundColor)
gl.enable(DEPTH_TEST)
}
update {
gl.clear(COLOR_BUFFER_BIT or DEPTH_BUFFER_BIT)
graphics.projection = camera.projection
graphics.view = camera.view
graphics.model = modelPosition
graphics.cameraPosition = camera.position
graphics.atmosphere = atmosphere
graphics.drawModel(model)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment