March 05, 2021, 07:04:20 PM
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email
?
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Like stats
Home
Forum
Help
Search
Gallery
Login
Register
SyntaxBomb - Indie Coders
»
Languages & Coding
»
BlitzMax / BlitzMax NG
»
Pixelperfect in low res ?
« previous
next »
Print
Pages: [
1
]
Go Down
Author
Topic: Pixelperfect in low res ? (Read 138 times)
drfloyd
Jr. Member
Posts: 40
Total likes: 0
Pixelperfect in low res ?
«
on:
February 03, 2021, 11:03:28 AM »
Hello,
Laurent from France, ex-dev with BLITZ3D, was coming here sometimes, I try a come back with BLITZ MAX
First question : i want to do a low res game, like 320x200, or 320x240, or something like that, in fullscreen
I just use :
Graphics 320,240,32
But the result is a blurry screen.
There is a way to do Pixel Perfect in fullscreen or not ?
Thank you for your help, and sorry for my bad english
Laurent
Logged
Derron
Hero Member
Posts: 3416
Total likes: 2
Re: Pixelperfect in low res ?
«
Reply #1 on:
February 03, 2021, 11:14:25 AM »
There are multiple ways:
- virtual resolution + some added black bars so pixel perfect also means "square" pixels
- render 2 texture (available via some old openGL code, via Col's render2texture code - or via my pull requests to brl.mod, pub.mod and sdl.mod), you there render into a 320x200 texture and render it "scaled up" (without filtering) on your current window size
bye
Ron
Logged
drfloyd
Jr. Member
Posts: 40
Total likes: 0
Re: Pixelperfect in low res ?
«
Reply #2 on:
February 03, 2021, 11:23:01 AM »
hello Ron,
Thanks for your prompt reply
I am a novice/casual coder
Have you got a code example with the more easy solution ? (perhaps the first no ? Virtual resolution ?)
Thank you
Laurent
Logged
TomToad
Hero Member
Posts: 544
Total likes: 0
Re: Pixelperfect in low res ?
«
Reply #3 on:
February 03, 2021, 11:50:37 AM »
That is because almost all modern computers and monitors are incapable of 320x240 resolution. So instead, your computer is using the lowest resolution it can and then scaling the 320x240 up to that resolution causing a blur.
What you need to do is use a common resolution that your computer supports, such as 1024x768, then use SetVirtualResolution 320,240. Also, you'll need to load your images in without any filters.
LoadImage("IMage.png",0) MASKEDIMAGE and DYNAMICIMAGE are okay to use if you will be using a color mask or will be modifying the image.
Also note that the actual resolution will not be 320x240, SetVirtualResolution just scales the coordinate system so that 320 untits by 240 units fit in the graphics display. So if you draw an image at a fractional coordinate, then the image will be drawn at the proper scaled coordinate instead of at the integer offset like it would on an actual 320x240 display. This can be fixed by either using only Ints for X and Y or casting to Int before passing to the draw commands.
Hopefully this example can show you better than I can explain it. The top square might move more smoothly because it is able to draw at fractional pixels, but it is not how an actual low resolution display would behave.
Code: BlitzMax
SuperStrict
Graphics
1024
,
768
,
32
'lets create an image to draw
Local
Image:TImage = CreateImage
(
8
,
8
,
1
,
0
)
'32x32 pixels, 1 frame, no flags
Cls
For
Local
x:
Int
=
0
To
7
For
Local
y:
Int
=
0
To
7
SetColor Rand
(
0
,
255
)
,Rand
(
0
,
255
)
,Rand
(
0
,
255
)
Plot x,y
Next
Next
SetColor
255
,
255
,
255
GrabImage Image,
0
,
0
'Now lets set the virtual resolution
' really low so that the pixels show up
SetVirtualResolution
80
,
60
'then lets move the image both fractional and in integers
Local
x:
Float
Local
Delta:
Float
'we will use delta timing to move the images
Local
Time:
Int
, LastTime:
Int
=
MilliSecs
(
)
While
Not
KeyHit
(
KEY_ESCAPE
)
And
Not
AppTerminate
(
)
Time =
MilliSecs
(
)
Delta =
Float
(
Time-LastTime
)
/
1000.0
LastTime = Time
x :+
2
*Delta
If
x >=
80
Then
x :-
88
'if off the right border, then wrap past left border
Cls
DrawImage Image,x,
12
'drawing to the virtual screen
DrawImage Image,
Int
(
x
)
,
42
'drawing at integer pixels
DrawText
"Fractional"
,
0
,
0
DrawText
"Integer"
,
0
,
30
Flip
Wend
Logged
------------------------------------------------
8 rabbits equals 1 rabbyte.
drfloyd
Jr. Member
Posts: 40
Total likes: 0
Re: Pixelperfect in low res ?
«
Reply #4 on:
February 03, 2021, 01:06:02 PM »
THANK YOU VERY VERY MUCH !!!!! I have forgotten SETVIRTUALRESOLUTION
But it seems to work only by doing that :
Graphics 1024,768,32
SetVirtualResolution 320,200
The blur has diseapear. So easy
Logged
Derron
Hero Member
Posts: 3416
Total likes: 2
Re: Pixelperfect in low res ?
«
Reply #5 on:
February 03, 2021, 01:43:12 PM »
You can leave out the ",32" if you want a 1024x768 window.
bye
Ron
Logged
Print
Pages: [
1
]
Go Up
« previous
next »
SyntaxBomb - Indie Coders
»
Languages & Coding
»
BlitzMax / BlitzMax NG
»
Pixelperfect in low res ?
SimplePortal 2.3.6 © 2008-2014, SimplePortal