add mesh for rendering car lights

This commit is contained in:
sergeypdev 2025-05-03 01:33:19 +04:00
parent 19ca2f28b8
commit 786d18cd75
4 changed files with 15 additions and 9 deletions

BIN
assets/ae86_lights.glb (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -822,7 +822,7 @@ draw :: proc() {
render.draw_model(car_model, basic_shader.shader, car_matrix) render.draw_model(car_model, basic_shader.shader, car_matrix)
render.draw_point_light(0, 2, rl.Color{255, 255, 255, 69}) render.draw_mesh_light(assets.get_model(&g_mem.assetman, "assets/ae86_lights.glb"), car_matrix, rl.Color{255, 255, 255, 100})
} }
{ {
@ -1111,6 +1111,8 @@ game_init_window :: proc(args: []string) {
init_physfs(args) init_physfs(args)
render.init()
rl.SetConfigFlags({.WINDOW_RESIZABLE, .VSYNC_HINT}) rl.SetConfigFlags({.WINDOW_RESIZABLE, .VSYNC_HINT})
rl.InitWindow(1280, 720, "Odin + Raylib + Hot Reload template!") rl.InitWindow(1280, 720, "Odin + Raylib + Hot Reload template!")
rl.SetExitKey(.KEY_NULL) rl.SetExitKey(.KEY_NULL)

View File

@ -27,7 +27,10 @@ draw_model :: proc(model: rl.Model, shader: rl.Shader, transform: rl.Matrix) {
rl.DrawModel(model, rl.Vector3{}, 1, rl.WHITE) rl.DrawModel(model, rl.Vector3{}, 1, rl.WHITE)
} }
draw_point_light :: proc(pos: rl.Vector3, radius: f32, color: rl.Color) { draw_mesh_light :: proc(model: rl.Model, transform: rl.Matrix, color: rl.Color) {
model := model
model.transform = transform
rlgl.DrawRenderBatchActive() rlgl.DrawRenderBatchActive()
gl.Enable(gl.STENCIL_TEST) gl.Enable(gl.STENCIL_TEST)
@ -40,7 +43,7 @@ draw_point_light :: proc(pos: rl.Vector3, radius: f32, color: rl.Color) {
gl.ColorMask(false, false, false, false) gl.ColorMask(false, false, false, false)
rlgl.SetCullFace(.FRONT) rlgl.SetCullFace(.FRONT)
rl.DrawSphere(pos, radius, color) rl.DrawModel(model, {}, 1, color)
rlgl.DrawRenderBatchActive() rlgl.DrawRenderBatchActive()
} }
@ -51,7 +54,7 @@ draw_point_light :: proc(pos: rl.Vector3, radius: f32, color: rl.Color) {
gl.ColorMask(true, true, true, true) gl.ColorMask(true, true, true, true)
rlgl.SetCullFace(.BACK) rlgl.SetCullFace(.BACK)
rl.DrawSphere(pos, radius, color) rl.DrawModel(model, {}, 1, color)
rlgl.DrawRenderBatchActive() rlgl.DrawRenderBatchActive()
} }
@ -60,7 +63,7 @@ draw_point_light :: proc(pos: rl.Vector3, radius: f32, color: rl.Color) {
gl.DepthFunc(gl.GREATER) gl.DepthFunc(gl.GREATER)
rlgl.SetCullFace(.FRONT) rlgl.SetCullFace(.FRONT)
rl.DrawSphere(pos, radius, color) rl.DrawModel(model, {}, 1, color)
rlgl.DrawRenderBatchActive() rlgl.DrawRenderBatchActive()
} }
@ -70,6 +73,4 @@ draw_point_light :: proc(pos: rl.Vector3, radius: f32, color: rl.Color) {
gl.DepthFunc(gl.LEQUAL) gl.DepthFunc(gl.LEQUAL)
rlgl.EnableDepthMask() rlgl.EnableDepthMask()
// rl.DrawMesh(mesh, rl.LoadMaterialDefault(), transform)
} }

BIN
src_assets/ae86.blend (Stored with Git LFS)

Binary file not shown.