Author Topic: Re: TinyPTC Ext (Screen doubling problem)  (Read 5057 times)

0 Members and 1 Guest are viewing this topic.

Offline Voltage

  • Professor
  • Pentium
  • *****
  • Posts: 857
  • Karma: 53
    • View Profile
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.
Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17409
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: TinyPTC Ext (Screen doubling problem)
« Reply #1 on: July 17, 2008 »
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.

Code: [Select]
#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 :)
Shockwave ^ Codigos
Challenge Trophies Won:

Offline Voltage

  • Professor
  • Pentium
  • *****
  • Posts: 857
  • Karma: 53
    • View Profile
Re: TinyPTC Ext (Screen doubling problem)
« Reply #2 on: July 17, 2008 »
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?
Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17409
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: TinyPTC Ext (Screen doubling problem)
« Reply #3 on: July 17, 2008 »
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.
Shockwave ^ Codigos
Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: TinyPTC Ext (Screen doubling problem)
« Reply #4 on: July 17, 2008 »
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
Challenge Trophies Won:

Offline Rbz

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 2757
  • Karma: 493
    • View Profile
    • https://www.rbraz.com/
Re: TinyPTC Ext (Screen doubling problem)
« Reply #5 on: July 22, 2008 »
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 ;)
Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: TinyPTC Ext (Screen doubling problem)
« Reply #6 on: July 22, 2008 »
The correct fix is to use AdjustWindowRect with the same Style and ExStyle as the CreateWindow.

Jim
Challenge Trophies Won:

Offline Rbz

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 2757
  • Karma: 493
    • View Profile
    • https://www.rbraz.com/
Re: TinyPTC Ext (Screen doubling problem)
« Reply #7 on: July 23, 2008 »
Jim, same problem using AdjustWindowRect :(

Code: [Select]
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);

Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: TinyPTC Ext (Screen doubling problem)
« Reply #8 on: July 23, 2008 »
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
« Last Edit: July 23, 2008 by Jim »
Challenge Trophies Won:

Offline Rbz

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 2757
  • Karma: 493
    • View Profile
    • https://www.rbraz.com/
Re: TinyPTC Ext (Screen doubling problem)
« Reply #9 on: July 26, 2008 »
Ok, problem sorted! 

Tested different windows resolutions and it's working fine now.


http://www.rbraz.com/source/tinyptc_ext.zip
Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: TinyPTC Ext (Screen doubling problem)
« Reply #10 on: July 26, 2008 »
Sensational!

Jim
Challenge Trophies Won:

Offline Voltage

  • Professor
  • Pentium
  • *****
  • Posts: 857
  • Karma: 53
    • View Profile
Re: TinyPTC Ext (Screen doubling problem)
« Reply #11 on: July 27, 2008 »
You are a god amoung mortals. :)

Nice one.  Thank you.
Challenge Trophies Won: