From f272d0145aed15c1c2656fb5fc858665e12cc068 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Sun, 21 May 2023 10:19:04 +0200 Subject: [PATCH] xxdddddddddddd --- images/wall.png | Bin 0 -> 277 bytes shaders/tag.fs | 21 +++++++++++++++++- shaders/tag.vs | 31 +++++++++++++++++++++++++- src/tag.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 108 insertions(+), 2 deletions(-) create mode 100644 images/wall.png diff --git a/images/wall.png b/images/wall.png new file mode 100644 index 0000000000000000000000000000000000000000..1dd652b0ebab43822efc1029dbccf717b7c04e3d GIT binary patch literal 277 zcmeAS@N?(olHy`uVBq!ia0vp^AT}2V8<6ZZI=>f4F%}28J29*~C-V}>VM%xNb!1@J z*w6hZkrl}2EbxddW?X?_wfUrhf~!1T978mMZ6`zvwJPv9@6HnpiICVQ8+O%N z-FUA&pQp#AuDQ=&p8x!#GZnZh z5Bt_XpVOK=tLL-LYR1A@YLX8N7fCPq{%&iSsgmAlCE?_mZZjQ^Nl3LaPGqP`h%&Wu zi3;*Mbn#d1{CB;sf}Wqs3#2YsT;zOJ>Cwh`CT`1xWB+U>Z?xg;sd+A3DDIHp00i_>zopr0PRRshaders/tag.vs", "shaders/tag.fs", NULL); + + glGenTextures(1, &_texId); + load_img("images/wall.png", _texId); + + gl4duGenMatrix(GL_FLOAT, matrix_proj); + gl4duGenMatrix(GL_FLOAT, matrix_model); + gl4duGenMatrix(GL_FLOAT, matrix_view); } static void draw(void) { + static double t0 = 0; + float dt = (float)get_dt(&t0, GL_TRUE); + + static GLfloat angle = 0.0f; + GLfloat lum_pos[] = {-2.0f * + (float)cos(angle * (GLfloat)M_PI / (5.0f * 180.0f)), + 0.2f, 0.0f, 1.0f}; + glEnable(GL_DEPTH_TEST); glClearColor(0.2f, 0.2f, 0.2f, 1); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glUseProgram(_pId); + bindAndLoadf(matrix_proj); + GLfloat ratio = (GLfloat)_dims[0] / (GLfloat)_dims[1]; + gl4duFrustumf(-1, 1, -ratio, ratio, 2, 1000); + + bindAndLoadf(matrix_view); + const GLfloat distance = 2; // distance from the scene + gl4duLookAtf(0, distance, distance, 0, 0, 0, 0, 1, 0); + // gl4duRotatef(-90, 0, 1, 0); // rotation camera + + bindAndLoadf(matrix_model); + gl4duRotatef(40, 1, 0, 0); + gl4duRotatef(40, 0, 0, 1); + + angle += dt * 90.0f; + gl4duSendMatrices(); + + glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D, _texId); + glUniform1f(glGetUniformLocation(_pId, "phase"), 0); + glUniform4fv(glGetUniformLocation(_pId, "lumPos"), 1, lum_pos); + + gl4dgDraw(_murId); + glUseProgram(0); + glBindTexture(GL_TEXTURE_2D, 0); +} + +static void deinit(void) { + if (_texId) { + glDeleteTextures(1, &_texId); + _texId = 0; + } }