Results 1 to 7 of 7

Thread: Graphics loops

  1. #1

    Thread Starter
    Addicted Member jmiller's Avatar
    Join Date
    Jul 2002
    Location
    University of Michigan
    Posts
    238

    Graphics loops

    I've programmed games in visual basic that have used graphical loops, but i'm not sure how to go about it in C++. In a windowed environment, isn't there always a loop running (the message loop)?

    if this loop has to be there in order to communicate with windows, does the graphics loop have to go inside this loop? i can't image how you could have two loops running at the same time.

    thanks,
    jmiller

  2. #2
    Hyperactive Member
    Join Date
    Sep 2001
    Posts
    396
    You are using MFC or just plain Win32 programming?

  3. #3
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Modify the message loop to look like this:
    Code:
    for(;;)
    {
      if(PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
      {
        if(msg.message == WM_QUIT)
          break;
        TranslateMessage(&msg);
        DispatchMessage(&msg);
      }
      // Game stuff here
    }
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  4. #4
    Frenzied Member
    Join Date
    Jul 1999
    Posts
    1,800
    or you could make a new thread

  5. #5
    Fanatic Member McCain's Avatar
    Join Date
    Jan 2002
    Location
    Sweden/Denmark
    Posts
    802
    CornedBee: Why do you use a for-loop? Is it faster than a while-loop?
    Never argue with fools, they will only drag you down to their level, and beat you with experience.

    Q: How do you tell an experienced hacker from a novice?
    A: The latter thinks there's 1000 bytes in a kilobyte, while the former is sure there's 1024 meters in a kilometer

  6. #6
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    I always use for(;; ) for infinite loops, it's shorter to write than while(true) and while(1) isn't C++-like.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  7. #7
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Except if you have a very stupid compiler (an anti-optimizing compiler so to say ) they are both exactly the same speed.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

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



Click Here to Expand Forum to Full Width