23 std::uint32_t width, std::uint32_t height)
25 std::vector<std::uint8_t> pixels(width * height * 4);
26 constexpr std::uint32_t cellSize = 32;
28 for (std::uint32_t y = 0; y < height; ++y)
30 for (std::uint32_t x = 0; x < width; ++x)
33 ((x / cellSize) + (y / cellSize)) % 2 == 0;
34 const std::uint8_t c = light ? 230 : 55;
35 const std::size_t i = (y * width + x) * 4;
44 glCreateTextures(GL_TEXTURE_2D, 1, &m_RendererID);
45 glTextureStorage2D(m_RendererID, 1, GL_RGBA8, width, height);
47 m_RendererID, 0, 0, 0, width, height,
48 GL_RGBA, GL_UNSIGNED_BYTE, pixels.data());
50 glTextureParameteri(m_RendererID, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
51 glTextureParameteri(m_RendererID, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
52 glTextureParameteri(m_RendererID, GL_TEXTURE_WRAP_S, GL_REPEAT);
53 glTextureParameteri(m_RendererID, GL_TEXTURE_WRAP_T, GL_REPEAT);
59 stbi_set_flip_vertically_on_load(1);
65 stbi_uc* data = stbi_load(
72 if (!data || width <= 0 || height <= 0)
74 const std::string reason =
75 stbi_failure_reason() ? stbi_failure_reason() :
"unknown error";
76 stbi_image_free(data);
77 throw std::runtime_error(
78 "NoJobEngine: could not load texture '" +
79 path +
"': " + reason);
82 glCreateTextures(GL_TEXTURE_2D, 1, &m_RendererID);
85 int size = width > height ? width : height;
110 ConfigureTexture(m_RendererID);
111 glGenerateTextureMipmap(m_RendererID);
113 stbi_image_free(data);
OpenGLTexture declarations for the OpenGL Backend subsystem.
~OpenGLTexture2D() override
void Bind(std::uint32_t slot=0) const override
OpenGLTexture2D(std::uint32_t width, std::uint32_t height)