Announcement

Collapse
No announcement yet.

Odd failures of graphic display

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Odd failures of graphic display

    Good morning group,

    I've been working on a program for use in a psychological research project. The program displays 15 to 25 circles, one at a time, in various sizes and requires a response to indicate the relative size. You input a digit from 1 to 5 to indicate if you think the specific circle is the smallest (1), largest (5), or somewhere in between (2-4). When the answer is right the program displays "That was right" under the circle; when wrong, "That was wrong."

    I finally achieved reliable presentation of circles and reliable taking and scoring of responses, etc. The problem is, the graphic displays fail in odd and, so far, unpredictable ways. Here are some of the specifics:

    1) Instead of the Times New Roman font, it sometimes drops back to the default font, but only for one display, the next circle or instruction will be Times New Roman again.
    2) Sometimes it totally omits some, but not all printed lines of instructions.
    3) Sometimes it omits a circle, but displays subsequent circles normally.
    4) Sometimes it omits the "right" or "wrong" text, but works right on subsequent trials.

    Some runs of the program (15 to 25 circle presentations) are flawless; but other runs may have multiple failures of display. The display failures happen with multiple runs of the same compiled code, differently on different runs. They also happen with new compiles with no code changes.

    I have begun to think there may be issues with Vista and PBCC, but I've found no mention of it on the forums.

    I'm using PBCC, ver 4.04 and the latest Vista upgrades (Home Premium).

    TIA,

    Bruce
    Bruce L. Bachelder
    www.BruceBachelderPhD.com

  • #2
    Have you tried it on a different machine running xp or maybe 2k?

    Failing that, post a stripped down version of your program and let's take a look at it.
    There are no atheists in a fox hole or the morning of a math test.
    If my flag offends you, I'll help you pack.

    Comment


    • #3
      We (or PB support) need to see some code to help you.

      You need to do what Mel suggested and supply a cut-down version that exhibits the problem.
      kgpsoftware.com | Slam DBMS | PrpT Control | Other Downloads | Contact Me

      Comment


      • #4
        Hi Bruce,

        which functions are you using for rendering?
        If those are PB GRAPHIC commands, you might workaround it using double buffer mode.

        That means attach window as:
        Code:
        GRAPHIC ATTACH hWnd, 0, REDRAW ' <-- That redraw is interesting
        
        ' -- Put your drawing code here
        
        GRAPHIC REDRAW ' <-- Update whole screen at once
        This applies at least for the graphic primitives rendering, not sure about text.
        Sure thing is this way is a lot faster than the immediate drawing.

        I experienced similar problem when working on turtle graphic for PB with Emil Menzel, using this approach fixed it.

        I could not put together reliable ( = always manifesting problematic behaviour ) way to demonstrate problem, as it happens from time to time on same code.

        That is the reason I did not dispatched any report to PB support yet about this issue.


        Petr
        [email protected]

        Comment


        • #5
          Here is one more sample,

          Single buffer ( sometimes not drawn completely, don't know why ):
          Code:
          #COMPILE EXE
          #DIM ALL
          
          FUNCTION PBMAIN () AS LONG
            REGISTER i AS LONG
            
            ' Create and show a Graphic window on screen
            LOCAL hWin AS DWORD
          
            GRAPHIC WINDOW "Lines : SINGLE", 300, 300, 480, 480 TO hWin
            GRAPHIC ATTACH hWin, 0
            GRAPHIC CLEAR %BLACK
            GRAPHIC WIDTH 2
            FOR i = 0 TO 479 STEP 5
              GRAPHIC LINE (0, i) - (479, i), %WHITE
            NEXT
          
            SLEEP 5000  ' show it for 5 seconds, then end
          
          END FUNCTION
          Double buffer mode, always rendered completely:
          Code:
          #COMPILE EXE
          #DIM ALL
          
          FUNCTION PBMAIN () AS LONG
            REGISTER i AS LONG
            
            ' Create and show a Graphic window on screen
            LOCAL hWin AS DWORD
          
            GRAPHIC WINDOW "Lines : DOUBLE", 300, 300, 480, 480 TO hWin
            GRAPHIC ATTACH hWin, 0, REDRAW
            GRAPHIC CLEAR %BLACK
            GRAPHIC WIDTH 2
            FOR i = 0 TO 479 STEP 5
              GRAPHIC LINE (0, i) - (479, i), %WHITE
            NEXT
          
            GRAPHIC REDRAW
            
            SLEEP 5000  ' show it for 5 seconds, then end
          
          END FUNCTION

          Petr
          [email protected]

          Comment


          • #6
            Hi Petr, Mel, and Kev,

            Thank you for the quick replies. I'll try "double buffer" first because it looks like the simplest solution if it works. Failing that, I'll work up some stripped down code to demonstrate the effect.

            Bruce
            Bruce L. Bachelder
            www.BruceBachelderPhD.com

            Comment


            • #7
              Originally posted by Mel Bishop View Post
              Have you tried it on a different machine running xp or maybe 2k?

              Failing that, post a stripped down version of your program and let's take a look at it.
              An excellent idea, but I don't have access to a different machine right now (we're traveling in a motorhome). I've sent the program to my project colleague to run on his XP machines, but at least two servers refused the .exe attachment. At this point, I haven't heard from him that he's received it or run it.

              I'm working on a stripped down version. Very stripped down seems to eliminate the problem. A bit more of the original code seems to bring it back big time, but I'm still studying the confusing results.

              Thanks,
              Bruce
              Bruce L. Bachelder
              www.BruceBachelderPhD.com

              Comment


              • #8
                Graphic not always rendered

                Bruce,
                I had the same problem win WinXP and using double buffers improved the display but did not cure the problem all the time.

                I got it to run correctly only by adding SLEEP 25 after the GRAPHIC ATTACH command
                Old QB45 Programmer

                Comment


                • #9
                  You might try sending the entire file to PB support and let them take a look at it. They have a reputation for maintaining privacy.
                  There are no atheists in a fox hole or the morning of a math test.
                  If my flag offends you, I'll help you pack.

                  Comment


                  • #10
                    Originally posted by Guy Dombrowski View Post
                    Bruce,
                    I had the same problem win WinXP and using double buffers improved the display but did not cure the problem all the time.

                    I got it to run correctly only by adding SLEEP 25 after the GRAPHIC ATTACH command
                    Hi Guy,

                    Very curious cure. I'll try it.

                    Bruce
                    Bruce L. Bachelder
                    www.BruceBachelderPhD.com

                    Comment


                    • #11
                      Originally posted by Bruce L. Bachelder View Post
                      Hi Guy,

                      Very curious cure. I'll try it.

                      Bruce
                      I thought the problem was cured. It ran many times flawlessly, then started failing to display the circles.

                      I'll double check to make sure I implemented Guy's suggested correctly and completely, but at this point it doesn't seem to have solved the problem.

                      Thanks,
                      Bruce
                      Bruce L. Bachelder
                      www.BruceBachelderPhD.com

                      Comment


                      • #12
                        Sleep

                        Bruce,

                        Depending on the speed of your video card, you may have to increase the sleep period until it work all the time.
                        I have 5 different machines and they all need differents timing. Very bizarre..
                        Old QB45 Programmer

                        Comment


                        • #13
                          I had a similar problem where a bitmap being saved was not working correctly and José offered this function to call for the delay needed. Not sure if it's relevant in this context??

                          James


                          Code:
                          SUB TLB_DoEvents (BYVAL hWnd AS DWORD)
                             LOCAL Msg AS tagMsg
                             WHILE PeekMessage(Msg, %NULL, %NULL, %NULL, %PM_REMOVE)
                                IF ISFALSE IsDialogMessage(hWnd, Msg) THEN
                                   TranslateMessage Msg
                                   DispatchMessage Msg
                                END IF
                             WEND
                          END SUB

                          Comment


                          • #14
                            Originally posted by Guy Dombrowski View Post
                            Bruce,

                            Depending on the speed of your video card, you may have to increase the sleep period until it work all the time.
                            I have 5 different machines and they all need differents timing. Very bizarre..
                            Hello Guy et al.,

                            Thanks for the additional comment. I'll try some more values. I just bought this computer 6 months or so ago so it probably has a faster card than the previous generation computer (inexpensive laptop) I originally worked on.

                            Some family illnesses have kept me away from the desk, but I probably will get to spend some more time on the problem today.

                            I've also been stripping down some code to share and test. It turns out it isn't hard to generate the problem.

                            Bruce
                            Bruce L. Bachelder
                            www.BruceBachelderPhD.com

                            Comment


                            • #15
                              Originally posted by jcfuller View Post
                              I had a similar problem where a bitmap being saved was not working correctly and José offered this function to call for the delay needed. Not sure if it's relevant in this context??

                              James


                              Hi James et al.

                              I'm such a novice at this stuff I don't know if it is relevant or not. However, I'm happy to have your suggestion and have tried to understand what the code does. Do you think the function was just to delay? If so, SLEEP would seem to be equivalent. I may even try WAITKEY$ at strategic spots and see if that helps.

                              Thanks for the contribution. I am managing to understand this stuff better and better and this forum has been helpful in several ways. Years ago a colleague of mine not only recommended I use PowerBASIC (for DOS those days) but he commented how helpful this group is. Unfortunately, he died a few months ago or I'd be writing him to thank him again for the excellent tips.

                              Bruce
                              Bruce L. Bachelder
                              www.BruceBachelderPhD.com

                              Comment


                              • #16
                                Originally posted by Bruce L. Bachelder View Post
                                Hi James et al.

                                I'm such a novice at this stuff I don't know if it is relevant or not. However, I'm happy to have your suggestion and have tried to understand what the code does. Do you think the function was just to delay? If so, SLEEP would seem to be equivalent. I may even try WAITKEY$ at strategic spots and see if that helps.
                                Bruce
                                Bruce,
                                No. It's not the same. Sleep lets other processes have a time slice. It may not help within the same process. I had tried sleep with the problem I had and it did not work but this call solved the problem.

                                James

                                Comment


                                • #17
                                  Originally posted by Kev Peel View Post
                                  We (or PB support) need to see some code to help you.

                                  You need to do what Mel suggested and supply a cut-down version that exhibits the problem.
                                  Hi Kev et al.,

                                  Here's the cut-down code. I have compiled it and run it over and over. I have seen it:

                                  1) run perfectly
                                  2) omit the first of two lines of "instructions"
                                  3) omit all instructions
                                  4) revert to the default font
                                  5) then run perfectly several consecutive times

                                  Code:
                                  #COMPILE EXE
                                  #DIM ALL
                                  
                                  DECLARE SUB DisplayCircle
                                  DECLARE SUB CreateGraphicWindow
                                  DECLARE SUB PresentInstructions
                                  
                                  GLOBAL hWin AS DWORD
                                  
                                  FUNCTION PBMAIN () AS LONG
                                  
                                      CONSOLE SET LOC 500, 300   'Get the window out of the way of the circle
                                      CreateGraphicWindow
                                      PresentInstructions
                                      GRAPHIC CLEAR
                                      GRAPHIC PRINT "Press any key to display a circle."
                                      CONSOLE SET FOCUS
                                      WAITKEY$
                                      DisplayCircle
                                  END FUNCTION
                                  
                                  SUB CreateGraphicWindow
                                  
                                      DIM hWin AS GLOBAL DWORD
                                      GRAPHIC WINDOW "", 0, 0, 1278, 750 TO hWin
                                      GRAPHIC ATTACH hWin, 0
                                      GRAPHIC FONT "Times New Roman", 16
                                  END SUB
                                  
                                  SUB PresentInstructions
                                  
                                      GRAPHIC PRINT "This is standing in for instructions"
                                      GRAPHIC PRINT "When finished, press any key."
                                      CONSOLE SET FOCUS
                                      WAITKEY$
                                      
                                  END SUB
                                  SUB DisplayCircle
                                  
                                  
                                      GRAPHIC ELLIPSE (50, 50) - (100, 100)
                                  
                                      GRAPHIC SET POS (50, 120)
                                      GRAPHIC PRINT "Press any key to finish."
                                  
                                  
                                      CONSOLE SET FOCUS
                                      WAITKEY$
                                  
                                  
                                  END SUB
                                  My next step is to try some of the group's suggestions on this code.

                                  Bruce
                                  Bruce L. Bachelder
                                  www.BruceBachelderPhD.com

                                  Comment


                                  • #18
                                    Code

                                    Bruce,

                                    I just downloaded your code and sure enough, I have the same problem you have.

                                    I just added a START: line on top and a GOTO START at the bottom to run it quickly many times and I got it to run all the time with a SLEEP 5 after the GRAPHIC ATTACH command.

                                    My machine is a 6000 mhz AMD X2 and I have a fast Nvidia
                                    8800GT card with WinXP SP2.
                                    On my slowest machines I needed SLEEP 50 to fix it
                                    Old QB45 Programmer

                                    Comment


                                    • #19
                                      Originally posted by Guy Dombrowski View Post
                                      Bruce,

                                      quickly many times and I got it to run all the time with a SLEEP 5 after the GRAPHIC ATTACH command.


                                      On my slowest machines I needed SLEEP 50 to fix it
                                      Hi Guy et al.

                                      Great news! My colleague, even less a programmer than I, will be pleased that we are over this challenge. He is eager to get back collecting data again.

                                      I'll start testing here with the sample code, then move to the program, itself. I'll let you know what value is required here.

                                      I'm running an HP Pavilion dv6707us with AMD 64 Athlon X2 with NVIDIA GeForce Go 7150M graphics. Maybe this information and yours will be useful to someone more knowledgeable than I am.

                                      Thank you very much.

                                      Bruce
                                      Bruce L. Bachelder
                                      www.BruceBachelderPhD.com

                                      Comment


                                      • #20
                                        Originally posted by Bruce L. Bachelder View Post
                                        Hi Guy et al.

                                        I'll start testing here with the sample code, I'll let you know what value is required here.

                                        Bruce
                                        Hi Guy et al.,

                                        SLEEP 5 and 10 failed; 20 seems to have fixed it.

                                        Now, I'll see if I can fix the program, itself.

                                        Thank you,
                                        We can get moving here, again.

                                        Bruce
                                        Bruce L. Bachelder
                                        www.BruceBachelderPhD.com

                                        Comment

                                        Working...
                                        X