Testing textures

This commit is contained in:
2023-05-11 23:57:08 -07:00
parent 642f1408ff
commit f44fe25011
7 changed files with 76 additions and 173 deletions

View File

@ -10,6 +10,7 @@
#include "prefabs/VNTextbox.hpp"
#include "display/TextureRenderTarget.hpp"
#include "scene/components/ui/UIImage.hpp"
#include "prefabs/EthPrefab.hpp"
namespace Dawn {
class HelloWorldScene : public Scene {
@ -19,51 +20,59 @@ namespace Dawn {
UICanvas *canvas;
TextureRenderTarget *renderTarget;
Texture text;
TilesetGrid grid;
int32_t test = 0;
void stage() override {
canvas = UICanvas::create(this);
// canvas = UICanvas::create(this);
camera = Camera::create(this);
glm::vec3 off = glm::vec3(90000, 100, 100);
glm::vec3 off = glm::vec3(0, 0, 0);
camera->transform->lookAt(glm::vec3(10, 10, 10) + off, glm::vec3(0, 0, 0) + off);
camNew = Camera::create(this);
auto camTexture = camNew->item->addComponent<CameraTexture>();
camNew->fov = 0.436332f;
camNew->transform->lookAt(glm::vec3(10, 10, 10), glm::vec3(0, 0, 0));
camTexture->renderTarget.setSize(1024, 1024);
// auto textbox = VNTextbox::create(this);
// textbox->transform.setParent(canvas->transform);
auto cube = SimpleSpinningCubePrefab::create(this);
// camNew = Camera::create(this);
// auto camTexture = camNew->item->addComponent<CameraTexture>();
// camNew->fov = 0.436332f;
// camNew->transform->lookAt(glm::vec3(10, 10, 10), glm::vec3(0, 0, 0));
// camTexture->renderTarget.setSize(1024, 1024);
auto textbox = VNTextbox::create(this);
textbox->transform.setParent(canvas->transform);
// auto uiTest = this->createSceneItem();
// uiTest->transform.setParent(canvas->transform);
// auto image = uiTest->addComponent<UIImage>();
// image->texture = camTexture->renderTarget.getTexture();
// image->alignment = glm::vec4(0, 0, 50, 0);
// image->alignX = UI_COMPONENT_ALIGN_START;
// image->alignUnitRight = UI_COMPONENT_ALIGN_UNIT_PERCENT;
// image->alignY = UI_COMPONENT_ALIGN_STRETCH;
auto uiTest = this->createSceneItem();
uiTest->transform.setParent(canvas->transform);
auto image = uiTest->addComponent<UIImage>();
image->texture = camTexture->renderTarget.getTexture();
image->alignment = glm::vec4(0, 0, 50, 0);
image->alignX = UI_COMPONENT_ALIGN_START;
image->alignUnitRight = UI_COMPONENT_ALIGN_UNIT_PERCENT;
image->alignY = UI_COMPONENT_ALIGN_STRETCH;
this->grid = TilesetGrid(
1, 26,
741, 20540,
0, 0,
0, 0
);
auto eth = EthPrefab::create(this);
// eth->tiledSprite->tileset = &grid;
struct Color colors[] = {
COLOR_BLUE, COLOR_MAGENTA, COLOR_WHITE,
COLOR_MAGENTA, COLOR_CORNFLOWER_BLUE, COLOR_MAGENTA,
COLOR_BLACK, COLOR_MAGENTA, COLOR_BLUE
};
text.setSize(3, 3);
text.buffer(colors);
textbox->border->texture = &text;
// struct Color colors[] = {
// COLOR_BLUE, COLOR_MAGENTA, COLOR_WHITE,
// COLOR_MAGENTA, COLOR_CORNFLOWER_BLUE, COLOR_MAGENTA,
// COLOR_BLACK, COLOR_MAGENTA, COLOR_BLUE
// };
// text.setSize(3, 3);
// text.buffer(colors);
// textbox->border->texture = &text;
}
std::vector<Asset*> getRequiredAssets() override {
auto assMan = &this->game->assetManager;
std::vector<Asset*> assets;
vectorAppend(&assets, SimpleSpinningCubePrefab::prefabAssets(assMan));
vectorAppend(&assets, VNTextbox::prefabAssets(assMan));
vectorAppend(&assets, EthPrefab::prefabAssets(assMan));
return assets;
}