1 min
Getting multiple sprites rendering on the screen for each player was my target today. I was over thinking all the time as with direct x it renders sprites using a batch, so it has a batch of sprites which is sent to the renderer to be rendered. Since I had done the splitscreen by having multiple viewports and cameras which render all the obejcts separately. I applied this logic to the sprites thinking I needed multiple batches to render the sprites on different viewports, so I implemented this and realized that if each player has its own sprite batch, then every sprite for every player will get added to each batch. So every player will render every sprite. Also the renderer would receive multiple batches so it would be horribly inefficient.
A simple solution was realized, as all that was needed was one batch with each sprite being made into an array. The viewport the sprite batch uses being separate from the viewports for rendering the 3D models and positioning each sprite in the array over the viewport correlating with the number in the sprite array and viewport array.
test[i] = new ImageGO2D(_RD, "twist");
test[i]->SetScale(0.25f*Vector2::One);
test[i]->SetPos(Vector2(_WD->m_viewport[i].TopLeftX, _WD->m_viewport[i].TopLeftY));
m_2DObjects.push_back(test[i]);
Subscribe to this blog via RSS.
Low level programming dev diary 28
Text based adventure dev diary 6
Level design developer diary 3
Game engine programming dev diary 14
Audio-visual production dev diary 7
Audio-Visual Production: Particle System Mesh Spawning Issues
Posted on 20 Feb 2020Low level programming dev diary (28) Text based adventure dev diary (6) Level design developer diary (3) Post mortem (4) Ex-machina dev diary (11) Game engine programming dev diary (14) Network game dev diary (11) Audio-visual production dev diary (7)