| @@ -67,10 +67,12 @@ data/windows/Carla | |||||
| data/windows/CarlaControl | data/windows/CarlaControl | ||||
| source/tests/ANSI | source/tests/ANSI | ||||
| source/tests/CarlaString | source/tests/CarlaString | ||||
| source/tests/DGL | |||||
| source/tests/DGL1 | |||||
| source/tests/DGL2 | |||||
| source/tests/Print | source/tests/Print | ||||
| source/tests/RtList | source/tests/RtList | ||||
| source/tests/Utils | source/tests/Utils | ||||
| source/tests/dgl-neko-test* | |||||
| # Docs | # Docs | ||||
| doc/CarlaBackend/ | doc/CarlaBackend/ | ||||
| @@ -0,0 +1,61 @@ | |||||
| /* | |||||
| * Carla Tests | |||||
| * Copyright (C) 2013 Filipe Coelho <falktx@falktx.com> | |||||
| * | |||||
| * This program is free software; you can redistribute it and/or | |||||
| * modify it under the terms of the GNU General Public License as | |||||
| * published by the Free Software Foundation; either version 2 of | |||||
| * the License, or any later version. | |||||
| * | |||||
| * This program is distributed in the hope that it will be useful, | |||||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
| * GNU General Public License for more details. | |||||
| * | |||||
| * For a full copy of the GNU General Public License see the GPL.txt file | |||||
| */ | |||||
| #include "dgl/Image.hpp" | |||||
| #include "dgl/StandaloneWindow.hpp" | |||||
| #include "DGL1_Artwork.hpp" | |||||
| USE_NAMESPACE_DGL; | |||||
| class MyWidget : public Widget | |||||
| { | |||||
| public: | |||||
| MyWidget(StandaloneWindow* win) | |||||
| : Widget(win->getWindow()), | |||||
| fWindow(win->getWindow()) | |||||
| { | |||||
| { | |||||
| using namespace DGL1_Artwork; | |||||
| fImage.loadFromMemory(start_here_kxstudioData, | |||||
| Size<int>(start_here_kxstudioWidth, start_here_kxstudioHeight), | |||||
| GL_BGRA, GL_UNSIGNED_BYTE); | |||||
| } | |||||
| fWindow->setSize(fImage.getWidth(), fImage.getHeight()); | |||||
| fWindow->setWindowTitle("DGL Test"); | |||||
| } | |||||
| protected: | |||||
| void onDisplay() override | |||||
| { | |||||
| fImage.draw(); | |||||
| } | |||||
| private: | |||||
| Window* const fWindow; | |||||
| Image fImage; | |||||
| }; | |||||
| int main() | |||||
| { | |||||
| StandaloneWindow win; | |||||
| MyWidget widget(&win); | |||||
| win.exec(); | |||||
| return 0; | |||||
| } | |||||
| @@ -0,0 +1,15 @@ | |||||
| /* (Auto-generated binary data file). */ | |||||
| #ifndef BINARY_DGL1_ARTWORK_HPP | |||||
| #define BINARY_DGL1_ARTWORK_HPP | |||||
| namespace DGL1_Artwork | |||||
| { | |||||
| extern const char* start_here_kxstudioData; | |||||
| const unsigned int start_here_kxstudioDataSize = 262144; | |||||
| const unsigned int start_here_kxstudioWidth = 256; | |||||
| const unsigned int start_here_kxstudioHeight = 256; | |||||
| } | |||||
| #endif // BINARY_DGL1_ARTWORK_HPP | |||||
| @@ -0,0 +1,221 @@ | |||||
| /* | |||||
| * Carla Tests | |||||
| * Copyright (C) 2013 Filipe Coelho <falktx@falktx.com> | |||||
| * | |||||
| * This program is free software; you can redistribute it and/or | |||||
| * modify it under the terms of the GNU General Public License as | |||||
| * published by the Free Software Foundation; either version 2 of | |||||
| * the License, or any later version. | |||||
| * | |||||
| * This program is distributed in the hope that it will be useful, | |||||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
| * GNU General Public License for more details. | |||||
| * | |||||
| * For a full copy of the GNU General Public License see the GPL.txt file | |||||
| */ | |||||
| #include "dgl/Image.hpp" | |||||
| #include "dgl/StandaloneWindow.hpp" | |||||
| #include "CarlaUtils.hpp" | |||||
| #include "NekoArtwork.hpp" | |||||
| // this is just a test file! | |||||
| #include <QtCore/QThread> | |||||
| USE_NAMESPACE_DGL; | |||||
| class NekoWidget : public Widget, | |||||
| QThread | |||||
| { | |||||
| public: | |||||
| NekoWidget(StandaloneWindow* win) | |||||
| : Widget(win->getWindow()), | |||||
| fPos(0), | |||||
| fTimer(0), | |||||
| fTimerSpeed(20), | |||||
| fCurAction(kActionNone), | |||||
| fCurImage(&fImages.sit) | |||||
| { | |||||
| // load images | |||||
| { | |||||
| using namespace NekoArtwork; | |||||
| fImages.background.loadFromMemory(backgroundData, backgroundWidth, backgroundHeight, GL_BGR); | |||||
| #define JOIN(a, b) a ## b | |||||
| #define LOAD_IMAGE(NAME) fImages.NAME.loadFromMemory(JOIN(NAME, Data), JOIN(NAME, Width), JOIN(NAME, Height)); | |||||
| LOAD_IMAGE(sit) | |||||
| LOAD_IMAGE(tail) | |||||
| LOAD_IMAGE(claw1) | |||||
| LOAD_IMAGE(claw2) | |||||
| LOAD_IMAGE(scratch1) | |||||
| LOAD_IMAGE(scratch2) | |||||
| LOAD_IMAGE(run1) | |||||
| LOAD_IMAGE(run2) | |||||
| LOAD_IMAGE(run3) | |||||
| LOAD_IMAGE(run4) | |||||
| #undef JOIN | |||||
| #undef LOAD_IMAGE | |||||
| } | |||||
| QThread::start(); | |||||
| } | |||||
| ~NekoWidget() | |||||
| { | |||||
| hide(); | |||||
| QThread::quit(); | |||||
| QThread::wait(); | |||||
| } | |||||
| protected: | |||||
| void onDisplay() override | |||||
| { | |||||
| int x = fPos+118; | |||||
| int y = -2; | |||||
| if (fCurImage == &fImages.claw1 || fCurImage == &fImages.claw2) | |||||
| { | |||||
| x += 2; | |||||
| y += 12; | |||||
| } | |||||
| fImages.background.draw(); | |||||
| fCurImage->draw(x, y); | |||||
| } | |||||
| void idle() | |||||
| { | |||||
| if (++fTimer % fTimerSpeed != 0) // target is 25ms | |||||
| return; | |||||
| if (fTimer == fTimerSpeed*9) | |||||
| { | |||||
| if (fCurAction == kActionNone) | |||||
| fCurAction = static_cast<Action>(rand() % kActionCount); | |||||
| else | |||||
| fCurAction = kActionNone; | |||||
| fTimer = 0; | |||||
| } | |||||
| switch (fCurAction) | |||||
| { | |||||
| case kActionNone: | |||||
| if (fCurImage == &fImages.sit) | |||||
| fCurImage = &fImages.tail; | |||||
| else | |||||
| fCurImage = &fImages.sit; | |||||
| break; | |||||
| case kActionClaw: | |||||
| if (fCurImage == &fImages.claw1) | |||||
| fCurImage = &fImages.claw2; | |||||
| else | |||||
| fCurImage = &fImages.claw1; | |||||
| break; | |||||
| case kActionScratch: | |||||
| if (fCurImage == &fImages.scratch1) | |||||
| fCurImage = &fImages.scratch2; | |||||
| else | |||||
| fCurImage = &fImages.scratch1; | |||||
| break; | |||||
| case kActionRunRight: | |||||
| if (fTimer == 0 && fPos > 20*9) | |||||
| { | |||||
| // run the other way | |||||
| --fTimer; | |||||
| fCurAction = kActionRunLeft; | |||||
| idle(); | |||||
| break; | |||||
| } | |||||
| fPos += 20; | |||||
| if (fCurImage == &fImages.run1) | |||||
| fCurImage = &fImages.run2; | |||||
| else | |||||
| fCurImage = &fImages.run1; | |||||
| break; | |||||
| case kActionRunLeft: | |||||
| if (fTimer == 0 && fPos < 20*9) | |||||
| { | |||||
| // run the other way | |||||
| --fTimer; | |||||
| fCurAction = kActionRunRight; | |||||
| idle(); | |||||
| break; | |||||
| } | |||||
| fPos -= 20; | |||||
| if (fCurImage == &fImages.run3) | |||||
| fCurImage = &fImages.run4; | |||||
| else | |||||
| fCurImage = &fImages.run3; | |||||
| break; | |||||
| case kActionCount: | |||||
| break; | |||||
| } | |||||
| repaint(); | |||||
| } | |||||
| void run() override | |||||
| { | |||||
| while (isVisible()) | |||||
| { | |||||
| idle(); | |||||
| carla_msleep(10); | |||||
| } | |||||
| } | |||||
| private: | |||||
| enum Action { | |||||
| kActionNone, // bounce tail | |||||
| kActionClaw, | |||||
| kActionScratch, | |||||
| kActionRunRight, | |||||
| kActionRunLeft, | |||||
| kActionCount | |||||
| }; | |||||
| struct Images { | |||||
| Image background; | |||||
| Image sit; | |||||
| Image tail; | |||||
| Image claw1; | |||||
| Image claw2; | |||||
| Image scratch1; | |||||
| Image scratch2; | |||||
| Image run1; | |||||
| Image run2; | |||||
| Image run3; | |||||
| Image run4; | |||||
| } fImages; | |||||
| int fPos; | |||||
| int fTimer; | |||||
| int fTimerSpeed; | |||||
| Action fCurAction; | |||||
| Image* fCurImage; | |||||
| }; | |||||
| int main() | |||||
| { | |||||
| StandaloneWindow win; | |||||
| win.setSize(NekoArtwork::backgroundWidth, NekoArtwork::backgroundHeight); | |||||
| win.setWindowTitle("Neko Test"); | |||||
| NekoWidget widget(&win); | |||||
| win.exec(); | |||||
| return 0; | |||||
| } | |||||
| @@ -0,0 +1,65 @@ | |||||
| /* (Auto-generated binary data file). */ | |||||
| #ifndef BINARY_NEKOARTWORK_HPP | |||||
| #define BINARY_NEKOARTWORK_HPP | |||||
| namespace NekoArtwork | |||||
| { | |||||
| extern const char* backgroundData; | |||||
| const unsigned int backgroundDataSize = 206064; | |||||
| const unsigned int backgroundWidth = 636; | |||||
| const unsigned int backgroundHeight = 108; | |||||
| extern const char* claw1Data; | |||||
| const unsigned int claw1DataSize = 4096; | |||||
| const unsigned int claw1Width = 32; | |||||
| const unsigned int claw1Height = 32; | |||||
| extern const char* claw2Data; | |||||
| const unsigned int claw2DataSize = 4096; | |||||
| const unsigned int claw2Width = 32; | |||||
| const unsigned int claw2Height = 32; | |||||
| extern const char* run1Data; | |||||
| const unsigned int run1DataSize = 4096; | |||||
| const unsigned int run1Width = 32; | |||||
| const unsigned int run1Height = 32; | |||||
| extern const char* run2Data; | |||||
| const unsigned int run2DataSize = 4096; | |||||
| const unsigned int run2Width = 32; | |||||
| const unsigned int run2Height = 32; | |||||
| extern const char* run3Data; | |||||
| const unsigned int run3DataSize = 4096; | |||||
| const unsigned int run3Width = 32; | |||||
| const unsigned int run3Height = 32; | |||||
| extern const char* run4Data; | |||||
| const unsigned int run4DataSize = 4096; | |||||
| const unsigned int run4Width = 32; | |||||
| const unsigned int run4Height = 32; | |||||
| extern const char* scratch1Data; | |||||
| const unsigned int scratch1DataSize = 4096; | |||||
| const unsigned int scratch1Width = 32; | |||||
| const unsigned int scratch1Height = 32; | |||||
| extern const char* scratch2Data; | |||||
| const unsigned int scratch2DataSize = 4096; | |||||
| const unsigned int scratch2Width = 32; | |||||
| const unsigned int scratch2Height = 32; | |||||
| extern const char* sitData; | |||||
| const unsigned int sitDataSize = 4096; | |||||
| const unsigned int sitWidth = 32; | |||||
| const unsigned int sitHeight = 32; | |||||
| extern const char* tailData; | |||||
| const unsigned int tailDataSize = 4096; | |||||
| const unsigned int tailWidth = 32; | |||||
| const unsigned int tailHeight = 32; | |||||
| } | |||||
| #endif // BINARY_NEKOARTWORK_HPP | |||||