×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Regular Contributor
    Join Date
    May 2003
    Posts
    151

    Paint function timing.

    This is probably a bit of a confused noob question but.....

    When (or how) does the paint function get called for the active Canvas ? Is it synced to some sort of vsync or called a set number of times a second, or does the painting thread just get a proportion of the CPU time ?


    Basically I'm trying to understand how my games run and paint functions should be synced with each other and have the game running at full speed.

    Obviously you only want the game to do one update loop for each paint loop, does calling serviceRepaints() achieve this ie yield the current run thread and cause the paint function to be called immediately or does it sit around and wait for the paint function to do it's thing at it's own pace.

    tia
    dan

  2. #2
    Registered User
    Join Date
    Jun 2003
    Location
    Denmark
    Posts
    11
    My personal experiences show, that the paint() method only gets called upon application start, and when you call it manually using repaint().

  3. #3
    Regular Contributor
    Join Date
    May 2003
    Posts
    151
    Cool - that's useful


    cheers
    dan

  4. #4
    Registered User
    Join Date
    Mar 2003
    Posts
    5
    No, this isn't correct. The repaint does not occur when you call repaint(). Calling repaint() schedules an event which is executed by a seperate thread on the phone (which also handle user input). This is not dissimiliar to the AWT thread in J2SE.

    Supposedly, serviceRepaints() is supposed to block (ie. yield the current thread) and not return until the painting has actually been carried out.

    My experience is that this has not been implemented properly on Nokia phones :-( There are solutions - but all of them are hacks.

  5. #5
    Regular Contributor
    Join Date
    May 2003
    Posts
    151
    >My experience is that this has not been implemented properly
    >on Nokia phones

    It seems to be working on the Nokia 7210 - are there any specific phones that show this behaviour ?

  6. #6
    Regular Contributor
    Join Date
    May 2003
    Posts
    72
    I have found that if you make a repaint(x,y,widht,height) call from a secondary thread that paint is called inline. Maybe I was screwing something up but if you want you can try putting this snippet in an app to see if you can replicate the problem.

    public void repaintStuff(){
    System.out.println("Before");
    repaint(0,0,100,100);
    System.out.println("After");
    }
    public String str;
    public synchronized void paint(Graphics g){
    g.setColor(0);
    g.fillRect(0,0,120,120);
    g.setColor(255);
    g.drawString(str, 0,0,0);
    }

    ``````Other Thread`````

    repaintStuff();
    str = "Didnt do it inline."
    Last edited by sam.hendley; 2003-07-02 at 22:38.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •