Jump to content
  • 0
tipforeveryone

DrawImage() can not display what I want on game window

Question

I created my project in cpp from scratch, and here is the code I used in main.cpp

#include "Leadwerks.h"
#include "GameControl.h"
using namespace Leadwerks;

int main()
{	
	iVec2 gfxmode = System::GetGraphicsMode(System::CountGraphicsModes() - 1);
	gfxmode.x = Math::Min(700, gfxmode.x);
	gfxmode.y = Math::Round(gfxmode.x * 9 / 16);

	Window* window = Window::Create("CSCDVMP cpp", 600, 600, gfxmode.x, gfxmode.y, Window::Titlebar);
	Context* context = Context::Create(window, 0);
	World* world = World::Create();
	
	Pivot* gameControl = Pivot::Create();
	GameControl* actor = new GameControl(); //this actor has PostRender() which I used to draw image
	gameControl->SetActor(actor);

	while (true)
	{
		if (window->Closed() || window->KeyDown(Key::Escape)) return false;
		Time::Update();
		world->Update();
		world->Render();
		context->Sync();
	}
	return 0;
}

In PostRender() function of my actor

Context::GetCurrent()->DrawImage(
  myimage,
  Window::GetCurrent()->GetWidth() - myimage->GetWidth(),
  0,
  myimage->GetWidth(),
  myimage->GetHeight()
);

as my expectation, myimage will be displayed on the top right corner of screen, but this look like this instead

image.png.ef84ba5ba3dc510af677481bdb770cfe.png

window size seems to be larger than actual game display. It is ok if I use Window::FullScreen in Window::Create()

Share this post


Link to post

2 answers to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   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.

×
×
  • Create New...