Jump to content

Recommended Posts

Posted

I need to show a dialog box in center of screen no matter what size monitor is.Are there screenheight and screenwidth variables available?

amd quad core 4 ghz / geforce 660 ti 2gb / win 10

Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++

Posted

I need more help on this if possible. I used context->GetHeight(); etc but now the dialog ( image) is showing in the lower right side of the screen

 

if (title_on)

{

int w = context->GetWidth();

int h = context->GetHeight();

context->SetBlendMode(Blend::Solid);

context->DrawImage(title, w/2, h/2);

}

amd quad core 4 ghz / geforce 660 ti 2gb / win 10

Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++

Posted

if (title_on)

{

 

 

context->SetBlendMode(Blend::Solid);

 

context->DrawImage(title, 0, 0, context->GetWidth()/2, context->GetHeight() / 2);

 

}

 

This displays image top left of screen which is better but I want it in the middle.

amd quad core 4 ghz / geforce 660 ti 2gb / win 10

Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++

Posted

You have to take into account the width/height of the image as well if you are trying to center it.

 

so essentially (psuedocode):

context_w = Context:GetWidth()

context_h = Context:GetHeight()

image_w = Texture:GetWidth()

image_h = Texture:GetHeight()

Context:DrawImage( image, (context_w - image_w) / 2 , (context_h - image_h) / 2, image_w, image_h )

  • Upvote 1

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Posted

if (title_on)

{

 

 

context->SetBlendMode(Blend::Solid);

 

context->DrawImage(title, 0, 0, context->GetWidth()/2, context->GetHeight() / 2);

 

}

 

This displays image top left of screen which is better but I want it in the middle.

 

It's in the top left corner because you are telling it to draw "title" at position 0,0 and its size is half the screen width and half the screen height.

For top of the centre of screen - title,W/2,0

For middle of screen - title, w/2,h/2

Rember that this is where the image will start to draw from so you may need to factor an offset so that the size of the image is accounted for.

If you check out Aggrors project Saturn health bar he explains it well.

Hope this helps.

 

Posted

Thanks mac I can use that. I am using "window" now instead of context but it shouldn;t make much difference.

amd quad core 4 ghz / geforce 660 ti 2gb / win 10

Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++

Posted

If you don't supply the width and height parameters, it will just be the texture's own size, by default. :)

  • Upvote 1

My job is to make tools you love, with the features you want, and performance you can't live without.

Posted

I have it filling the screen now which is better than my first intention. It looks ok.

amd quad core 4 ghz / geforce 660 ti 2gb / win 10

Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++

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.

×
×
  • Create New...