mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-03-22 06:55:02 +01:00
39 lines
1.0 KiB
C++
39 lines
1.0 KiB
C++
#include "stdafx.h"
|
|
#include "cubemap.h"
|
|
|
|
gl::cubemap::cubemap()
|
|
{
|
|
glGenTextures(1, *this);
|
|
|
|
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
|
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
|
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
|
|
}
|
|
|
|
gl::cubemap::~cubemap()
|
|
{
|
|
glDeleteTextures(1, *this);
|
|
}
|
|
|
|
void gl::cubemap::alloc(GLint format, int width, int height, GLenum components, GLenum type)
|
|
{
|
|
glBindTexture(GL_TEXTURE_CUBE_MAP, *this);
|
|
for (GLuint tgt = GL_TEXTURE_CUBE_MAP_POSITIVE_X; tgt <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z; tgt++)
|
|
glTexImage2D(tgt, 0, format, width, height, 0, components, type, nullptr);
|
|
|
|
glBindTexture(GL_TEXTURE_CUBE_MAP, 0);
|
|
}
|
|
|
|
void gl::cubemap::bind(int unit)
|
|
{
|
|
glActiveTexture(unit);
|
|
glBindTexture(GL_TEXTURE_CUBE_MAP, *this);
|
|
}
|
|
|
|
void gl::cubemap::generate_mipmaps()
|
|
{
|
|
glBindTexture(GL_TEXTURE_CUBE_MAP, *this);
|
|
glGenerateMipmap(GL_TEXTURE_CUBE_MAP);
|
|
glBindTexture(GL_TEXTURE_CUBE_MAP, 0);
|
|
}
|