Last active
May 18, 2023 05:20
-
-
Save dmitrykolesnikovich/96148482e52d49e53fcbd015e88ae3c6 to your computer and use it in GitHub Desktop.
Shader - Program - Graphics
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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