69#ifndef OLC_PGEX_SHADER_H
70#define OLC_PGEX_SHADER_H
72#if !defined(OLC_GFX_OPENGL33)
73#error The olc::Shader Extension requires the OpenGL 3.3 Renderer to be specified!
76#if !defined(OLC_USING_PGEX_SHADER)
77#define OLC_USING_PGEX_SHADER
81#define OLC_GFX_OPENGL33
92 const std::vector<std::tuple<std::string, std::string, std::string>>
vAttributes;
99#if defined(__arm__) || defined(OLC_PLATFORM_EMSCRIPTEN)
100#define SHADER_HEADER "#version 300 es \n" \
101 "precision mediump float;\n"
103#define SHADER_HEADER "#version 330 core \n"
107#define DEFAULT_VS "void main() \n" \
109 " float p = 1.0 / inPos.z; \n" \
110 " gl_Position = p * vec4(inPos.x, inPos.y, 0.0, 1.0); \n" \
111 " xUV1 = p * inUV1; \n" \
112 " xCol = inCol; \n" \
115#define DEFAULT_PS "void main() \n" \
117 " pix_out = texture(tex1, xUV1) * xCol; \n" \
120 static EffectConfig FX_NORMAL =
128 static EffectConfig FX_GREYSCALE =
133 " vec4 o = texture(tex1, xUV1) * xCol; \n"
134 " float lum = o.r * 0.2126 + o.g * 0.7152 + o.b * 0.0722; \n"
135 " pix_out = vec4(lum, lum, lum, o.a); \n"
141 static EffectConfig FX_BOXBLUR =
147 " vec2 texelSize = 1.0 / vec2(textureSize(tex1, 0)); \n"
149 " for (int x = -box_width; x < +box_width; ++x) \n"
151 " for (int y = -box_width; y < +box_width; ++y) \n"
153 " vec2 offset = vec2(float(x), float(y)) * texelSize; \n"
154 " result += texture(tex1, xUV1 + offset); \n"
157 " pix_out = (result / (4.0 * float(box_width * box_width))) * xCol; \n"
163 {
"box_width",
"int",
"4"},
167 static EffectConfig FX_THRESHOLD =
173 " vec4 o = texture(tex1, xUV1) * xCol; \n"
174 " float lum = o.r * 0.2126 + o.g * 0.7152 + o.b * 0.0722; \n"
175 " pix_out = (lum > threshold) ? vec4(1, 1, 1, 1) : vec4(0,0,0,1); \n"
181 {
"threshold",
"float",
"0.5"},
186 static EffectConfig FX_SCANLINE =
192 " float scanline = sin(xUV1.y * frequency + phase) * intensity; \n"
193 " pix_out = (texture(tex1, xUV1) + vec4(scanline, scanline, scanline, 0.0)) * xCol; \n"
198 {
"frequency",
"float",
"400.0"},
199 {
"intensity",
"float",
"0.4"},
200 {
"phase",
"float",
"0.0"}
205 static EffectConfig FX_SOBEL =
209 "void make_kernel(inout vec4 n[9], sampler2D tex, vec2 coord) \n"
211 " vec2 texel = 1.0 / vec2(textureSize(tex, 0)); \n"
214 " n[0] = texture2D(tex, coord + vec2(-texel.x, -texel.y)); \n"
215 " n[1] = texture2D(tex, coord + vec2(0.0, -texel.y)); \n"
216 " n[2] = texture2D(tex, coord + vec2(texel.x, -texel.y)); \n"
217 " n[3] = texture2D(tex, coord + vec2(-texel.x, 0.0)); \n"
218 " n[4] = texture2D(tex, coord); \n"
219 " n[5] = texture2D(tex, coord + vec2(texel.x, 0.0)); \n"
220 " n[6] = texture2D(tex, coord + vec2(-texel.x, texel.y)); \n"
221 " n[7] = texture2D(tex, coord + vec2(0.0, texel.y)); \n"
222 " n[8] = texture2D(tex, coord + vec2(texel.x, texel.y)); \n"
228 " make_kernel(n, tex1, xUV1); \n"
230 " vec4 sobel_edge_h = n[2] + (2.0 * n[5]) + n[8] - (n[0] + (2.0 * n[3]) + n[6]); \n"
231 " vec4 sobel_edge_v = n[0] + (2.0 * n[1]) + n[2] - (n[6] + (2.0 * n[7]) + n[8]); \n"
232 " vec4 sobel = sqrt((sobel_edge_h * sobel_edge_h) + (sobel_edge_v * sobel_edge_v)); \n"
234 " pix_out = vec4(1.0 - sobel.rgb, 1.0); \n"
259 void SetResourceIDs(
const uint32_t
id,
const uint32_t vsid,
const uint32_t psid);
260 void SetSlots(
const uint32_t nInput,
const uint32_t nTarget);
292 void DrawPolygonDecal(
olc::Decal* decal,
const std::vector<olc::vf2d>& pos,
const std::vector<olc::vf2d>& uv,
const std::vector<olc::Pixel>& colours);
304 int nTargetResID = 0;
310 std::array<sResourceSlot, 8> slotTarget;
311 std::array<sResourceSlot, 8> slotSource;
327 uint32_t m_nEffectID = 0;
329 int32_t RenderDecal();
334 const std::vector<olc::Decal*>& decals,
335 const std::vector<olc::vf2d>& pos,
336 const std::vector<olc::vf2d>& uv,
337 const std::vector<olc::Pixel>& colours,
340 void ClearAllSlots();
342 olc::Effect ConstructShader(
const std::string& sVS,
const std::string& sPS);
345 locCreateShader_t* locCreateShader =
nullptr;
346 locShaderSource_t* locShaderSource =
nullptr;
347 locCompileShader_t* locCompileShader =
nullptr;
348 locDeleteShader_t* locDeleteShader =
nullptr;
349 locCreateProgram_t* locCreateProgram =
nullptr;
350 locDeleteProgram_t* locDeleteProgram =
nullptr;
351 locLinkProgram_t* locLinkProgram =
nullptr;
352 locAttachShader_t* locAttachShader =
nullptr;
353 locBindBuffer_t* locBindBuffer =
nullptr;
354 locBufferData_t* locBufferData =
nullptr;
355 locGenBuffers_t* locGenBuffers =
nullptr;
356 locVertexAttribPointer_t* locVertexAttribPointer =
nullptr;
357 locEnableVertexAttribArray_t* locEnableVertexAttribArray =
nullptr;
358 locUseProgram_t* locUseProgram =
nullptr;
359 locBindVertexArray_t* locBindVertexArray =
nullptr;
360 locGenVertexArrays_t* locGenVertexArrays =
nullptr;
361 locSwapInterval_t* locSwapInterval =
nullptr;
362 locGetShaderInfoLog_t* locGetShaderInfoLog =
nullptr;
363 locGetUniformLocation_t* glGetUniformLocation =
nullptr;
364 locUniform1f_t* locUniform1f =
nullptr;
365 locUniform1i_t* locUniform1i =
nullptr;
366 locUniform2fv_t* locUniform2fv =
nullptr;
367 locGenFrameBuffers_t* locGenFrameBuffers =
nullptr;
368 locBindFrameBuffer_t* locBindFrameBuffer =
nullptr;
369 locCheckFrameBufferStatus_t* locCheckFrameBufferStatus =
nullptr;
370 locDeleteFrameBuffers_t* locDeleteFrameBuffers =
nullptr;
371 locFrameBufferTexture2D_t* locFrameBufferTexture2D =
nullptr;
372 locActiveTexture_t* locActiveTexture =
nullptr;
373 locDrawBuffers_t* locDrawBuffers =
nullptr;
374 locBlendFuncSeparate_t* locBlendFuncSeparate =
nullptr;
385#ifdef OLC_PGEX_SHADERS
386#undef OLC_PGEX_SHADERS
435 olc::Effect Shade::ConstructShader(
const std::string& sVS,
const std::string& sPS)
440 GLsizei nLogSize = 0;
443 GLuint vs_id = locCreateShader(0x8B31);
444 const GLchar* vs_str = sVS.c_str();
445 locShaderSource(vs_id, 1, &vs_str, NULL);
446 locCompileShader(vs_id);
449 locGetShaderInfoLog(vs_id, 512, &nLogSize, sError);
456 GLuint ps_id = locCreateShader(0x8B30);
457 const GLchar* ps_str = sPS.c_str();
458 locShaderSource(ps_id, 1, &ps_str, NULL);
459 locCompileShader(ps_id);
462 locGetShaderInfoLog(ps_id, 512, &nLogSize, sError);
469 GLuint sh_id = locCreateProgram();
470 locAttachShader(sh_id, ps_id);
471 locAttachShader(sh_id, vs_id);
472 locLinkProgram(sh_id);
475 locGetShaderInfoLog(sh_id, 512, &nLogSize, sError);
490 std::string sVertexShader =
492 "layout(location = 0) in vec3 inPos; \n"
493 "layout(location = 1) in vec4 inCol; \n";
495 for (
size_t i = 0; i < premade.
nInputs; i++)
497 sVertexShader.append(
"layout(location = " + std::to_string(2 + i) +
") in vec2 inUV" + std::to_string(1 + i) +
"; \n");
500 for (
size_t i = 0; i < premade.
nInputs; i++)
502 sVertexShader.append(
"out vec2 xUV" + std::to_string(1 + i) +
"; \n");
505 sVertexShader.append(
"out vec4 xCol; \n");
510 std::string sPixelShader =
514 for (
size_t i = 0; i < premade.
nInputs; i++)
516 sPixelShader.append(
"in vec2 xUV" + std::to_string(1 + i) +
"; \n");
519 for (
size_t i = 0; i < premade.
nInputs; i++)
521 sPixelShader.append(
"uniform sampler2D tex" + std::to_string(1 + i) +
";\n");
524 for (
const auto& attribute : premade.vAttributes)
526 sPixelShader.append(
"uniform " + std::get<1>(attribute) +
" " + std::get<0>(attribute) +
" = " + std::get<2>(attribute) +
";\n");
529 sPixelShader.append(
"out vec4 pix_out;\n");
532 olc::Effect effect = ConstructShader(sVertexShader, sPixelShader);
541 locCreateShader = OGL_LOAD(locCreateShader_t, glCreateShader);
542 locCompileShader = OGL_LOAD(locCompileShader_t, glCompileShader);
543 locShaderSource = OGL_LOAD(locShaderSource_t, glShaderSource);
544 locDeleteShader = OGL_LOAD(locDeleteShader_t, glDeleteShader);
545 locCreateProgram = OGL_LOAD(locCreateProgram_t, glCreateProgram);
546 locDeleteProgram = OGL_LOAD(locDeleteProgram_t, glDeleteProgram);
547 locLinkProgram = OGL_LOAD(locLinkProgram_t, glLinkProgram);
548 locAttachShader = OGL_LOAD(locAttachShader_t, glAttachShader);
549 locBindBuffer = OGL_LOAD(locBindBuffer_t, glBindBuffer);
550 locBufferData = OGL_LOAD(locBufferData_t, glBufferData);
551 locGenBuffers = OGL_LOAD(locGenBuffers_t, glGenBuffers);
552 locVertexAttribPointer = OGL_LOAD(locVertexAttribPointer_t, glVertexAttribPointer);
553 locEnableVertexAttribArray = OGL_LOAD(locEnableVertexAttribArray_t, glEnableVertexAttribArray);
554 locUseProgram = OGL_LOAD(locUseProgram_t, glUseProgram);
555 locGetShaderInfoLog = OGL_LOAD(locGetShaderInfoLog_t, glGetShaderInfoLog);
558 locGenFrameBuffers = OGL_LOAD(locGenFrameBuffers_t, glGenFramebuffers);
559 locBindFrameBuffer = OGL_LOAD(locBindFrameBuffer_t, glBindFramebuffer);
560 locCheckFrameBufferStatus = OGL_LOAD(locCheckFrameBufferStatus_t, glCheckFramebufferStatus);
561 locDeleteFrameBuffers = OGL_LOAD(locDeleteFrameBuffers_t, glDeleteFramebuffers);
562 locFrameBufferTexture2D = OGL_LOAD(locFrameBufferTexture2D_t, glFramebufferTexture2D);
563 locActiveTexture = OGL_LOAD(locActiveTexture_t, glActiveTexture);
565 locBlendFuncSeparate = OGL_LOAD(locBlendFuncSeparate_t, glBlendFuncSeparate);
567#if !defined(OLC_PLATFORM_EMSCRIPTEN)
568 locBindVertexArray = OGL_LOAD(locBindVertexArray_t, glBindVertexArray);
569 locGenVertexArrays = OGL_LOAD(locGenVertexArrays_t, glGenVertexArrays);
570 locDrawBuffers = OGL_LOAD(locDrawBuffers_t, glDrawBuffers);
572 locBindVertexArray = glBindVertexArrayOES;
573 locGenVertexArrays = glGenVertexArraysOES;
574 locDrawBuffers = glDrawBuffersNV;
581 locGenFrameBuffers(1, (GLuint*)&m_nFBO);
584 locGenBuffers(1, &m_nVB);
585 locGenVertexArrays(1, &m_nVA);
586 locBindVertexArray(m_nVB);
588 locBindBuffer(0x8892, m_nVB);
590 locBufferData(0x8892,
sizeof(sOmniVertex) *
OLC_MAX_VERTS, verts, 0x88E0);
592 locVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE,
sizeof(sOmniVertex), (
void*)(0 *
sizeof(
float)));
593 locVertexAttribPointer(1, 4, GL_UNSIGNED_BYTE, GL_TRUE,
sizeof(sOmniVertex), (
void*)(3 *
sizeof(
float)));
594 locVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE,
sizeof(sOmniVertex), (
void*)(4 *
sizeof(
float)));
595 locVertexAttribPointer(3, 2, GL_FLOAT, GL_FALSE,
sizeof(sOmniVertex), (
void*)(6 *
sizeof(
float)));
596 locVertexAttribPointer(4, 2, GL_FLOAT, GL_FALSE,
sizeof(sOmniVertex), (
void*)(8 *
sizeof(
float)));
597 locVertexAttribPointer(5, 2, GL_FLOAT, GL_FALSE,
sizeof(sOmniVertex), (
void*)(10 *
sizeof(
float)));
598 locVertexAttribPointer(6, 2, GL_FLOAT, GL_FALSE,
sizeof(sOmniVertex), (
void*)(12 *
sizeof(
float)));
599 locVertexAttribPointer(7, 2, GL_FLOAT, GL_FALSE,
sizeof(sOmniVertex), (
void*)(14 *
sizeof(
float)));
600 locVertexAttribPointer(8, 2, GL_FLOAT, GL_FALSE,
sizeof(sOmniVertex), (
void*)(16 *
sizeof(
float)));
601 locVertexAttribPointer(9, 2, GL_FLOAT, GL_FALSE,
sizeof(sOmniVertex), (
void*)(18 *
sizeof(
float)));
603 locEnableVertexAttribArray(0);
604 locEnableVertexAttribArray(1);
605 locEnableVertexAttribArray(2);
606 locEnableVertexAttribArray(3);
607 locEnableVertexAttribArray(4);
608 locEnableVertexAttribArray(5);
609 locEnableVertexAttribArray(6);
610 locEnableVertexAttribArray(7);
611 locEnableVertexAttribArray(8);
612 locEnableVertexAttribArray(9);
614 locBindBuffer(0x8892, 0);
615 locBindVertexArray(0);
622 void Shade::ClearAllSlots()
624 slotTarget[0] = {
false, 0, {0.0f, 0.0f}, {1.0f, 1.0f} };
629 if (pDecal ==
nullptr)
631 slotSource[nSlot] = {
false, dummyTex.
Decal()->
id, {0.0f, 0.0f}, {1.0f, 1.0f} };
635 slotSource[nSlot].bInUse =
true;
636 slotSource[nSlot].nTargetResID = pDecal->
id;
637 slotSource[nSlot].vPos = vSourcePos;
638 slotSource[nSlot].vSize = vSourceSize;
641 locActiveTexture(0x84C0);
642 glBindTexture(GL_TEXTURE_2D, slotSource[nSlot].nTargetResID);
648 slotTarget[nSlot].bInUse =
true;
649 slotTarget[nSlot].nTargetResID = pDecal->
id;
651 slotTarget[nSlot].vInvSize = 1.0f / slotTarget[nSlot].vSize;
658 locBindFrameBuffer(36160U, m_nFBO);
660 std::array<GLenum, 8> attachments =
661 { { 36064U, 36065U, 36066U, 36067U, 36068U, 36069U, 36070U, 36071U } };
664 for (
const auto& a : attachments)
666 locFrameBufferTexture2D(36160U, a, GL_TEXTURE_2D, 0, 0);
670 int nTargetSlots = 0;
671 while (slotTarget[nTargetSlots].nTargetResID > 0)
675 locDrawBuffers(nTargetSlots, attachments.data());
680 locFrameBufferTexture2D(36160U, attachments[i], GL_TEXTURE_2D, slotTarget[i].nTargetResID, 0);
684 locUseProgram(pEffect->
m_nID);
687 locBindVertexArray(m_nVA);
689 glDisable(GL_DEPTH_TEST);
690 glDisable(GL_CULL_FACE);
696#if defined(OLC_PLATFORM_EMSCRIPTEN)
697 locVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE,
sizeof(sOmniVertex), 0); locEnableVertexAttribArray(0);
698 locVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE,
sizeof(sOmniVertex), (
void*)(3 *
sizeof(
float))); locEnableVertexAttribArray(1);
699 locVertexAttribPointer(2, 4, GL_UNSIGNED_BYTE, GL_TRUE,
sizeof(sOmniVertex), (
void*)(5 *
sizeof(
float))); locEnableVertexAttribArray(2);
702 glViewport(0, 0, int32_t(slotTarget[0].vSize.x), int32_t(slotTarget[0].vSize.y));
710 locBindBuffer(0x8892, 0);
711 locBindVertexArray(0);
713 locBindFrameBuffer(36160U, 0);
720 locBindBuffer(0x8892, m_nVB);
722 pVertexMem[0].pos[0] = vPos.
x;
723 pVertexMem[0].pos[1] = vPos.
y;
724 pVertexMem[0].pos[2] = 1.0f;
725 pVertexMem[0].tex[0] = { 0.0f, 0.0f };
728 pVertexMem[1].pos[0] = vPos.
x;
729 pVertexMem[1].pos[1] = vPos.
y + vSize.
y;
730 pVertexMem[1].pos[2] = 1.0f;
731 pVertexMem[1].tex[0] = { 0.0f, 1.0f };
734 pVertexMem[2].pos[0] = vPos.
x + vSize.
x;
735 pVertexMem[2].pos[1] = vPos.
y + vSize.
y;
736 pVertexMem[2].pos[2] = 1.0f;
737 pVertexMem[2].tex[0] = { 1.0f, 1.0f };
740 pVertexMem[3].pos[0] = vPos.
x + vSize.
x;
741 pVertexMem[3].pos[1] = vPos.
y;
742 pVertexMem[3].pos[2] = 1.0f;
743 pVertexMem[3].tex[0] = { 1.0f, 0.0f };
747 locBufferData(0x8892,
sizeof(sOmniVertex) * 4, pVertexMem, 0x88E0);
749 glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
757 glClearColor(
float(p.
r) / 255.0f,
float(p.
g) / 255.0f,
float(p.
b) / 255.0f,
float(p.
a) / 255.0f);
758 glClear(GL_COLOR_BUFFER_BIT);
767 (std::floor(pos.
x) * slotTarget[0].vInvSize.x) * 2.0f - 1.0f,
768 ((std::floor(pos.
y) * slotTarget[0].vInvSize.y) * 2.0f - 1.0f),
773 vScreenSpacePos.
x + (2.0f * (float(decal->
sprite->
width) * slotTarget[0].vInvSize.x)) * scale.
x,
774 vScreenSpacePos.
y + (2.0f * (float(decal->
sprite->
height) * slotTarget[0].vInvSize.y)) * scale.
y
782 di.tint = { tint, tint, tint, tint };
783 di.pos = { { vScreenSpacePos.
x, vScreenSpacePos.
y }, { vScreenSpacePos.
x, vScreenSpaceDim.
y }, { vScreenSpaceDim.
x, vScreenSpaceDim.
y }, { vScreenSpaceDim.
x, vScreenSpacePos.
y } };
784 di.uv = { { 0.0f, 0.0f}, {0.0f, 1.0f}, {1.0f, 1.0f}, {1.0f, 0.0f} };
785 di.w = { 1, 1, 1, 1 };
793 (std::floor(pos.
x) * slotTarget[0].vInvSize.x) * 2.0f - 1.0f,
794 ((std::floor(pos.
y) * slotTarget[0].vInvSize.y) * 2.0f - 1.0f)
799 vScreenSpacePos.
x + (2.0f * source_size.
x * slotTarget[0].vInvSize.x) * scale.
x,
800 vScreenSpacePos.
y + (2.0f * source_size.
y * slotTarget[0].vInvSize.y) * scale.
y
808 di.tint = { tint, tint, tint, tint };
809 di.pos = { { vScreenSpacePos.
x, vScreenSpacePos.
y }, { vScreenSpacePos.
x, vScreenSpaceDim.
y }, { vScreenSpaceDim.
x, vScreenSpaceDim.
y }, { vScreenSpaceDim.
x, vScreenSpacePos.
y } };
812 di.uv = { { uvtl.
x, uvtl.
y }, { uvtl.
x, uvbr.
y }, { uvbr.
x, uvbr.
y }, { uvbr.
x, uvtl.
y } };
821 (std::floor(pos.
x) * slotTarget[0].vInvSize.x) * 2.0f - 1.0f,
822 ((std::floor(pos.
y) * slotTarget[0].vInvSize.y) * 2.0f - 1.0f)
827 vScreenSpacePos.
x + (2.0f * source_size.
x * slotTarget[0].vInvSize.x),
828 vScreenSpacePos.
y + (2.0f * source_size.
y * slotTarget[0].vInvSize.y)
836 di.tint = { tint, tint, tint, tint };
837 di.pos = { { vScreenSpacePos.
x, vScreenSpacePos.
y }, { vScreenSpacePos.
x, vScreenSpaceDim.
y }, { vScreenSpaceDim.
x, vScreenSpaceDim.
y }, { vScreenSpaceDim.
x, vScreenSpacePos.
y } };
840 di.uv = { { uvtl.x, uvtl.y }, { uvtl.x, uvbr.y }, { uvbr.x, uvbr.y }, { uvbr.x, uvtl.y } };
848 std::vector<olc::vf2d> vTransformedPos(pos.size());
849 std::transform(pos.begin(), pos.end(), vTransformedPos.begin(),
858 void Shade::RenderPolygon(
859 const std::vector<olc::Decal*>& decals,
860 const std::vector<olc::vf2d>& pos,
861 const std::vector<olc::vf2d>& uv,
862 const std::vector<olc::Pixel>& colours,
866 for (
size_t i = 0; i < decals.size(); i++)
870 for (uint32_t i = 0; i < pos.size(); i++)
872 pVertexMem[i].pos[0] = pos[i].x;
873 pVertexMem[i].pos[1] = pos[i].y;
874 pVertexMem[i].pos[2] = 1.0f;
875 pVertexMem[i].tex[0] = uv[i];
876 pVertexMem[i].col = colours[i];
880 locBindBuffer(0x8892, m_nVB);
883 locBufferData(0x8892,
sizeof(sOmniVertex) * pos.size(), pVertexMem, 0x88E0);
889 glDrawArrays(GL_TRIANGLE_FAN, 0, GLsizei(pos.size()));
892 glDrawArrays(GL_TRIANGLES, 0, GLsizei(pos.size()));
895 glDrawArrays(GL_TRIANGLE_STRIP, 0, GLsizei(pos.size()));
903 locBindBuffer(0x8892, m_nVB);
905 for (uint32_t i = 0; i < decal.
points; i++)
907 pVertexMem[i].pos[0] = decal.
pos[i].x;
908 pVertexMem[i].pos[1] = decal.
pos[i].y;
909 pVertexMem[i].pos[2] = decal.
w[i];
910 pVertexMem[i].tex[0] = { decal.
uv[i].x, decal.
uv[i].y };
911 pVertexMem[i].col = decal.
tint[i];
915 locBufferData(0x8892,
sizeof(sOmniVertex) * decal.
points, pVertexMem, 0x88E0);
916 glDrawArrays(GL_TRIANGLE_FAN, 0, decal.
points);
Definition olcPixelGameEngine.h:1113
int32_t id
Definition olcPixelGameEngine.h:1122
olc::Sprite * sprite
Definition olcPixelGameEngine.h:1123
olc::vf2d vUVScale
Definition olcPixelGameEngine.h:1124
Definition olcPGEX_Shaders.h:246
uint32_t m_nInputSlots
Definition olcPGEX_Shaders.h:267
uint32_t m_nPSID
Definition olcPGEX_Shaders.h:264
uint32_t m_nVSID
Definition olcPGEX_Shaders.h:265
uint32_t m_nTargetSlots
Definition olcPGEX_Shaders.h:268
void SetResourceIDs(const uint32_t id, const uint32_t vsid, const uint32_t psid)
const uint32_t GetTargetSlots() const
const uint32_t GetInputSlots() const
void SetSlots(const uint32_t nInput, const uint32_t nTarget)
const std::string & GetStatus() const
std::string m_sStatus
Definition olcPGEX_Shaders.h:263
void AppendStatus(const std::string &sMsg)
uint32_t m_nID
Definition olcPGEX_Shaders.h:266
Definition olcPixelGameEngine.h:1685
Definition olcPixelGameEngine.h:1149
void Create(uint32_t width, uint32_t height, bool filter=false, bool clamp=true)
olc::Sprite * Sprite() const
olc::Decal * Decal() const
Definition olcPGEX_Shaders.h:272
olc::Effect MakeEffect(const olc::EffectConfig &premade)
void DrawDecal(const olc::vf2d &pos, olc::Decal *decal, const olc::vf2d &scale={ 1.0f, 1.0f }, const olc::Pixel &tint=olc::WHITE)
void DrawPolygonDecal(olc::Decal *decal, const std::vector< olc::vf2d > &pos, const std::vector< olc::vf2d > &uv, const std::vector< olc::Pixel > &colours)
void DrawPartialDecal(const olc::vf2d &pos, const olc::vf2d &size, olc::Decal *decal, const olc::vf2d &source_pos, const olc::vf2d &source_size, const olc::Pixel &tint=olc::WHITE)
int32_t SetSourceDecal(olc::Decal *pDecal, const uint32_t nSlot=0, const olc::vf2d &vSourcePos={ 0.0f, 0.0f }, const olc::vf2d &vSourceSize={ 1.0f, 1.0f })
void OnBeforeUserCreate() override
void Clear(const olc::Pixel &p=olc::BLANK)
int32_t DrawQuad(const olc::vf2d &vPos, const olc::vf2d &vSize)
int32_t SetTargetDecal(olc::Decal *pDecal, const uint32_t nSlot=0)
int32_t Start(olc::Effect *pEffect)
void DrawPartialDecal(const olc::vf2d &pos, olc::Decal *decal, const olc::vf2d &source_pos, const olc::vf2d &source_size, const olc::vf2d &scale={ 1.0f, 1.0f }, const olc::Pixel &tint=olc::WHITE)
int32_t height
Definition olcPixelGameEngine.h:1084
int32_t width
Definition olcPixelGameEngine.h:1083
Definition olcPixelGameEngine.h:612
DecalStructure
Definition olcPixelGameEngine.h:1138
constexpr size_t OLC_MAX_VERTS
Definition olcPixelGameEngine.h:940
static const Pixel BLANK(0, 0, 0, 0)
static const Pixel WHITE(255, 255, 255)
#define DEFAULT_VS
Definition olcPGEX_Shaders.h:107
#define DEFAULT_PS
Definition olcPGEX_Shaders.h:115
#define SHADER_HEADER
Definition olcPGEX_Shaders.h:103
Definition olcPixelGameEngine.h:1172
std::vector< olc::Pixel > tint
Definition olcPixelGameEngine.h:1178
std::vector< float > w
Definition olcPixelGameEngine.h:1176
std::vector< olc::vf2d > uv
Definition olcPixelGameEngine.h:1175
std::vector< olc::vf2d > pos
Definition olcPixelGameEngine.h:1174
uint32_t points
Definition olcPixelGameEngine.h:1181
Definition olcPGEX_Shaders.h:87
const std::vector< std::tuple< std::string, std::string, std::string > > vAttributes
Definition olcPGEX_Shaders.h:92
const std::string sPixelSource
Definition olcPGEX_Shaders.h:89
const size_t nOutputs
Definition olcPGEX_Shaders.h:91
const std::string sVertexSource
Definition olcPGEX_Shaders.h:88
const size_t nInputs
Definition olcPGEX_Shaders.h:90
Definition olcPixelGameEngine.h:948
uint8_t g
Definition olcPixelGameEngine.h:952
uint8_t a
Definition olcPixelGameEngine.h:952
uint8_t b
Definition olcPixelGameEngine.h:952
uint8_t r
Definition olcPixelGameEngine.h:952
T x
Definition olcPixelGameEngine.h:623
T y
Definition olcPixelGameEngine.h:625