| @@ -2265,19 +2265,16 @@ void render_hud(LunarWM *this, float /*dt*/, int hud_size) | ||||
|  | ||||
| void render_3d(LunarWM *this, float /*dt*/) | ||||
| { | ||||
| 	Skybox_draw(this->renderer.skybox, this->renderer.camera.position); | ||||
|  | ||||
| 	for (size_t i = 0; i < vector_size(this->wayland.v_toplevels); i++) { | ||||
| 		auto *tl = this->wayland.v_toplevels[i]; | ||||
|  | ||||
| 		if (!tl || !tl->surface) | ||||
| 			continue; | ||||
|  | ||||
| 		auto const rad = this->cman->cfg.space.radius - 0.01 * (float)i; | ||||
|  | ||||
| 		if (tl->gles_texture && !tl->gles_texture->has_alpha) { | ||||
| 			float rad = this->cman->cfg.space.radius - 0.01f * (float)i; | ||||
| 			DrawTextureCyl(tl->rl_texture, (Vector3) { 0, 0, rad }, rad, | ||||
| 			    this->cman->cfg.space.window_scale, false); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	for (int h = 0; h < 2; ++h) { | ||||
| 		auto *hand_info = &this->xr.hands[h]; | ||||
| @@ -2293,6 +2290,22 @@ void render_3d(LunarWM *this, float /*dt*/) | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	Skybox_draw(this->renderer.skybox, this->renderer.camera.position); | ||||
|  | ||||
| 	rlEnableColorBlend(); | ||||
| 	rlDisableDepthMask(); // don't write depth | ||||
| 	for (size_t i = 0; i < vector_size(this->wayland.v_toplevels); i++) { | ||||
| 		auto *tl = this->wayland.v_toplevels[i]; | ||||
| 		if (!tl || !tl->surface) | ||||
| 			continue; | ||||
| 		if (tl->gles_texture && tl->gles_texture->has_alpha) { | ||||
| 			float rad = this->cman->cfg.space.radius - 0.01f * (float)i; | ||||
| 			DrawTextureCyl(tl->rl_texture, (Vector3) { 0, 0, rad }, rad, | ||||
| 			    this->cman->cfg.space.window_scale, false); | ||||
| 		} | ||||
| 	} | ||||
| 	rlEnableDepthMask(); | ||||
|  | ||||
| 	if (IsTextureValid(this->renderer.hud_rt.texture)) { | ||||
| 		rlDrawRenderBatchActive(); | ||||
| 		rlDisableDepthTest(); | ||||
|   | ||||
							
								
								
									
										28
									
								
								src/RayExt.c
									
									
									
									
									
								
							
							
						
						
									
										28
									
								
								src/RayExt.c
									
									
									
									
									
								
							| @@ -1,17 +1,22 @@ | ||||
| #include "RayExt.h" | ||||
|  | ||||
| #include <GLES2/gl2.h> | ||||
|  | ||||
| #include <raylib.h> | ||||
| #include <raymath.h> | ||||
| #include <rlgl.h> | ||||
|  | ||||
| #if defined(GRAPHICS_API_OPENGL_ES3) | ||||
| static char const *SKYBOX_VS = "#version 300 es\n" | ||||
| static char const *SKYBOX_VS | ||||
|     = "#version 300 es\n" | ||||
|       "precision mediump float;\n" | ||||
|       "layout(location=0) in vec3 vertexPosition;\n" | ||||
|       "uniform mat4 mvp;\n" | ||||
|       "out vec3 vDir;\n" | ||||
|                                "void main(){ vDir=vertexPosition; " | ||||
|                                "gl_Position=mvp*vec4(vertexPosition,1.0); }\n"; | ||||
|       "void main(){\n" | ||||
|       "\tvDir = vertexPosition;\n" | ||||
|       "\tvec4 pos = mvp * vec4(vertexPosition, 1.0);\n" | ||||
|       "\tgl_Position = vec4(pos.xy, pos.w, pos.w); // z := 1 after division\n" | ||||
|       "}\n"; | ||||
| static char const *SKYBOX_FS | ||||
|     = "#version 300 es\n" | ||||
|       "precision highp float;\n" | ||||
| @@ -20,7 +25,6 @@ static char const *SKYBOX_FS | ||||
|       "out vec4 finalColor;\n" | ||||
|       "void main(){ vec3 dir=normalize(vDir); " | ||||
|       "finalColor=vec4(texture(environmentMap, normalize(vDir)).rgb, 1.0); }\n"; | ||||
| #endif | ||||
|  | ||||
| void Skybox_init(Skybox *skybox, char const *fp) | ||||
| { | ||||
| @@ -90,19 +94,25 @@ void Skybox_destroy(Skybox *skybox) | ||||
| 	*skybox = (Skybox) { 0 }; | ||||
| } | ||||
|  | ||||
| void Skybox_draw(Skybox const skybox, Vector3 position) | ||||
| void Skybox_draw(Skybox const skybox, Vector3 camPos) | ||||
| { | ||||
| 	if (!skybox.ok) | ||||
| 		return; | ||||
|  | ||||
| 	rlDisableBackfaceCulling(); | ||||
| 	rlDisableDepthTest(); | ||||
| 	rlDisableDepthMask(); | ||||
| 	rlDisableColorBlend(); | ||||
|  | ||||
| 	DrawModel(skybox.cube, position, 5.0f, (Color) { 255, 255, 255, 255 }); | ||||
| 	rlDrawRenderBatchActive(); | ||||
| 	GLint oldFunc = 0; | ||||
| 	glGetIntegerv(GL_DEPTH_FUNC, &oldFunc); | ||||
| 	glDepthFunc(GL_LEQUAL); | ||||
|  | ||||
| 	DrawModel(skybox.cube, camPos, 500.0f, (Color) { 255, 255, 255, 255 }); | ||||
| 	rlDrawRenderBatchActive(); | ||||
|  | ||||
| 	glDepthFunc(oldFunc ? oldFunc : GL_LESS); | ||||
| 	rlEnableColorBlend(); | ||||
| 	rlEnableDepthTest(); | ||||
| 	rlEnableDepthMask(); | ||||
| 	rlEnableBackfaceCulling(); | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user