SyntaxBomb - Indie Coders

Languages & Coding => Blitz2D, BlitzPlus, Blitz3D => Topic started by: drfloyd on November 15, 2018, 07:31:09 PM

Title: My BLITZ3D game in 320x240... fullscreen ?
Post by: drfloyd on November 15, 2018, 07:31:09 PM
Hello,

How are you !?

My name is Dr FLoyd, french "casual" coder ! :)

Some of my games in BLTZ3D
http://www.gamopat-forum.com/t66372-termine-crash-time-plumber-deluxe-edition-pc
http://www.gamopat-forum.com/t93454-termine-supa-zazai-da

I am about to finish my new game in BLITZ 3D... in full 2D :
http://www.gamopat-forum.com/t99730-new-cosmos-the-secret-melody-sortie-mi-decembre-2018

But this time my game is in 320x240 pixels ! So Windowed only... Our screens do not accept this resolution.

Is there a possibility/tips to transform the game in fullscreen ???? Virtualisation ?

Thank you for your help

PS : in the past, I have already see that but It was complicate :
http://www.mojolabs.nz/posts.php?topic=95702
Title: Re: My BLITZ3D game in 320x240... fullscreen ?
Post by: Naughty Alien on November 16, 2018, 12:54:08 AM
..hello man...everything is possible here...welcome mann..
Title: Re: My BLITZ3D game in 320x240... fullscreen ?
Post by: RemiD on November 17, 2018, 01:42:35 PM
@drfloyd>>i have posted a code example to do exactly that,
the idea was to stretch a 320x200 image on a quad mesh (using a texture and specific UVs), the code is somewhere on this forum...
https://www.syntaxbomb.com/index.php/topic,3658.327.html (#327)

i have used this method for the 320x200 compo last year... see : https://www.syntaxbomb.com/index.php/topic,3991.0.html

Title: Re: My BLITZ3D game in 320x240... fullscreen ?
Post by: Dan on November 20, 2018, 08:56:28 AM
Hello,
with blitzbasic, you can setup low res graphic mode, but use hardware stretching to make the window size bigger.

To do this you would set, first the desired window size e.g 800x600. Then you set the Graphic mode of 320x200. This will be resized to the 800x600 automatically.

Code: [Select]
Graphics 800,600,32,2
Graphics 320,200,32,3

Print "hi"
WaitKey()

For testing purpose, i do use following function:

Code: [Select]
Function Screen(defaultx=320,defaulty=240,Stretchx=640,Stretchy=480)
;bits=api_GetDeviceCaps(api_GetDC( api_GetDesktopWindow()),12)   ;Userlib function - Get Desktop Bit size
bits=32  ;Set color depth manually
Graphics Stretchx,Stretchy,bits,2
Graphics defaultx,defaulty,bits,3
End Function

or following function, which uses user32 and gdi32 userlib:

Code: [Select]
;;gdi32.decls

;.lib "gdi32.dll"
;api_GetDeviceCaps% (hdc%, nIndex%) : "GetDeviceCaps"

;;user32.decls
;.lib "user32.dll"
;api_GetActiveWindow% () : "GetActiveWindow"
;api_GetDC% (hwnd%) : "GetDC"
;api_GetDesktopWindow% () : "GetDesktopWindow"
;api_GetSystemMetrics% (nIndex%) : "GetSystemMetrics"
;api_MoveWindow% (hwnd%, x%, y%, nWidth%, nHeight%, bRepaint%) : "MoveWindow"
;api_SetWindowLong% (hwnd%, nIndex%, dwNewLong%) : "SetWindowLongA"

Function Screen(x,y,full=0)
;fill <0 = Fulldesktop, borderless window
;full =0 = Fulldesktop
;full =1 = original x,y
;full >1-5 = x*full,y*full size
;full >5 = 0
DeskX=api_GetSystemMetrics(0)
DeskY=api_GetSystemMetrics(1)
If x>DeskX Then x=DeskX
    If x<64 Then x=64
If y>DeskY Then y=DeskY
    If y<64 Then y=64
    bits=api_GetDeviceCaps(api_GetDC( api_GetDesktopWindow()),12)
Graphics x,y,bits,6
Graphics x,y,bits,7
If full<=0 Or full>5
If full<0 Then api_SetWindowLong(api_GetActiveWindow(), -16, $10000000)
api_MoveWindow(api_GetActiveWindow(),0,0,DeskX,DeskY,True)
    EndIf
If full>1 And full<=5 Then api_MoveWindow(api_GetActiveWindow(),0,0,x*full,y*full,True)
End Function

There is another way to display low res Graphic in bigger window, but it can be a bit slow on lower end machines.
Instead using 3d function, this ones uses software resizing.

You draw the game happenings on a imagebuffer instead of backbuffer.
Then after changing to backbuffer you resize the game image and after resizing you paste it on the backbuffer.

Code: [Select]
Function DrawSizeImage(image,x%,y%,w%,h%)
;Global scratch%=CreateImage(SW,SH)                ; create a scratch image
     Local ih%=ImageHeight(image)
     Local iw%=ImageWidth(image)

     Local sw%=Abs(w)
     Local sh%=Abs(h)
     
     Local xr#=(Float(iw)/Float(sw))
     Local yr#=(Float(ih)/Float(sh))
     
     fromimg=ImageBuffer(image)
     toimg=ImageBuffer(scratch)
     
     Local vf=-1+((h>0)*2)
     
     Local fw=(w<0)*w
     Local fh=(h<0)*h
     
     If w>=0
          For ix=0 To sw
               CopyRect ix*xr,0,1,ih,ix,0,fromimg,toimg
          Next
     Else
          For ix=0 To sw
               CopyRect ix*xr,0,1,ih,sw-ix,0,fromimg,toimg
          Next
     EndIf

     For iy=0 To sh
          CopyRect 0,iy*yr,sw,1,x+fw,y+(iy*vf),toimg
     Next
End Function

eh, Déjà vu ??
Title: Re: My BLITZ3D game in 320x240... fullscreen ?
Post by: peteswansen on December 04, 2018, 07:46:05 PM
on my 1920x1080 monitor 320 by 240 does not work but 640x480 in mode 1 (fullscreen) produces a image with a large black border..
Title: Re: My BLITZ3D game in 320x240... fullscreen ?
Post by: MagosDomina on January 04, 2019, 11:55:35 PM
I would seriously consider scaling your games graphics to use a more modern resolution (at least 800x600) but maintain the look of 320x240 by either realtime scaling or simply compensate by scaling your actual art files to be larger.

320x240 works fine on Analog displays but will cause nothing but issues on digital displays.