Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Game loop

Game loop

Scheduled Pinned Locked Moved C / C++ / MFC
game-devquestiongraphics
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    snir_ya
    wrote on last edited by
    #1

    Hi all, I'm writing a game application with a main lobby where players can select a game which opens in a different frame window. Players can open several games at a time so actually there's only one view that needs to be rendered at a time. The game loop should respond to key and mouse events using directInput (directX). My question is where do i place the game loop? Should it be in the main application's run method? Should it answer onpaint messages on the currently active view? Thanks in advnace. Snir_ya.

    J 1 Reply Last reply
    0
    • S snir_ya

      Hi all, I'm writing a game application with a main lobby where players can select a game which opens in a different frame window. Players can open several games at a time so actually there's only one view that needs to be rendered at a time. The game loop should respond to key and mouse events using directInput (directX). My question is where do i place the game loop? Should it be in the main application's run method? Should it answer onpaint messages on the currently active view? Thanks in advnace. Snir_ya.

      J Offline
      J Offline
      Jeremy Falcon
      wrote on last edited by
      #2

      snir_ya wrote:

      My question is where do i place the game loop?

      This is an open ended question as we don't really know your plan. Are these individual games running in their own process space, in a new thread, or what? Each game (assuming they are independent) should have its own main loop more times than not - even if they have to interact with one another via IPC or whatever. Also, don't put your main game loop in WM_PAINT for D3D or DD. It should be independent of GDI operations and either ran in or called from within the process' main loop (e.g.; WinMain(), main(), etc.).

      Jeremy Falcon Oatmeal, It's What's for Dinner.[^]

      M 1 Reply Last reply
      0
      • J Jeremy Falcon

        snir_ya wrote:

        My question is where do i place the game loop?

        This is an open ended question as we don't really know your plan. Are these individual games running in their own process space, in a new thread, or what? Each game (assuming they are independent) should have its own main loop more times than not - even if they have to interact with one another via IPC or whatever. Also, don't put your main game loop in WM_PAINT for D3D or DD. It should be independent of GDI operations and either ran in or called from within the process' main loop (e.g.; WinMain(), main(), etc.).

        Jeremy Falcon Oatmeal, It's What's for Dinner.[^]

        M Offline
        M Offline
        Mark Salsbery
        wrote on last edited by
        #3

        Jeremy Falcon wrote:

        don't put your main game loop in WM_PAINT

        :-D mmmm...oatmeal... Happy new year Jeremy!

        Mark Salsbery Microsoft MVP - Visual C++ :java:

        J 1 Reply Last reply
        0
        • M Mark Salsbery

          Jeremy Falcon wrote:

          don't put your main game loop in WM_PAINT

          :-D mmmm...oatmeal... Happy new year Jeremy!

          Mark Salsbery Microsoft MVP - Visual C++ :java:

          J Offline
          J Offline
          Jeremy Falcon
          wrote on last edited by
          #4

          Mark Salsbery wrote:

          mmmm...oatmeal...

          ;)

          Mark Salsbery wrote:

          Happy new year Jeremy!

          You too man! Here's to another great year of procrastination! :laugh:

          Jeremy Falcon Oatmeal, It's What's for Dinner.[^]

          M 1 Reply Last reply
          0
          • J Jeremy Falcon

            Mark Salsbery wrote:

            mmmm...oatmeal...

            ;)

            Mark Salsbery wrote:

            Happy new year Jeremy!

            You too man! Here's to another great year of procrastination! :laugh:

            Jeremy Falcon Oatmeal, It's What's for Dinner.[^]

            M Offline
            M Offline
            Mark Salsbery
            wrote on last edited by
            #5

            Jeremy Falcon wrote:

            Here's to another great year of procrastination!

            I'm putting that off for a while...

            Mark Salsbery Microsoft MVP - Visual C++ :java:

            S 1 Reply Last reply
            0
            • M Mark Salsbery

              Jeremy Falcon wrote:

              Here's to another great year of procrastination!

              I'm putting that off for a while...

              Mark Salsbery Microsoft MVP - Visual C++ :java:

              S Offline
              S Offline
              snir_ya
              wrote on last edited by
              #6

              Cheers Jeremy and Mark - Happy new year to ya too.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups