Dark Bit Factory & Gravity
PROGRAMMING => Freebasic => Topic started by: Voltage on July 17, 2008
-
Can some check the attached proggy for me?
It looks like the memory buffer is not sent to the screen pixel perfect. Some lines are doubled up.
There is a screen shot, some code, and an exe in the attached file.
I am running this under Vista Ultimate, on an Nvidia 5700. FreeBasic 0.18.3.
-
Hi Voltage, the program looks fine. You are running this in windowed mode.
If you run it in full screen mode you'll see that it's fine.
#include "tinyptc_ext.bi"
#include "windows.bi"
#define XRES 800
#define YRES 600
dim shared buffer(XRES*YRES) as integer
Dim As Integer x,y,i
ptc_setdialog(0,"",1,1) ' No messagebox, no message text, windowed, borderless
ptc_allowclose(1) 'enable tinyptc_ext to close on Escape Key press
'Open TinyPTC window
PTC_SETDIALOG(1,"test"+CHR$(13)+"FULL SCREEN?",0,0)
If( ptc_open( "Borderless Window test", XRES, YRES ) = 0 ) Then
End -1
End if
For i=0 To XRES*YRES
buffer(i) = 0
Next
'Main Loop
ptc_allowclose(1)
do
'Draw to every second line
For y=0 To YRES-1 Step 2
For x=0 To XRES -1
buffer((y*xres)+x)=&hffffff
Next
Next y
ptc_update @buffer(0)
loop until inkey$<>""
ptc_close()
Rbraz's ptc ext uses opengl to render the screen so it's probably applied some filtering to the pixels in windowed mode.
Btw, sorry I had to split this topic so as not to hijack the ptc_ext topic which is really reserved for queries relating directly to the ptc_ext extension.
Cheers :)
-
I hadn't noticed that is was working in fullscreen mode. I tested a few different resolutions, but not fullscreen.
Regarding the texture being filtered, I was thinking the same thing.
Is it difficult to get this pixel perfect, or does it differ from system to system?
-
I'd leave a slightly larger gap between the lines if you want to have a more distinct stripy background, but I think that's about all you could do here.
-
Same problem happens for me in windowed mode in Clyde's latest demo - the one that shears alternate pixel lines in the logo, but it full screen it's fine.
Jim
-
Ok, that bug was caused by a change I did in CreateWindow code of original tinyptc, gaffer tinyptc uses only WS_OVERLAPPEDWINDOW style and when I added another style to remove minimize button and make window to non sizable that bug happened, and it will happen for bordeless window too.
It's a weird windows API behavior/bug, tried to fix it but none of my window style combinations worked out.
I can only revert it back to original window style (OVERLAPPEDWINDOW), but we will lost bordeless option and fixed window size.
Btw, Shockie, tinyptc_ext use directdraw ;)
-
The correct fix is to use AdjustWindowRect with the same Style and ExStyle as the CreateWindow.
Jim
-
Jim, same problem using AdjustWindowRect :(
AdjustWindowRect((LPRECT)&rect,WS_OVERLAPPEDWINDOW & ~WS_MAXIMIZEBOX & ~WS_THICKFRAME,0);
// create fixed window
wnd = CreateWindow(title,title,WS_OVERLAPPEDWINDOW & ~WS_MAXIMIZEBOX & ~WS_THICKFRAME,x,y,rect.right,rect.bottom,0,0,0,0);
-
You need to do
width = rect.right - rect.left
height = rect.bottom - rect.top
I think you'll find rect.left and rect.top go negative after the adjustment.
Jim
-
Ok, problem sorted!
Tested different windows resolutions and it's working fine now.
http://www.rbraz.com/source/tinyptc_ext.zip
-
Sensational!
Jim
-
You are a god amoung mortals. :)
Nice one. Thank you.