Announcement

Collapse
No announcement yet.

Graphics for dummies

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

  • Graphics for dummies

    Hi everyone, I am wondering if there is a guide or even better yet if someone could post bit more about working with graphics.
    My problem is that I think I go wrong way about almost any graphics problem. My graphics are too slow or if they are fast they flicker or doing all sorts of weird things.

    Couple of problems I encountered:

    - counter counting up and down when counting up all good but when counting 255 to 0 it a) leaves traces of unused digits or b) flickers when I first clear the area and then write number

    - bar graphs pretty much the same deal, when it goes up/down fast it almost diapers on me

    - photo realistic needle going round the clock on the photo realistic background, I have not tried that yet but I do not even know how to tackle that.

    I have more coming so if there is someone who wants to share basic know-how I would really appreciate it.
    Thank you
    Josef

  • #2


    Try not to clear the screen, or clear as little as possible, update only what needs updating.

    For Text write in Opaque mode.

    Not sure about the needle, not sure what you are trying to achieve.
    Mark

    Comment


    • #3


      There is an example here showing how to deal with meters that may help:-

      http://www.4dsystems.com.au/code/index.php?node=60&id=102
      Regards,
      Dave

      Comment


      • #4


        Thanks guys, it definitely shined some light on it. But like with everything the more I know the more questions I have.
        If I keep redrawing just as little as possible is there a time that you end up with corrupt picture? as in little glitch would take the graphics out of sync. Do you actually worry about this or it is too unlikely to worry about it?

        now something from very basic library is there a function in 4dgl to draw an arc? gfx_Arc? or how do you do lets say only 180deg of a circle? gfx_Circle(x, y, radius, colour)>>1; hahaha

        thanks again

        Comment


        • #5


          yes, its a different world when you don't have dual video buffering, and all the hidden nice things you get from a more complex/faster/expensive operating system.
          Programming strategy is very strict when it comes to graphics.

          Graphics wont go out of sync though, there is no sync - you are literally writing directly to the screen so everything you do is visible.

          If yo want to draw arcs, the best way is to use the gfx_Orbit function, and draw a section of line segments.

          It seems like you wish to create 'meters' and although it can be done with basic geometry and drawing lines etc, you will get
          extremely good performance by rendering each 'picture' for the meter, and just selecting the required image frame for the meter.

          Blitting an image to a rectangular area on the screen is extremely fast - faster than any line drawings.

          have a look here for further info on that concept:-
          http://4d.websitetoolbox.com/post?id=2767589&highlight=bargraph
          Regards,
          Dave

          Comment


          • #6


            Thanks for all the help. I got bit done today, I just can not overcome little problem that the needle on my gauge leaves traces. It looks like old broken radar screen. What I came up with is that I copy all pixels in the area where the needle goes and then draw needle and next round I put those copied pixels back and ..... But it does not work. (I thought I got it worked out but I don't)
            I am wondering if you guys could have a look ? This is just the part where I copy paste and draw needle. I split it and spread it so it is easier to go through it but still can not see a problem (except on the screen). at the end I have two versions of drawing needle, to draw a line is total disaster and the pixel version just slowly corrupt my background.

            gfx_MoveTo(peekB(GFX_XMAX)>>1, peekB(GFX_YMAX)>>1);

            if (ind_val!=old_ind_val)

            for(i:=0; i

            Comment


            • #7


              yes the problem is that the pixel positions calculated by orbit
              don't match the points that the bresline plots so it will have some dither.

              [quote]
              func main()

              var i, ind_val, old_ind_val, orbit_X, orbit_Y;
              var needle_copy[50];

              gfx_OrbitInit(&orbit_X, &orbit_Y);

              gfx_RectangleFilled(0,0,127,127,DARKBLUE);

              gfx_MoveTo(64,64);

              goto first; // ugly

              while(1)

              if ( ind_val >= 360) ind_val := 0;

              if (ind_val != old_ind_val)

              // replace old line segment
              for(i:=0; i
              Regards,
              Dave

              Comment


              • #8


                Yeah, the problem is that I can not use simple Undraw, I have bit complex background.

                I just discovered something strange! I am not sure if I missed something but gfx_PutPixel(64, 64,0x0100 );
                putnum(HEX,gfx_GetPixel(64,64)); returns 0x0020???

                am I missing something? or or this have some sort of magic in it?

                Comment


                • #9


                  hmm, what module and what PmmC revision are you using ?
                  Regards,
                  Dave

                  Comment


                  • #10


                    The module is uLCD-144 rev3 with uLCD-144rGFX-R21.pmmc

                    Comment


                    • #11


                      very interesting it looks like it does getpix>>3 very interesting, I think I could cheat buy using just some shades of color and shift :-)

                      Comment


                      • #12


                        There are two different revisions of hardware for uLCD-144GFX,
                        try the non 'r' version PmmC.
                        What you are describing indicates wrong PmmC.
                        Regards,
                        Dave

                        Comment


                        • #13


                          just tried with no luck, The 'r' version is the only version which comes up with green writing after upload and actually does something, the other version just blank screen no matter what I load in it.

                          Comment


                          • #14


                            now, I did not have any time to follow up on this but do you reckon it is a problem with pmmc or actual screen and how do I get this fixed?

                            Comment


                            • #15


                              Yep ok, then I cant quite understand whats happening.
                              If the example code I posted below works, it seems that it is reading pixels ok so your simple test :-
                              gfx_PutPixel(64, 64,0x0100 );
                              putnum(HEX,gfx_GetPixel(64,64));

                              should work.

                              I will get hold of an 'r' version module and test - you either have a faulty module, or there is a bug in the PmmC.
                              Will get back to you asap.
                              Regards,
                              Dave

                              Comment

                              Working...
                              X