dodanie textur

This commit is contained in:
2025-01-08 04:55:58 +01:00
parent 4956d74c1a
commit 395b470b5d
29 changed files with 1848 additions and 456 deletions

View File

@@ -1,15 +1,21 @@
#include "lazik.hpp"
lazik::lazik(float x, float y, float z, const char* modelpath){
//lazik::lazik(float x, float y, float z, const char* modelpath, const char* texturepath) {
lazik::lazik(float x, float y, float z, const char* modelpath) {
this->c_x = x;
this->c_y = y;
this->c_z = z;
this->modelpath = modelpath;
// this->texturepath = texturepath;
timestampedCout("lazik.cpp: Zaladowano dane w konstruktorze.")
}
// void lazik::passProgramID(GLuint programID) {
// this->programID = programID;
// }
void lazik::loadModel() {
timestampedCout("lazik.cpp:");
@@ -18,6 +24,11 @@ void lazik::loadModel() {
if (res) timestampedCout("Pomyslnie zaladowano model lazika.")
else timestampedCout("Nie udalo sie zaladowac modelu lazika.");
//this->Texture = loadDDS(this->texturepath);
//timestampedCout("lazik.cpp: this->Texture = " << this->Texture);
//this->TextureID = glGetUniformLocation(this->programID, "myTextureSampler");
//timestampedCout("lazik.cpp: this->TextureID = " << this->TextureID);
glGenBuffers(1, &vertexbuffer);
glBindBuffer(GL_ARRAY_BUFFER, this->vertexbuffer);
glBufferData(GL_ARRAY_BUFFER, this->vertices.size() * sizeof(glm::vec3), &vertices[0], GL_STATIC_DRAW);
@@ -30,6 +41,13 @@ void lazik::loadModel() {
void lazik::draw() {
// glEnable(GL_TEXTURE_2D);
// // Bind our texture in Texture Unit 0
// glActiveTexture(GL_TEXTURE0);
// glBindTexture(GL_TEXTURE_2D, Texture);
// // Set our "myTextureSampler" sampler to use Texture Unit 0
// glUniform1i(TextureID, 0);
// 1st attribute buffer: vertices
glEnableVertexAttribArray(0);
glBindBuffer(GL_ARRAY_BUFFER, this->vertexbuffer);
@@ -57,11 +75,19 @@ void lazik::draw() {
// Draw vertices
glDrawArrays(GL_TRIANGLES, 0, this->vertices.size());
// glDisable(GL_TEXTURE_2D);
glDisableVertexAttribArray(0);
glDisableVertexAttribArray(1);
}
void lazik::unload(){
glDeleteBuffers(1, &this->vertexbuffer);
glDeleteBuffers(1, &this->uvbuffer);
// glDeleteTextures(1, &this->Texture);
}
void lazik::moveX(float x){
// TODO: dodać timer do poniższych funkcji, aby czas przejścia z punktu A do B był uniezależniony od FPSów
timestampedCout("dummy moveX");