I am working my way through some of the sample code and making slight modifications. I am stuck with a very simple problem. I cannot manage to get a model to successfully render a texture.
I am using slightly modified code from the leadwerks docs and a stock material.
Any insight to my challenged code/thought process is appreciated.
#include "App.h"
using namespace Leadwerks;
App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}
App::~App() { delete world; delete window; }
bool App::Start()
{
window = Window::Create();
context = Context::Create(window);
world = World::Create();
camera = Camera::Create();
camera->SetRotation(5, 0, 0);
camera->Move(0, 0, -6);
Light* light = DirectionalLight::Create();
light->SetRotation(35, 35, 0);
Model* model = NULL;
model = Model::Create();
model->SetColor(1.0, 0.0, 1.0);
model->SetPosition(0, 0, 0);
material = Material::Load("Materials/Concrete/concrete_dirty.mat");
Surface* surface = model->AddSurface();
surface->AddVertex(-0.5, -0.5, 0, 0, 0, -1);
surface->AddVertex(0.5, -0.5, 0, 0, 0, -1);
surface->AddVertex(0.5, 0.5, 0, 0, 0, -1);
surface->AddVertex(-0.5, 0.5, 0, 0, 0, -1);
surface->AddTriangle(2, 1, 0);
surface->AddTriangle(0, 3, 2);
surface->UpdateAABB();
model->SetMaterial(material,1);
model->UpdateAABB(Entity::LocalAABB | Entity::GlobalAABB);
return true;
}
bool App::Loop()
{
if (window->Closed() || window->KeyDown(Key::Escape)) return false;
Time::Update();
world->Update();
world->Render();
context->Sync();
return true;
}