Mosaic PGE integration

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
main
Nic0Nic0Nii 9 months ago
parent 83f5e9bc3a
commit a38ef4e71d
  1. BIN
      C++ProjectTemplate.wasm
  2. 30
      main.cpp
  3. 13
      pixelGameEngine.h
  4. BIN
      pixelGameEngine_wasm.o

Binary file not shown.

@ -8,7 +8,7 @@ using namespace olc;
class Example : public olc::PixelGameEngine
{
float lastIncrease=0.f;
public:
Example()
@ -20,21 +20,29 @@ public:
olc::Key last;
bool OnUserCreate() override
{
std::cout<<"Test"<<std::endl;
ConsoleShow(olc::Key::A);
return true;
}
bool OnUserUpdate(float fElapsedTime) override
{
std::cout<<"Test 4"<<std::endl;
ConsoleCaptureStdOut(true);
std::cout<<"Test 2"<<std::endl;
ConsoleCaptureStdOut(false);
std::cout<<"Test 3"<<std::endl;
std::cout<<"A"<<std::endl;
Clear(BLACK);
DrawString({0,0},std::to_string(last));
if(lastIncrease==0.f){
if(GetKey(RIGHT).bHeld){
SetMosaicEffect(GetMosaicEffect()+1);
lastIncrease=0.01f;
}
if(GetKey(LEFT).bHeld){
SetMosaicEffect(GetMosaicEffect()-1);
lastIncrease=0.01f;
}
}else{
lastIncrease=std::max(0.f,lastIncrease-fElapsedTime);
}
Clear(WHITE);
srand(48190);
for(int i=0;i<100;i++){
DrawCircle({rand()%640,rand()%480},rand()%30,{uint8_t(rand()%255),uint8_t(rand()%255),uint8_t(rand()%255)});
}
DrawStringDecal({0,0},"Mosaic Effect: "+std::to_string(GetMosaicEffect()),BLACK);
return true;
}

@ -1169,6 +1169,9 @@ namespace olc
int32_t TextEntryGetCursor() const;
bool IsTextEntryEnabled() const;
const uint8_t GetMosaicEffect()const;
void SetMosaicEffect(uint8_t effectLevel);
private:
@ -1245,6 +1248,7 @@ namespace olc
std::vector<std::string> vDroppedFilesCache;
olc::vi2d vDroppedFilesPoint;
olc::vi2d vDroppedFilesPointCache;
uint8_t mosaic=0;
// Command Console Specific
bool bConsoleShow = false;
@ -3588,6 +3592,13 @@ namespace olc
bool PixelGameEngine::IsTextEntryEnabled() const
{ return bTextEntryEnable; }
const uint8_t PixelGameEngine::GetMosaicEffect()const{
return mosaic;
}
void PixelGameEngine::SetMosaicEffect(uint8_t effectLevel){
mosaic=effectLevel;
}
void PixelGameEngine::UpdateTextEntry()
{
@ -4963,7 +4974,7 @@ namespace olc
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
locUseProgram(m_nQuadShader);
GLint myUniformLocation = glGetUniformLocation(m_nQuadShader, "mosaic");
glUniform1i(myUniformLocation,0);
glUniform1i(myUniformLocation,ptrPGE->GetMosaicEffect());
locBindVertexArray(m_vaQuad);
#if defined(OLC_PLATFORM_EMSCRIPTEN)

Binary file not shown.
Loading…
Cancel
Save