From 1e5171fdebab7dd3d8b56cd66dc355d005f28b6b Mon Sep 17 00:00:00 2001
From: nakst <>
Date: Fri, 24 Sep 2021 12:06:45 +0100
Subject: [PATCH] hide viewer applications; change object viewer colors

---
 apps/markdown_viewer.ini  |  1 +
 ports/mesa/obj_viewer.c   | 16 ++++++++--------
 ports/mesa/obj_viewer.ini |  1 +
 3 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/apps/markdown_viewer.ini b/apps/markdown_viewer.ini
index 8c25397..92a2358 100644
--- a/apps/markdown_viewer.ini
+++ b/apps/markdown_viewer.ini
@@ -2,6 +2,7 @@
 name=Markdown Viewer
 icon=icon_text_markdown
 use_single_process=1
+hidden=1
 
 [build]
 source=apps/markdown_viewer.cpp
diff --git a/ports/mesa/obj_viewer.c b/ports/mesa/obj_viewer.c
index 9bcf6e9..1a82c06 100644
--- a/ports/mesa/obj_viewer.c
+++ b/ports/mesa/obj_viewer.c
@@ -122,11 +122,11 @@ void Render() {
 		return;
 	}
 
-	glClearColor(0, 0, 0, 1);
+	glClearColor(0.21f, 0.2f, 0.2f, 1.0f);
 	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 #ifdef MODERN_GL
 	float m = timeMs / 1000.0f;
-	float transform[16] = { 1, 0, 0, 0, /**/ 0, 1, 0, 0, /**/ 0, 0, 1, 0, /**/ 0, 0, 0, 1 };
+	float transform[16] = { 0.9f, 0, 0, 0, /**/ 0, 1, 0, 0, /**/ 0, 0, 1, 0, /**/ 0, 0, 0, 1 };
 	float normalTransform[9];
 	float rotation[16] = { cosf(m), 0, sinf(m), 0, /**/ 0, 1, 0, 0, /**/ -sinf(m), 0, cosf(m), 0, /**/ 0, 0, 0, 1 };
 	float rotation2[16] = { 1, 0, 0, 0, /**/ 0, cosf(0.3f), sinf(0.3f), 0, /**/ 0, -sinf(0.3f), cosf(0.3f), 0, /**/ 0, 0, 0, 1 };
@@ -161,10 +161,10 @@ int CanvasCallback(EsElement *element, EsMessage *message) {
 		EsRectangle bounds = EsPainterBoundsInset(message->painter);
 		EsRectangle imageBounds = EsRectangleCenter(bounds, ES_RECT_2S(IMAGE_WIDTH, IMAGE_HEIGHT));
 		EsDrawBitmap(message->painter, imageBounds, buffer, IMAGE_WIDTH * 4, ES_DRAW_BITMAP_OPAQUE);
-		EsDrawBlock(message->painter, ES_RECT_4(bounds.l, imageBounds.l, bounds.t, bounds.b), 0xFF000000);
-		EsDrawBlock(message->painter, ES_RECT_4(imageBounds.r, bounds.r, bounds.t, bounds.b), 0xFF000000);
-		EsDrawBlock(message->painter, ES_RECT_4(imageBounds.l, imageBounds.r, bounds.t, imageBounds.t), 0xFF000000);
-		EsDrawBlock(message->painter, ES_RECT_4(imageBounds.l, imageBounds.r, imageBounds.b, bounds.b), 0xFF000000);
+		EsDrawBlock(message->painter, ES_RECT_4(bounds.l, imageBounds.l, bounds.t, bounds.b), 0xFF333336);
+		EsDrawBlock(message->painter, ES_RECT_4(imageBounds.r, bounds.r, bounds.t, bounds.b), 0xFF333336);
+		EsDrawBlock(message->painter, ES_RECT_4(imageBounds.l, imageBounds.r, bounds.t, imageBounds.t), 0xFF333336);
+		EsDrawBlock(message->painter, ES_RECT_4(imageBounds.l, imageBounds.r, imageBounds.b, bounds.b), 0xFF333336);
 		framesDrawn++;
 	} else if (message->type == ES_MSG_ANIMATE) {
 		double currentTime = EsTimeStampMs();
@@ -341,7 +341,6 @@ int main(int argc, char **argv) {
 	LOADEXT(glVertexAttribPointer);
 #undef LOADEXT
 
-	glClearColor(0, 0, 0, 1);
 	glEnable(GL_BLEND);
 	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
 	glEnable(GL_MULTISAMPLE);
@@ -367,10 +366,11 @@ int main(int argc, char **argv) {
 		"void main() { \n"
 		"	vec3 n = normalize(Normal0);\n"
 		"	vec3 lightDirection = vec3(0, -0.707, 0.707);\n"
+		"	vec3 color = vec3(1.0, 0.9, 0.9);\n"
 		"	float lightFactor = max(0, -dot(n, lightDirection));\n"
 		"	// FragColor = vec4(n.xyz, 1);\n" // Visualize normals.
 		"	// FragColor = vec4(vec3(gl_FragCoord.z), 1);\n" // Visualize Z coordinates.
-		"	FragColor = vec4(vec3(lightFactor), 1);\n"
+		"	FragColor = vec4(color * vec3(lightFactor), 1);\n"
 		"}\n";
 
 	const char *shaderSources[] = { vertexShaderSource, fragmentShaderSource };
diff --git a/ports/mesa/obj_viewer.ini b/ports/mesa/obj_viewer.ini
index 419019f..222aed9 100644
--- a/ports/mesa/obj_viewer.ini
+++ b/ports/mesa/obj_viewer.ini
@@ -2,6 +2,7 @@
 name=Object Viewer
 permission_posix_subsystem=1
 icon=icon_model
+hidden=1
 
 [build]
 link_flags=-lOSMesa -lstdc++ -lz