updated makefile for supporting different target architectures

use "ARCH=arch_name make"

restructured project folder, implementations and headers together under sources/
This commit is contained in:
beno
2026-03-16 00:10:52 +01:00
parent 6c125fb35e
commit bbede61723
73 changed files with 786 additions and 379 deletions

View File

@@ -0,0 +1,52 @@
#include "OnlyOnce.hpp"
/*
#include <GL/glew.h>
*/
extern "C" {
#ifndef STB_IMAGE_IMPLEMENTATION
#define STB_IMAGE_IMPLEMENTATION
#endif // !STB_IMAGE_IMPLEMENTATION
#include "stb_image.h"
}
GLuint loadImg(const char* path) {
GLuint texture;
int width, height, nrChannels;
GLenum format;
unsigned char* data;
glGenTextures(1, &texture);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, texture);
//Gestione minification e magnification
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
data = stbi_load(path, &width, &height, &nrChannels, 0);
if (data)
{
if (nrChannels == 3)
format = GL_RGB;
if (nrChannels == 4)
format = GL_RGBA;
glTexImage2D(GL_TEXTURE_2D, 0, format, width, height, 0, format, GL_UNSIGNED_BYTE, data);
glGenerateMipmap(GL_TEXTURE_2D);
printf("Tutto OK %d %d \n", width, height);
}
else
{
printf("LoadImage Errore nel caricare la texture\n");
printf("%s\n", stbi_failure_reason());
}
stbi_image_free(data);
glBindTexture(GL_TEXTURE_2D, 0);
return texture;
}