WOWCube Docs logo
WOWCube Docs
Mission Control
Section Shortcuts
APIExamplesSourceWOWConnectChangelog
Filters
SDK and language defaults persist in cookies.
SDK version
Navigation Tree
Collapsed by default, focused on the active path.
Made byMcKay Seamons
GitHub
  1. Home
  2. Docs
  3. Examples
  4. GfxBitmaps.cpp
Mission NodeSDK 6.1C++renderingProject Included

GfxBitmaps.cpp

Example: GfxBitmaps.cpp

Examples / SDK 6.1 / C++ / rendering / Gfx Engine - Bitmaps / project / src
GfxBitmaps.cpp
CPP
1// This file is generated by WOWCube SDK project wizard
2
3#include <stdint.h>
4#include <string>
5#include <vector>
6#include <string>
7#include <memory>
8
9#include "AppManager.h"
10#include "GfxBitmaps.h"
11
12using namespace Cubios;
13using namespace Cubios::Math;
14using namespace Cubios::Gfx;
15
16//Applicaton initialization callback. Called once when CUB application starts
17void OnInit(Cubios::AppManager& appMgr)
18{
19 GfxBitmaps* theApp = new GfxBitmaps();
20
21 appMgr.SetApplication(theApp,"AAbbCCddEE");
22
23 theApp->InitializeResources();
24}
25
26
27GfxBitmaps::GfxBitmaps():offsets{{0,0},{240,0},{240,240},{0,240}}
28{
29}
30
31GfxBitmaps::~GfxBitmaps()
32{
33 this->Scene.DisposeAllObjects();
34}
35
36void GfxBitmaps::InitializeResources()
37{
38 //Create a Cubios::Gfx::Background object
39 this->Scene.CreateObjectWithID(GfxObjects::myBackground,new Background(0,0,0));
40
41 //Create a Cubios::Gfx::Sprite object
42
43 this->scroller.Sides[0][2] = this->Scene.CreateObject(new Sprite("s1_1.webp",Transform(120,120,0)));
44 this->scroller.Sides[0][3] = this->Scene.CreateObject(new Sprite("s1_2.webp",Transform(120,120,0)));
45 this->scroller.Sides[0][0] = this->Scene.CreateObject(new Sprite("s1_3.webp",Transform(120,120,0)));
46 this->scroller.Sides[0][1] = this->Scene.CreateObject(new Sprite("s1_4.webp",Transform(120,120,0)));
47
48 this->scroller.Sides[1][2] = this->Scene.CreateObject(new Sprite("s2_1.webp",Transform(120,120,0)));
49 this->scroller.Sides[1][3] = this->Scene.CreateObject(new Sprite("s2_2.webp",Transform(120,120,0)));
50 this->scroller.Sides[1][0] = this->Scene.CreateObject(new Sprite("s2_3.webp",Transform(120,120,0)));
51 this->scroller.Sides[1][1] = this->Scene.CreateObject(new Sprite("s2_4.webp",Transform(120,120,0)));
52
53 this->scroller.Sides[2][2] = this->Scene.CreateObject(new Sprite("s3_1.webp",Transform(120,120,0)));
54 this->scroller.Sides[2][3] = this->Scene.CreateObject(new Sprite("s3_2.webp",Transform(120,120,0)));
55 this->scroller.Sides[2][0] = this->Scene.CreateObject(new Sprite("s3_3.webp",Transform(120,120,0)));
56 this->scroller.Sides[2][1] = this->Scene.CreateObject(new Sprite("s3_4.webp",Transform(120,120,0)));
57
58 this->scroller.Sides[3][2] = this->Scene.CreateObject(new Sprite("s4_1.webp",Transform(120,120,0)));
59 this->scroller.Sides[3][3] = this->Scene.CreateObject(new Sprite("s4_2.webp",Transform(120,120,0)));
60 this->scroller.Sides[3][0] = this->Scene.CreateObject(new Sprite("s4_3.webp",Transform(120,120,0)));
61 this->scroller.Sides[3][1] = this->Scene.CreateObject(new Sprite("s4_4.webp",Transform(120,120,0)));
62
63
64 this->Scene.CreateObjectWithID(GfxObjects::myText,new Text("WOWCUBE",120,120,12,Colors::gold));
65
66}
67
68//This callback is called every "tick" of cubeapp application loop
69void GfxBitmaps::on_Tick(uint32_t currentTime, uint32_t deltaTime)
70{
71 if(this->Module==0)
72 {
73 this->scroller.Tick();
74
75 //Send the position to other modules
76 this->networkMessage.Reset(true);
77 this->networkMessage.WriteInt(this->scroller.Offset,32);
78 this->SendNetworkMessage(0, &this->networkMessage);
79 }
80}
81
82//This callback is called every time device is about to render visuals. Use it for calling your rendering code.
83void GfxBitmaps::on_Render(std::array<Cubios::Screen, 3>& screens)
84{
85 Cubios::TOPOLOGY_place_t place;
86 std::vector<Sprite_t> spr;
87
88 for(auto it = screens.begin(); it != screens.end(); ++it)
89 {
90 spr.clear();
91
92 //Start adding objects to a screen
93 it->Begin(TOPOLOGY_orientation_mode_t::ORIENTATION_MODE_GRAVITY,true);
94
95 TOPOLOGY_orientation_t dir = it->Direction();
96
97 if(dir!=TOPOLOGY_orientation_t::ORIENTATION_UP && dir!=TOPOLOGY_orientation_t::ORIENTATION_DOWN)
98 {
99 Cubios::TOPOLOGY_getPlace(this->Module, it->ID(),TOPOLOGY_orientation_mode_t::ORIENTATION_MODE_GRAVITY, &place);
100
101 //add fullscreen sprite
102 this->scroller.GetSprites(dir, place.position, &spr);
103
104 for(int i=0;i<spr.size();i++)
105 {
106 it->Add(this->Scene[this->scroller.Sides[spr[i].side][spr[i].place]])->SetPosition(spr[i].xOffset,120);
107 }
108 }
109 else
110 {
111 it->Add(Scene[myBackground]);
112 }
113
114 //Finish adding objects
115 it->End();
116 }
117}
118
119//The "physics" callback. Gets called recurrently with at least 33ms resolution or less depending on the load.
120void GfxBitmaps::on_PhysicsTick(const std::array<Cubios::Screen, 3>& screens)
121{
122}
123
124//This callback is called on programmable timer (if any)
125void GfxBitmaps::on_Timer(uint8_t timerID)
126{
127}
128
129//The cube topology change callback. Gets called when cube is twisted and its topological desctiption has been changed
130void GfxBitmaps::on_Twist(const Cubios::TOPOLOGY_twistInfo_t& twist)
131{
132}
133
134//The "inner network" callback. Gets called when WOWCube module receives a data packet from other module
135void GfxBitmaps::on_Message(uint32_t type, uint8_t* pkt, u32_t size)
136{
137 NetworkMessage nm(pkt,size);
138
139 if(this->Module!=0)
140 {
141 this->scroller.Offset = nm.ReadInt(32);
142 }
143
144}
145
146//The external data transfer callback. Gets called when WOWCube module receives a data over BLE from an external source
147void GfxBitmaps::on_ExternalMessage(uint8_t* pkt, u32_t size)
148{
149}
150
151//Screen tap callback
152void GfxBitmaps::on_Tap(uint32_t count)
153{
154}
Wrapped for easier reading. Turn wrap off to inspect exact line lengths.
Context Rail

Project files

GfxBitmaps.cpp
project/src/GfxBitmaps.cpp
GfxBitmaps.h
project/src/GfxBitmaps.h
wowcubeapp-build.json
project/wowcubeapp-build.json
Context Rail

Related nodes

GfxBitmaps.h
Examples / SDK 6.1 / C++ / rendering / Gfx Engine - Bitmaps / project / src
Gfx Engine - Bitmaps
Examples / SDK 6.1 / C++ / rendering
info.json
Examples / SDK 6.1 / C++ / rendering / Gfx Engine - Bitmaps
wowcubeapp-build.json
Examples / SDK 6.1 / C++ / rendering / Gfx Engine - Bitmaps / project
Previous Node
info.json
Examples / SDK 6.1 / C++ / rendering / Gfx Engine - Bitmaps
Next Node
GfxBitmaps.h
Examples / SDK 6.1 / C++ / rendering / Gfx Engine - Bitmaps / project / src