Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- TextureParameter param;
- param.magFilter = GL_NEAREST;
- param.minFilter = GL_NEAREST;
- param.wrapS = GL_REPEAT;
- param.wrapT = GL_REPEAT;
- Texture noiseTexture (500, 500, PixelFormat::BLACK_WHITE, param, data);
- enum class PixelFormat : GLenum
- {
- RGB = GL_RGB,
- RGBA = GL_RGBA,
- BLACK_WHITE = GL_RED
- };
- TextureRender TextureRender::create(Texture& texture, PixelFormat storFrom, uint32_t width, uint32_t height)
- {
- TextureRender textureRender;
- textureRender._width = width;
- textureRender._height = height;
- textureRender._locked = false;
- textureRender._sorageFormat = storFrom;
- glGenTextures(1, &textureRender._handler);
- glBindTexture(GL_TEXTURE_2D, textureRender._handler);
- glTexStorage2D(GL_TEXTURE_2D, 1, GL_R8, width, height);
- glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, (GLenum) texture._format, GL_UNSIGNED_BYTE, texture._data);
- assert(!glGetError());
- glTextureParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, texture._parametr.magFilter);
- glTextureParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, texture._parametr.minFilter);
- glTextureParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_R, texture._parametr.wrapS);
- glTextureParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, texture._parametr.wrapT);
- return textureRender;
- }
Add Comment
Please, Sign In to add comment