summaryrefslogtreecommitdiffhomepage
path: root/src/render.c
diff options
context:
space:
mode:
authorarngo <[email protected]>2024-05-16 21:00:51 -0400
committerarngo <[email protected]>2024-05-16 21:00:51 -0400
commit0e1c3d42a93f623f60284f7e9acfd014e41ddadc (patch)
tree701cd9cef7e0e7210dba9ac77e2bad9a87b8c5e9 /src/render.c
parent21ab7c1df0b8a0fcbb1d10ed2e61410d7f7021e0 (diff)
downloadtojam2024-0e1c3d42a93f623f60284f7e9acfd014e41ddadc.tar.gz
tojam2024-0e1c3d42a93f623f60284f7e9acfd014e41ddadc.zip
loading and draw textures for skyboxtextures
Diffstat (limited to 'src/render.c')
-rw-r--r--src/render.c76
1 files changed, 76 insertions, 0 deletions
diff --git a/src/render.c b/src/render.c
index 1501814..ef6383a 100644
--- a/src/render.c
+++ b/src/render.c
@@ -114,6 +114,82 @@ drawGrid(Vector3 position, int lines, int size, Color color)
rlPopMatrix();
}
+GLuint customLoadTextureN64(char *spritePath)
+{
+ sprite_t *sprite = sprite_load(spritePath);
+ GLuint id;
+ glGenTextures(1, &id);
+ glBindTexture(GL_TEXTURE_2D, id);
+ glSpriteTextureN64(GL_TEXTURE_2D, sprite, NULL);
+ glBindTexture(GL_TEXTURE_2D, 0);
+ return id;
+}
+
+/*Vector3 vertices[] = {
+ {0.5f, 0.5f, 0.0f},
+ {0.5f, -0.5f, 0.0f},
+ {-0.5f, -0.5f, 0.0f},
+ {-0.5f, 0.5f, 0.0f},
+};
+
+float texcoords[] = {
+ 1.0f, 1.0f,
+ 1.0f, 0.0f,
+ 0.0f, 0.0f,
+ 0.0f, 1.0f
+};*/
+
+Vector2 vertices[] =
+{
+ {1.0f, 0.0f},
+ {1.0f, 1.0f},
+ {0.0f, 1.0f},
+ {0.0f, 0.0f},
+};
+
+float texcoords[] = {
+ 1.0f, 1.0f,
+ 1.0f, 0.0f,
+ 0.0f, 0.0f,
+ 0.0f, 1.0f,
+};
+
+uint8_t indices[] =
+{
+ 0, 1, 2, 3,
+};
+
+void
+renderSkybox(GLuint *textures, int m, int n, Camera3D camera)
+{
+ //int len = m*n;
+ rlPushMatrix();
+ rlTranslatef(-6.0f, 3.0f, 0.0f);
+ glEnable(GL_TEXTURE_2D);
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+
+ rlColor4ub(255,255,255,255);
+ glVertexPointer(2, GL_FLOAT, 0, vertices);
+ glTexCoordPointer(2, GL_FLOAT, 0, texcoords);
+ for (int i = 0; i < m; i++)
+ {
+ for (int j = 0; j < n; j++)
+ {
+ glBindTexture(GL_TEXTURE_2D, textures[i*n+j]);
+ rlPushMatrix();
+ rlTranslatef(j, -i, 0.0f);
+ glDrawElements(GL_QUADS, 4, GL_UNSIGNED_BYTE, indices);
+ rlPopMatrix();
+ }
+ }
+ glDisableClientState(GL_VERTEX_ARRAY);
+ glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+ glDisable(GL_TEXTURE_2D);
+ glBindTexture(GL_TEXTURE_2D, 0);
+ rlPopMatrix();
+}
+
void
renderWorld(World* world, Camera camera)
{