Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Draw commands and virtual resolution

Author
Message
Agent Dink
20
Years of Service
User Offline
Joined: 30th Mar 2004
Location:
Posted: 5th Feb 2015 21:32
Is it possible to get the draw commands to render in the virtual resolution? I seem to only be able to draw lines with 1 screen pixel thickness even though I have my virtual resolution set to 320 x 200. I was just working on a media-free project and want it to feel nice and pixely.
basjak
14
Years of Service
User Offline
Joined: 16th Apr 2010
Location: feel like signing up for mars
Posted: 6th Feb 2015 16:13
You should be able to use any resolution you want:

http://forum.thegamecreators.com/?m=forum_view&t=205338&b=41

Agent Dink
20
Years of Service
User Offline
Joined: 30th Mar 2004
Location:
Posted: 6th Feb 2015 16:30
Well, I can use them in any resolution, but if I'm running my app in full screen on a 1920x1080 display with a virtual resolution of 320x200, the lines using the built in drawline command are still 1 actual pixel thick instead of one virtual pixel thick.
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 6th Feb 2015 16:41
as workaround u can try a sprite and the SetImage MinMag Filter commands.
ATanFull,SetSpriteAngle,SetSpriteSize,DrawSprite, and u need the length of line
dx=x2-x1
dy=y2-y1
length =sqrt(dx*dx+dy*dy)

AGK 108 (B)19 + AppGameKit V2 Alpha .. : Windows 8.1 Pro 64 Bit : AMD Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
Agent Dink
20
Years of Service
User Offline
Joined: 30th Mar 2004
Location:
Posted: 6th Feb 2015 16:44
So is this just currently a 'limitation' of the draw commands?
basjak
14
Years of Service
User Offline
Joined: 16th Apr 2010
Location: feel like signing up for mars
Posted: 6th Feb 2015 16:53
I got confused, so you want window size of 1920x1080 and virtual resolution of 320x200.

in fact the virtual resolution is too small for such size even if window size is 320x200 with virtual resolution of 1920x1080 will end up in squeezing the pixels too much where you may not see the lines unless the objects are large enopugh and with thick frame at least.

can you leave some code so, we can look at it.

Agent Dink
20
Years of Service
User Offline
Joined: 30th Mar 2004
Location:
Posted: 6th Feb 2015 17:52 Edited at: 6th Feb 2015 17:58


Above is all of my code. You can see it creates the window at 1280x768 and runs the virtual resoltution at 320 x 192. I took Markus's suggestion and used sprites for the lines composing my asteroids, but the ship is still made by using the default draw line command. This is a good example of my issue as well. The ship will render as one screen pixel and the sprite lines will render as 1 virtual resolution pixel. The 1 virtual resolution is closer to the results I desire, but the problem is that I can't get those nice chunky 1 pixel wide lines as if it was running in a native 320x192 resolution

I have added a picture of the issue as well. This is what you will see if you run the code

Attachments

Login to view attachments
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 6th Feb 2015 18:04 Edited at: 6th Feb 2015 18:06
Quote: "So is this just currently a 'limitation' of the draw commands?"


I think it is a limitation of OpenGL. If I remember previous discussions correctly, it's making a direct call to the equivalent OpenGL line command, which will always draw a 1-pixel line irrespective of the resolution.

Virtual Resolution has no effect on actual resolution. It's just a convenient way to code your game in one known resolution, while AppGameKit upscales/downscales it for different devices.

If you are trying to get a pixellated effect by using a very low virtual resolution it won't work. You are just reducing the resolution that you are working with in your code. (You can counteract the reduced resolution by using floating values for screen positions).

You'll probably need a shader to create the pixel effect. And that is where I graciously remove myself from the discussion!

Quidquid latine dictum sit, altum sonatur
basjak
14
Years of Service
User Offline
Joined: 16th Apr 2010
Location: feel like signing up for mars
Posted: 6th Feb 2015 18:07
just looked fast at the code. it seems that you haven't applyied a correct rotation commands. what you did is enlarge the X value with equivalent decrease with the Y value. this what kept the ship the same size as it was controlled by the rotation.

the size should be independent from the rotation effect.

I will do a sample for you when I comeback home.

Agent Dink
20
Years of Service
User Offline
Joined: 30th Mar 2004
Location:
Posted: 6th Feb 2015 18:09 Edited at: 6th Feb 2015 18:12
Balls. That's too bad. Thanks for the clarification, BatVink.

@BasJak - the reason the ship's lines are thinner is because I'm using the built in drawLine command instead of the custom drawSpriteLine function I created based off of Markus's recommendation.
Agent Dink
20
Years of Service
User Offline
Joined: 30th Mar 2004
Location:
Posted: 6th Feb 2015 18:15
I'm wondering if I can draw my game to a 320x192 pixel image and display that instead of using the actual draw commands on the screen.
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 6th Feb 2015 18:17
You could, but I would imagine that it may become blurry. It's worth a try though!

Try using RenderToImage() on a 320x200 pixel image. Use this to texture a fullscreen sprite.

Quidquid latine dictum sit, altum sonatur
Agent Dink
20
Years of Service
User Offline
Joined: 30th Mar 2004
Location:
Posted: 6th Feb 2015 18:23
It wouldn't be blurry if I set the min/mag filters correctly, since it's capturing a pixel perfect image and rendering it as a sprite. (I think)
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 6th Feb 2015 20:07 Edited at: 6th Feb 2015 20:09
try this, it paints original than grab the image and span over the screen.







AGK 108 (B)19 + AppGameKit V2 Alpha .. : Windows 8.1 Pro 64 Bit : AMD Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)

Attachments

Login to view attachments
Agent Dink
20
Years of Service
User Offline
Joined: 30th Mar 2004
Location:
Posted: 6th Feb 2015 20:15 Edited at: 6th Feb 2015 20:18
To anyone interested, I was able to accomplish what I set out to do. Here is a screenshot of the results of rendering to a 320x192 image and then pasting it to the screen as a sprite.

Edit: Thanks Markus, you beat me to posting, but I was able to figure it out on my own and I'm very satisfied with the results. Pretty cool functionality, for sure.

Here's my code, cleaned up and commented a bit too:



Screenshot:

Attachments

Login to view attachments
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 7th Feb 2015 12:28
Excellent, this will be useful for lots of people trying to create this effect. And without shaders!

I noticed a couple of optimisations when I looked at the code, updated version below. You don't need to keep deleted and recreating the image and the sprite. Also, you don't need to draw the sprite.



Quidquid latine dictum sit, altum sonatur
basjak
14
Years of Service
User Offline
Joined: 16th Apr 2010
Location: feel like signing up for mars
Posted: 7th Feb 2015 14:50
Well done guys I was going to sit this weekend to solve it for Agent dink. a process I picked up from DBpro.

at least I can be sure the same steps can be used.

Agent Dink
20
Years of Service
User Offline
Joined: 30th Mar 2004
Location:
Posted: 7th Feb 2015 18:48
Thanks BatVink, I'll update my source code. I arrived at deleting and recreating my images and sprites because I kept ending up with a plain white screen(sprite) and I wasn't quite sure why.
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 7th Feb 2015 19:25
Quote: " I kept ending up with a plain white screen(sprite) and I wasn't quite sure why."
.

At one point I did too, and I couldn't work out why either.

Quidquid latine dictum sit, altum sonatur
Agent Dink
20
Years of Service
User Offline
Joined: 30th Mar 2004
Location:
Posted: 8th Feb 2015 00:46
Your way works just fine on my PC too, so I can assume we're doing it right now.

Login to post a reply

Server time is: 2024-11-25 16:34:21
Your offset time is: 2024-11-25 16:34:21