@@ -2265,18 +2265,15 @@ void render_hud(LunarWM *this, float /*dt*/, int hud_size)
|
|||||||
|
|
||||||
void render_3d(LunarWM *this, float /*dt*/)
|
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++) {
|
for (size_t i = 0; i < vector_size(this->wayland.v_toplevels); i++) {
|
||||||
auto *tl = this->wayland.v_toplevels[i];
|
auto *tl = this->wayland.v_toplevels[i];
|
||||||
|
|
||||||
if (!tl || !tl->surface)
|
if (!tl || !tl->surface)
|
||||||
continue;
|
continue;
|
||||||
|
if (tl->gles_texture && !tl->gles_texture->has_alpha) {
|
||||||
auto const rad = this->cman->cfg.space.radius - 0.01 * (float)i;
|
float rad = this->cman->cfg.space.radius - 0.01f * (float)i;
|
||||||
|
DrawTextureCyl(tl->rl_texture, (Vector3) { 0, 0, rad }, rad,
|
||||||
DrawTextureCyl(tl->rl_texture, (Vector3) { 0, 0, rad }, rad,
|
this->cman->cfg.space.window_scale, false);
|
||||||
this->cman->cfg.space.window_scale, false);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int h = 0; h < 2; ++h) {
|
for (int h = 0; h < 2; ++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)) {
|
if (IsTextureValid(this->renderer.hud_rt.texture)) {
|
||||||
rlDrawRenderBatchActive();
|
rlDrawRenderBatchActive();
|
||||||
rlDisableDepthTest();
|
rlDisableDepthTest();
|
||||||
|
|||||||
36
src/RayExt.c
36
src/RayExt.c
@@ -1,17 +1,22 @@
|
|||||||
#include "RayExt.h"
|
#include "RayExt.h"
|
||||||
|
|
||||||
|
#include <GLES2/gl2.h>
|
||||||
|
|
||||||
#include <raylib.h>
|
#include <raylib.h>
|
||||||
#include <raymath.h>
|
#include <raymath.h>
|
||||||
#include <rlgl.h>
|
#include <rlgl.h>
|
||||||
|
|
||||||
#if defined(GRAPHICS_API_OPENGL_ES3)
|
static char const *SKYBOX_VS
|
||||||
static char const *SKYBOX_VS = "#version 300 es\n"
|
= "#version 300 es\n"
|
||||||
"precision mediump float;\n"
|
"precision mediump float;\n"
|
||||||
"layout(location=0) in vec3 vertexPosition;\n"
|
"layout(location=0) in vec3 vertexPosition;\n"
|
||||||
"uniform mat4 mvp;\n"
|
"uniform mat4 mvp;\n"
|
||||||
"out vec3 vDir;\n"
|
"out vec3 vDir;\n"
|
||||||
"void main(){ vDir=vertexPosition; "
|
"void main(){\n"
|
||||||
"gl_Position=mvp*vec4(vertexPosition,1.0); }\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
|
static char const *SKYBOX_FS
|
||||||
= "#version 300 es\n"
|
= "#version 300 es\n"
|
||||||
"precision highp float;\n"
|
"precision highp float;\n"
|
||||||
@@ -20,7 +25,6 @@ static char const *SKYBOX_FS
|
|||||||
"out vec4 finalColor;\n"
|
"out vec4 finalColor;\n"
|
||||||
"void main(){ vec3 dir=normalize(vDir); "
|
"void main(){ vec3 dir=normalize(vDir); "
|
||||||
"finalColor=vec4(texture(environmentMap, normalize(vDir)).rgb, 1.0); }\n";
|
"finalColor=vec4(texture(environmentMap, normalize(vDir)).rgb, 1.0); }\n";
|
||||||
#endif
|
|
||||||
|
|
||||||
void Skybox_init(Skybox *skybox, char const *fp)
|
void Skybox_init(Skybox *skybox, char const *fp)
|
||||||
{
|
{
|
||||||
@@ -90,19 +94,25 @@ void Skybox_destroy(Skybox *skybox)
|
|||||||
*skybox = (Skybox) { 0 };
|
*skybox = (Skybox) { 0 };
|
||||||
}
|
}
|
||||||
|
|
||||||
void Skybox_draw(Skybox const skybox, Vector3 position)
|
void Skybox_draw(Skybox const skybox, Vector3 camPos)
|
||||||
{
|
{
|
||||||
if (!skybox.ok)
|
if (!skybox.ok)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
rlDisableBackfaceCulling();
|
rlDisableBackfaceCulling();
|
||||||
rlDisableDepthTest();
|
rlDisableDepthMask();
|
||||||
rlDisableColorBlend();
|
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();
|
rlDrawRenderBatchActive();
|
||||||
|
|
||||||
|
glDepthFunc(oldFunc ? oldFunc : GL_LESS);
|
||||||
rlEnableColorBlend();
|
rlEnableColorBlend();
|
||||||
rlEnableDepthTest();
|
rlEnableDepthMask();
|
||||||
rlEnableBackfaceCulling();
|
rlEnableBackfaceCulling();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user