first attempt to bind texture

This commit is contained in:
2022-02-06 14:47:33 +01:00
parent a00022523f
commit 29fc4f67d4
11 changed files with 161 additions and 16 deletions

22
gl/Texture.cpp Normal file
View File

@ -0,0 +1,22 @@
//
// Created by lukas on 06.02.22.
//
#include "Texture.h"
#include "../bmploader.h"
#define GL_GLEXT_PROTOTYPES
#include <GL/gl.h>
Texture::Texture() {
mTexturehandle = bmploader().loadBMP("../block.bmp");
}
void Texture::Bind() {
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, mTexturehandle);
}
void Texture::UnBind() {
glBindTexture(GL_TEXTURE_2D, 0);
}

19
gl/Texture.h Normal file
View File

@ -0,0 +1,19 @@
//
// Created by lukas on 06.02.22.
//
#ifndef OPENGLTEST_TEXTURE_H
#define OPENGLTEST_TEXTURE_H
class Texture {
private:
unsigned mTexturehandle;
public:
Texture();
void Bind();
void UnBind();
};
#endif //OPENGLTEST_TEXTURE_H

View File

@ -13,12 +13,14 @@ VertexArray::VertexArray(const VertexBuffer& buff) {
buff.Bind();
// generate new vertex array object
glGenVertexArrays(1, &handle);
glGenVertexArrays(2, &handle);
Bind();
// specify syntax of my data
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), (void *) nullptr);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(float), (void *) nullptr);
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 5 * sizeof(float), (void *) nullptr);
glEnableVertexAttribArray(0);
glEnableVertexAttribArray(1);
}
unsigned VertexArray::getHandle() const {