Mosaic PGE integration

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
main
Nic0Nic0Nii 1 year 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 class Example : public olc::PixelGameEngine
{ {
float lastIncrease=0.f;
public: public:
Example() Example()
@ -20,21 +20,29 @@ public:
olc::Key last; olc::Key last;
bool OnUserCreate() override bool OnUserCreate() override
{ {
std::cout<<"Test"<<std::endl;
ConsoleShow(olc::Key::A);
return true; return true;
} }
bool OnUserUpdate(float fElapsedTime) override bool OnUserUpdate(float fElapsedTime) override
{ {
std::cout<<"Test 4"<<std::endl; if(lastIncrease==0.f){
ConsoleCaptureStdOut(true); if(GetKey(RIGHT).bHeld){
std::cout<<"Test 2"<<std::endl; SetMosaicEffect(GetMosaicEffect()+1);
ConsoleCaptureStdOut(false); lastIncrease=0.01f;
std::cout<<"Test 3"<<std::endl; }
std::cout<<"A"<<std::endl; if(GetKey(LEFT).bHeld){
Clear(BLACK); SetMosaicEffect(GetMosaicEffect()-1);
DrawString({0,0},std::to_string(last)); 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; return true;
} }

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

Binary file not shown.
Loading…
Cancel
Save