Changing Resolution in OpenTK - c#

I've been searching around for this, I've managed to find out out to change the size of our window, and how to change the resolution of the monitor.
But I can't seem to find how to tell OpenGL where and how big my viewport is.
Example: the game starts up in 400x300, and I expand the window to 800x600. I now have a 800x600 window, but only a 400x300 box in the corner is being rendered to.
I get the same problem when switching to fullscreen, the gray area covers the entire screen, but I only have a small box in the corner being rendered to.
Any OpenTK people out there that know how to do this?

You need to refresh your viewport:
GL.Viewport(gameWindow.ClientRectangle);

Related

How to draw an image next to mouse cursor ANYWHERE on the screen?

My code is in C#, I already have code that gets me the coordinates by using the GetCursorPos() function of Winapi, now I wish to draw an image (bmp and png as well) next to the cursor.
I need this to work on any window/program/desktop etc'.. anywhere on the screen at anytime. that is why I am dealing with Winapi and not .net which will limit my result to my form's perimeter only. and as I said I need it to work anywhere.
What is the most simple and direct way to accomplish this? I have searched and searched for the way to do this but didn't find anything conclusive. I'll appreciate any help..
I would suggest creating a transparent window covering the whole screen and get the mouse movements in its WindowProc (and not the WindowProc of your Form).
If thet's not feasible, call SetCapture() for your Form Window when you go into this mode and ReleaseCapture when you exit this mode.
As #JonathanPotter mentioned, drawing to your own transparent window is a lot better than drawing with GetDC(NULL).

WPF Window resizing in a different direction

I am having trouble making my WPF window resize in a different direction. Currently, when I shoot an event in my application, application resizes down (I make an element visible and then WPF window automatically resizes). I would like that my application would instead resize up, so that the application would not become hidden by a taskbar. How does one do that?
Below is a picture explaining my problem. Picture 1 shows small window. Picture 2 shows the problem, where window resizes beyond the screen. Picture 3 shows what I want to do.
I can surely code this resizing in my code, where I would move the window, but is there not a nice way in WPF?
Changing the Width or Height property of your window will always change the layout of it to the right or bottom.
The Left and Top property of the window determine the X- and Y-Offset of your window relative to the top-left corner of your screen.
To achieve your goal, you have to do 2 steps:
Increase the window Height by the amount of X
Decrease the window Top by the amount of X

Set the cursor to go to the other border of the screen if it goes into one in WPF

I'm currently developing a 3D viewer application in WPF, and for ergonomy reasons I want my mouse to go to the other border of the screen if it goes into one.
For example, if my mouse goes into the top screen border, set I set my mouse position to the bottom of my screen.
Same for left/right.
How can I actually detect my mouse position in WPF? The only position I can get is related to the software and not the entire screen.
Also, it would be great if it could support dual monitors. (So the mouse is re-set only if it goes into the second monitor)
based on the informative answers to the s.o. question here:
How do I get the current mouse screen coordinates in WPF?
I think the simpler way to go is the windows.forms method, unless your 3d graphics are updating a lot of computation and you don't want the extra .net unboxed loop performance margin hit. According to this msdn reference:
http://msdn.microsoft.com/en-us/library/system.windows.forms.cursor.position.aspx
the Cursor.Position property is settable, so should be settable from WPF app, although you want to do some research and testing before committing to a lot of code on that

Draw a overlaying rectangle (example)

How would I go about drawing a rectangle like this image?
(Notice rectangle slight grey in the middle)
Screenshot
I've got drawing Rectangles on Forms/PictureBox's ect but for the of me can't figure out how to do it over all your open applications.
Any feedback will be much appreciated
If you want just a border you can use ControlPaint.DrawReversibleFrame.
You need to create a window that is set to the size of the display. No border, no background. Basically, an invisible window. Then you can draw rectangles or whatever else you want and they will appear to be overlaid on top of other things.
Keep in mind you cannot keep this window open all the time as it will cover up everything else and prevent events from getting through. Open it as needed and then close it.

Increase Cursor Size on Entire Desktop

First of all, please put aside notions of "Your application shouldn't do this". This is exactly what the people purchasing this software will be expecting.
How can I, system-wide, increase the size of the mouse cursor? I'd have to increase all mouse cursors too, so I don't think SetCursor would do the trick, at least not in any nice, clean way.
And I can't use the Form's Cursor Size as detailed here, as this would only affect the cursor when it's active on the form.
I see that there are "Extra Large" Mouse Cursors available in Windows' Ease-of-Access Centre, so there must be a way...
Any ideas?
Any solution to this is going to get really hairy because of two things:
1. Any application can change the cursor to anything else on its own
2. Cursors are at most 32x32 pixels
If an application changes the cursor to something that is 32x32 pixels, there's no way to make that any larger.
The Extra Large cursors are just just using more of the 32x32 pixels a cursor can use. The default ones are just using the top-left more-or-less quadrant of the 32x32.
You might be able to constantly Retrieve the current cursor using
http://msdn.microsoft.com/en-us/library/windows/desktop/ms648388(v=vs.85).aspx
and then paint ontop of all windows that cursor doubled in size by stretching the image, then set the cursor to some empty cursor file. This is horribly hacky and will likely cause tons of flickering and compatibility problems.

Categories