Jump to content

DrawImage [Solved]


gamedeviancy
 Share

Recommended Posts

I cannot for the life of me figure out why I can't draw this silly image to the screen. Checked the path to the texture file, it was generated from LE from a PNG fine....

 

 

#include "App.h"
using namespace Leadwerks;
App::App() : window(NULL), context(NULL), world(NULL), camera(NULL) {}
App::~App() { delete world; delete window; }
bool freelookmode=true;
Texture* sidebar = NULL;
bool App::Start()
{
//Initialize Steamworks (optional)
/*if (!Steamworks::Initialize())
{
System::Print("Error: Failed to initialize Steam.");
return false;
}*/
//Create a window
window = Leadwerks::Window::Create("StrategyGame", 0, 0, 1920, 1080, Leadwerks::Window::FullScreen);
//Create a context
context = Context::Create(window);

//Create a world
world = World::Create();
//Create a camera
camera = Camera::Create();
camera->Move(0,50,0);
camera->SetRotation(75,0,0);
std::string mapname = System::GetProperty("map","Maps/start.map");
Map::Load(mapname);
//Load UI
sidebar = Texture::Load("Materials/Shadowless/menubar2.tex");
//Move the mouse to the center of the screen
window->SetMousePosition(context->GetWidth()/2,context->GetHeight()/2);
return true;
}
bool App::Loop()
{
//Close the window to end the program
if (window->Closed()) return false;
//Press escape to end freelook mode
if (window->KeyHit(Key::Escape))
{
if (!freelookmode) return false;
freelookmode=false;
window->ShowMouse();
}
if (freelookmode)
{
//Keyboard movement
float strafe = (window->KeyDown(Key:) - window->KeyDown(Key::A))*Leadwerks::Time::GetSpeed() * 0.5;
float move = (window->KeyDown(Key::W) - window->KeyDown(Key::S))*Leadwerks::Time::GetSpeed() * 0.5;
float rotate = (window->KeyDown(Key::Q) - window->KeyDown(Key::E))*Leadwerks::Time::GetSpeed() * 0.5;
camera->Translate(strafe,0,move);
camera->Turn(0,0,rotate);
}
// UI
context->SetColor(0,0,0);
 context->Clear();
context->SetColor(1,1,1);
context->DrawImage(sidebar,0,0);

Leadwerks::Time::Update();
world->Update();
world->Render();
context->Sync();
return true;
}

"The only true wisdom is in knowing you know nothing." ~ Socrates

Link to comment
Share on other sites

You need to call DrawImage() after world->Render() and before context->Sync(). You see world->Render() draws the 3D world to the buffer and context->Sync() draws that buffer to the screen. The place you have DrawImage() gets overwritten by the 3D world being draw to the buffer. That's why you don't see it.

  • Upvote 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...