• Advertisement

Pygmyowl

Member
  • Content count

    7
  • Joined

  • Last visited

Community Reputation

114 Neutral

About Pygmyowl

  • Rank
    Newbie
  1. Pretty much what the title says. I want to implement something similar to what is used in Terraria: textured tile-based (by which I mean comprised of physical blocks - just in case) modifiable terrain (in 2D, side view). Except with a lot more tiles to draw (I intend to use variable zoom; my current hopes are to draw about 150,000 tiles at the camera's furthest, but I'd still need 4x4 textures for when the camera is up close). What would be the fastest way to draw this? Or maybe I'm way in the dream land here?   On a somewhat related note, I'm currently using textured quads to draw objects, because I've read that ID3DXSPRITE is deprecated, not as flexible, and so on. Is this true?
  2. VSync messing with QPC() timing?

    Speaking of which, I tried obtaining the swap chain pointer from the device (using GetSwapChain) and calling Present from that (it has a flag parameter, like PresentEx), but D3DPRESENT_DONOTWAIT didn't have any effect. As it happens, my laptop has Intel and NVidia GPUs.   That said, is PresentEx any different from what I've tried? Should I give it a go nonetheless?   Update: I've come across an article describing the use of GetRasterStatus to determine if the frame is still being drawn. Adding this to my second timer check (so the render function isn't called until the display has finished drawing) seems to have fixed the problem. Just in case, the second check now looks like this: if((timer.tickCount.QuadPart-timer.memory1.QuadPart)>=(timer.tickFreq.QuadPart/GlobalParams.MaxFPS)) { d3ddev->GetRasterStatus(0,&d3drst); if(d3drst.InVBlank==true) { FramePass(); phystick=0; timer.memory1.QuadPart=timer.tickCount.QuadPart; } } Are there any potential problems I'm not seeing?
  3. VSync messing with QPC() timing?

    Since you've mentioned IDXGISwapChain, does your method require DirectX 10 or higher?   Sadly, adding the flag did nothing. I've mentioned before that, as per Hodgman's suggestion, this is probably a frame queueing problem.
  4. VSync messing with QPC() timing?

    In response to Hodgman: Thanks for the information on VSync and GPU queueing, it does indeed seem that frames were being fed to the display faster than it could draw them. I've slightly lowered the render function call frequency and the slowdowns seem to have ceased. I don't suppose it's too much of a crutch to render at (screen update rate)-1Hz if VSync is enabled?   As for my physical calculations, I've only just started figuring them out (hence the extreme update rate, for instance - I've decided to play it safe to avoid collision skips and such, but looks like I've overdone it). Thanks for everyone's suggestions, I'll definitely make use of them.
  5. VSync messing with QPC() timing?

    But why does the slowdown only occur after several seconds, then? To clarify, at first everything is just like without VSync, with phystick showing 16-17 every frame (that's got to mean first "if" fires 16.(6) times as often as the second one... right?). Then it slowly drops. And even so, it stays higher than 1, so "while(true)" must be firing at more than 60Hz.
  6. VSync messing with QPC() timing?

    Um, I didn't quite get it. Are you saying VSync stalls the rendering function until the display has finished drawing the previously presented frame? So the "while(true)" only fires once every 16.(6) ms?   Regarding the "physicsAccumulator": I've considered passing the time since the last physics iteration to ProcessPhysics(), so that it would advance the game world by that amount, but then, if a game were to freeze momentarily, there would be a skip. I thought it would make quite a mess of things, so I've decided to use a fixed step size.
  7. I apologize if this is the wrong subforum, but I couldn't quite figure out where to post this. Anyway, I'm currently trying to make my physical calculations independent from rendering. What I've done is make every physical object store its transformation matrices, which are then modified during physical calculations or used for rendering. Calculations and rendering are initiated in the message loop as follows: timer.Update(); //this essentially does the QueryPerformanceCounter(&tickCount) if((timer.tickCount.QuadPart-timer.memory1.QuadPart)>=(timer.tickFreq.QuadPart/GlobalParams.PhysicsFreq)) { ProcessPhysics(ObjectList,GlobalParams.PhysicsFreq); timer.memory1=timer.tickCount; phystick++; } if((timer.tickCount.QuadPart-timer.memory2.QuadPart)>=(timer.tickFreq.QuadPart/GlobalParams.MaxFPS)) { FramePass(); timer.memory2=timer.tickCount; phystick=0; } Notes: timer is a custom object; tickFreq is initialized via QueryPerformanceFrequency(&tickFreq) in the constructor; memory1, memory2 and phystick are pre-initialized to zero; phystick is displayed during rendering using ID3DXFont interface. Also, let's assume MaxFPS to be 60 and PhysicsFreq to be 1000. And I'm using a laptop.   Now, I've decided to do the whole "count the ticks" thing to check that "physics-to-frames" ratio stays the same. And here's the problem. Without VSync (D3DPRESENT_INTERVAL_IMMEDIATE), it's fine. With VSync (D3DPRESENT_INTERVAL_ONE), it stays level for around 5 seconds and then gradually drops to roughly 1/3rd of its original value. All movements slow down as well.   I've tried commenting out the physics call, updating tickFreq every Update(), but nothing works. FramePass() is executed at stable intervals, I've checked. What in the world could I be missing? (Also, feel free to point out if my concept is a waste of time.)
  • Advertisement