14 :
Layer(COVER_FULL, Z_BACKGROUND)
16 , noiseTexture(true, true)
20 std::uniform_int_distribution<int> distribution(0, 255);
21 std::array<uint8_t, 128 * 128> buf;
23#if OPENGL_VERSION < OPENGL_3_3
24 glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, 128, 128, 0,
25 GL_LUMINANCE, GL_UNSIGNED_BYTE, buf.data());
28 glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, 128, 128, 0,
29 GL_RED, GL_UNSIGNED_BYTE, buf.data());
30 GLint swizzleMask[] = {GL_RED, GL_RED, GL_RED, GL_ONE};
31 glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
34 static constexpr std::array pos = {
44 glBindBuffer(GL_ARRAY_BUFFER, vbo[0].get());
45 glBufferData(GL_ARRAY_BUFFER,
sizeof(pos), pos.data(), GL_STATIC_DRAW);
46 glBindBuffer(GL_ARRAY_BUFFER, 0);
53 static unsigned cnt = 0;
57 const std::array tex = {
58 offset +
vec2(0.0f, 2.0f),
59 offset +
vec2(2.0f, 2.0f),
60 offset +
vec2(2.0f, 0.0f),
61 offset +
vec2(0.0f, 0.0f),
65 glContext.progTex.activate();
66 glUniform4f(glContext.unifTexColor, 1.0f, 1.0f, 1.0f, 1.0f);
68 glUniformMatrix4fv(glContext.unifTexMvp, 1, GL_FALSE, &I[0][0]);
70 glBindBuffer(GL_ARRAY_BUFFER, vbo[0].get());
71 const vec2* base =
nullptr;
72 glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, base + 4 * cnt);
73 glEnableVertexAttribArray(0);
75 glBindBuffer(GL_ARRAY_BUFFER, vbo[1].get());
76 glBufferData(GL_ARRAY_BUFFER,
sizeof(tex), tex.data(), GL_STREAM_DRAW);
77 glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 0,
nullptr);
78 glEnableVertexAttribArray(1);
81 glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
82 glDisableVertexAttribArray(1);
83 glDisableVertexAttribArray(0);
84 glBindBuffer(GL_ARRAY_BUFFER, 0);
void bind()
Makes this texture the active GL texture.
Represents the output window/screen of openMSX.
void repaintDelayed(uint64_t delta)
void paint(OutputSurface &output) override
Paint this layer.
Interface for display layers.
A frame buffer where pixels can be written to.
std::optional< Context > context
This file implemented 3 utility functions:
void generate(ForwardRange &&range, Generator &&g)
auto & global_urng()
Return reference to a (shared) global random number generator.
float random_float(float from, float upto)
Return a random float in the range [from, upto) (note: half-open interval).