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. message loop in directx

message loop in directx

Scheduled Pinned Locked Moved C / C++ / MFC
game-devgraphicsquestion
2 Posts 2 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
    shaderx
    wrote on last edited by
    #1

    Hi, I am trying to write a fullscreen game... and I have a question about the message loop I am curently using the following form: while(msg.message!=WM_QUIT) if(PeekMessage(&msg,0,0,0,PM_REMOVE)){ TranslateMessage(&msg); DispatchMessage(&msg); } else Render(); whitch ain't so bad for the momment, but in future it's gonna have multiplayer and user input,and other stuff.I saw in Quake3's source the loop was way diffrent. And now the question: Can anyone(hwo had previously worked whit somethings like that ...hopefully)give me an ideea about how the message loop should be like. Thnaks

    Z 1 Reply Last reply
    0
    • S shaderx

      Hi, I am trying to write a fullscreen game... and I have a question about the message loop I am curently using the following form: while(msg.message!=WM_QUIT) if(PeekMessage(&msg,0,0,0,PM_REMOVE)){ TranslateMessage(&msg); DispatchMessage(&msg); } else Render(); whitch ain't so bad for the momment, but in future it's gonna have multiplayer and user input,and other stuff.I saw in Quake3's source the loop was way diffrent. And now the question: Can anyone(hwo had previously worked whit somethings like that ...hopefully)give me an ideea about how the message loop should be like. Thnaks

      Z Offline
      Z Offline
      Zac Howland
      wrote on last edited by
      #2

      The Quake 3 source isn't that much different (and neither is most other PC games message loops):

      WPARAM MainLoop()
      {
      	MSG msg;
      	while (1)
      	{
      		if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
      		{
      			if (msg.message == WM_QUIT)
      				break;
      			TranslateMessage(&msg);
      			DispatchMessage(&msg);
      		}
      		else
      		{
      			// rendering calls goes here
      		}
      	}
      
      	// cleanup code goes here
      	return msg.wParam;
      }
      

      It really isn't that much different than what you have.

      If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week Zac

      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