first attempt to bind texture
This commit is contained in:
22
gl/Texture.cpp
Normal file
22
gl/Texture.cpp
Normal 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
19
gl/Texture.h
Normal 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
|
@ -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 {
|
||||
|
Reference in New Issue
Block a user