JensE

Members
  • Content count

    32
  • Joined

  • Last visited

Community Reputation

122 Neutral

About JensE

  • Rank
    Member
  1. I know that I can leave "this->" out, but I got used to do it like that so I always see what variables and functions are class members, it's just a visual thing. But that is'nt my problem. Had anybody got the same problem with switching taking soooo long?
  2. Hi, I've got a switching method for toggling windowed - fullscreen, which works good - if I don't render anything. The time needed to switch then is hardly 1 second. If I render a simple cube, it takes almost 10 seconds! But there are neither D3D errors nor warnings, and the device is never lost. Here are my switching methods: bool CSingleView::SwitchWindowed(void) { // Get current mode VIDEOMODE stCurrMode; this->GetVideoMode(&stCurrMode); stCurrMode.bWindowed = !stCurrMode.bWindowed; // a) fullscreen => windowed if (stCurrMode.bWindowed) { stCurrMode.enBBFormat = this->m_stDesktopMode.enFormat; stCurrMode.enAdapterFormat = this->m_stDesktopMode.enFormat; } // b) windowed => fullscreen else { stCurrMode.wHrzRes = this->m_wModeWidth; stCurrMode.wVrtRes = this->m_wModeHeight; stCurrMode.enBBFormat = this->m_enModeFormat; stCurrMode.enAdapterFormat = this->m_enModeFormat; // Resize depth buffer if necessary if (this->m_pcDepthStencil != NULL) { if (this->m_wDSWidth < this->m_wModeWidth) this->m_wDSWidth = this->m_wModeWidth; if (this->m_wDSHeight < this->m_wModeHeight) this->m_wDSHeight = this->m_wModeHeight; } } this->AdjustRenderWindow(); if (!this->InitalizeMode(&stCurrMode, this->m_RenderParams.enSwapEffect, this->m_wDSWidth, this->m_wDSHeight, this->m_RenderParams.nBBCount, this->m_hFocusWnd, this->m_RenderParams.dwPresInterval, this->m_RenderParams.dwFlags, this->m_RenderParams.dwFlags) return false // Re-position the window if(stCurrMode.bWindowed) SetWindowPos((HWND) this->m_apcRenderViews[0]->GetRenderWindow(), HWND_NOTOPMOST, this->m_stRect.dwLeft, this->m_stRect.dwTop, this->m_stRect.dwRight - this->m_stRect.dwLeft, this->m_stRect.dwBottom - this->m_stRect.dwTop, SWP_SHOWWINDOW); return true; } void CSingleView::AdjustRenderWindow(void) { if (!this->m_RenderParams.bWindowed) { SetWindowLong((HWND) this->m_apcRenderViews[0]->GetRenderWindow(), GWL_STYLE, m_dwWindowStyle); } else { SetWindowLong((HWND) this->m_apcRenderViews[0]->GetRenderWindow(), GWL_STYLE, WS_POPUP | WS_SYSMENU | WS_VISIBLE); } return ; } Can someone tell me why it takes 10 seconds if I render?
  3. Yes, now I got it, thanks =). And my old way to get the fps was not really correct, I don't know why. I used QueryPerformanceCounter() - the formula fps = 1 / frame_time Which gives me the same fps as your way to do it for rendering my cube windowed. But then after switching to fullscreen, the structure with my fps display is 10000 - 30 - 11222 - 29.34 .... the other way it's always around 60 which indicates VSync is on. And the "slow movement" then is clear too - How to turn VSync off ? I DO use INTERVAL_IMMEDIATE and DISCARD, what else to do? AND: Why does toggling from windowed to fullscreen take TEN SECONDS when I render a cube, if I only clear it takes ONE SECOND !!!! With best wishes, Jens
  4. You update every frame and internally set last time = new time, so you can control movement and get the passed time for one frame, and then you additionally must have another time counter that determines if one second passed AND a counter to count the passed frames for one second? If one second passed you first calculate and then display / put out the fps. Is that correct?
  5. Quote:Original post by sirob IS VSync on? Because you seem to be getting an FPS of 30, which could indicate VSync is on. I don't know - I use discard as swap effect and when specifiyng D3DPRESENT_INTERVAL_IMMEDIATE I get the same fps. Quote:Also, you're writing the FPS to the file once per frame, that would provide inaccurate results. I do it once per second. Ok, but how? I update the timer and fetch the new time every frame, there seems to be no way to determine that one second has passed, please give me a tip!
  6. Ok, I've got some problems posting, but I think now it's ok. This line is for multiple back buffers. But in this example the value is ONE. I render the scene only ONCE per frame, I'm sure about that.
  7. Hallo, I create a renderer able to render a single view in fullscreen and windowed. Testing the renderer without rendering, all worked well. But when rendering a simple cube, the movement is way too slow (I rotate around all three axes around 0.001f), after switching to fullscreen it's much slower. Also switching takes 10 seconds (!!!) when rendering something into the window, and only 1 second, if I render nothing. Can you please give me a hint why the movement slows down after toggling and toggling takes up so long? Please consider the following: - D3D neither produces errors nor warnings (full output level) - The fps raise when I make the window smaller(AND the back buffer via Reset()) in windowed (halfe size = double fps) - Although I can SEE the rotation is very slow (+= 0.001 per frame!), my timer says the fps are over 1400, and after switching to fullscreen I get this weird fps structure: FPS: 11546.919922 FPS: 30.056973 FPS: 11546.919922 FPS: 30.051420 FPS: 9346.071289 FPS: 30.077681 FPS: 9780.177734 FPS: 30.072124 - I found out that if I comment out DrawIndexedPrimitiveUP(), all works as expected (except that nothing is rendered). My render routine looks like this: bool Render(DWORD dwID, APIRenderer *pcRenderer) { cTimer.Update() LPDIRECT3DDEVICE8 pcDevice = (LPDIRECT3DDEVICE8) pcRenderer->m_pvObject; D3DMATERIAL8 stMat; ZeroMemory(&stMat, sizeof(D3DMATERIAL8)); stMat.Ambient.r = 1.0f; stMat.Ambient.g = 0.9f; stMat.Ambient.b = 0.4f; stMat.Diffuse.r = 1.0f; stMat.Diffuse.g = 1.0f; stMat.Diffuse.b = 0.3f; // if (FAILED(pcDevice->SetMaterial(&stMat))) // return false; // if (FAILED(pcDevice->SetTexture(0, pcTex))) // return false; D3DTVERTEX astVerts[8]; astVerts[0].fx = 1.0f; astVerts[0].fy = 1.0f; astVerts[0].fz = - 1.0f; astVerts[0].fNx = 0.333333f; astVerts[0].fNy = 0.666667f; astVerts[0].fNz = - 0.666667f; astVerts[0].tu = 1.0f; astVerts[0].tv = 0.0f; astVerts[1].fx = - 1.0f; astVerts[1].fy = 1.0f; astVerts[1].fz = - 1.0f; astVerts[1].fNx = - 0.816497f; astVerts[1].fNy = 0.408248f; astVerts[1].fNz = - 0.408248f; astVerts[1].tu = 0.0f; astVerts[1].tv = 0.0f; astVerts[2].fx = - 1.0f; astVerts[2].fy = 1.0f; astVerts[2].fz = 1.0f; astVerts[2].fNx = - 0.333333f; astVerts[2].fNy = 0.666667f; astVerts[2].fNz = 0.666667f; astVerts[2].tu = 0.5f; astVerts[2].tv = 1.0f; astVerts[3].fx = 1.0f; astVerts[3].fy = 1.0f; astVerts[3].fz = 1.0f; astVerts[3].fNx = 0.816497f; astVerts[3].fNy = 0.408248f; astVerts[3].fNz = 0.408248f; astVerts[3].tu = 0.0f; astVerts[3].tv = 0.2f; astVerts[4].fx = 1.0f; astVerts[4].fy = - 1.0f; astVerts[4].fz = - 1.0f; astVerts[4].fNx = 0.666667f; astVerts[4].fNy = - 0.666667f; astVerts[4].fNz = - 0.333333f; astVerts[4].tu = 1.0f; astVerts[4].tv = 1.0f; astVerts[5].fx = - 1.0f; astVerts[5].fy = - 1.0f; astVerts[5].fz = - 1.0f; astVerts[5].fNx = -0.408248f; astVerts[5].fNy = -0.408248f; astVerts[5].fNz = -0.816497f; astVerts[5].tu = 0.0f; astVerts[5].tv = 1.0f; astVerts[6].fx = - 1.0f; astVerts[6].fy = - 1.0f; astVerts[6].fz = 1.0f; astVerts[6].fNx = -0.666667f; astVerts[6].fNy = -0.666667f; astVerts[6].fNz = 0.333333f; astVerts[6].tu = 0.0f; astVerts[6].tv = 0.0f; astVerts[7].fx = 1.0f; astVerts[7].fy = - 1.0f; astVerts[7].fz = 1.0f; astVerts[7].fNx = 0.408248f; astVerts[7].fNy = - 0.408248f; astVerts[7].fNz = 0.816497f; astVerts[7].tu = 1.0f; astVerts[7].tv = 0.0f; WORD astInds[36] = {0,1,2,0,2,3,0,4,5,0,5,1,1,5,6,1,6,2,2,6,7,2,7,3,3,7,4,3,4,0,4,7,6,4,6,5}; if (FAILED(pcDevice->SetVertexShader(D3DFVF_TVERTEX))) return false; if (FAILED(pcDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST, 0, 8, 12, astInds, D3DFMT_INDEX16, astVerts, sizeof(D3DTVERTEX)))) return false; fprintf(pFile, "FPS: %f\n", cTimer.GetFPS()); return true; } And the framework around this call is similar to this: bool CRenderView::Render(APIRenderer *pcRenderer, APISurface *pcDepthStencil, DWORD dwClearFlags) { pcRenderer->SetProjection(this->m_stViewInfo.pcProjection->GetProject()); pcRenderer->SetView(this->m_stViewInfo.pcCamera->GetView()); for (BYTE i = 0; i < this->m_nBBCount; ++i) { if (this->m_pFMoveFunc != NULL) if (!this->m_pFMoveFunc(this->m_stViewInfo.dwID, pcRenderer)) return false; if (!pcRenderer->SetRenderTarget(this->m_apcBack[i], pcDepthStencil)) return false; if (!pcRenderer->Clear(0, NULL, dwClearFlags, this->m_stViewInfo.stClearColor, this->m_stViewInfo.fDepthClear, this->m_stViewInfo.dwStencilClear)) return false; if (!pcRenderer->BeginScene()) return false; // fprintf(pFile, "Before Render\n"); if (this->m_pFRenderFunc != NULL) if (!this->m_pFRenderFunc(this->m_stViewInfo.dwID, pcRenderer)) return ERR_OBJECT_LOST; // fprintf(pFile, "After Render\n"); if (!pcRenderer->EndScene()) return false; // this->m_pcSwap == NULL bedeutet: Es wird die Swap Chain des Devices verwendet if (!pcRenderer->Present(NULL, NULL, NULL)) return false } return R_OK; } The render function is stored in to a function pointer, also the move func. Ok, that's all I have to say. Anybody experienced the same problem?
  8. Hi, I wonder if I should use one window (the main window - application window) or two windows (application window as focus window, a child as the render window). If I use only the application window, there are some disadvantages: - Switching between windowed and fullscreen mode crashes and I don't know why (with two windows it works great) - In OpenGL you must destroy the window, if you switch modes, and then recreate it. Is that correct? So I want to know what you do, when you render something fullscreen. Is there a standard way?
  9. 2 DX8 problems, again

    I'm totally sure that the ms type is compatible with the selected depth buffer format. Furthermore the device is Reset() with EnableAutoDepthStencil set to false and AutoDepthStencilFormat set to D3DFMT_UNKNOWN. The depth buffer would be created afterwards, but before that Reset() fails, that is the problem. Quote: Click on the depth stencil format you are trying to create and check the supported quality levels. 1 technically means it's not supported. I use D3D8 for now, and there don't seem to exist quality levels as in D3D9. -------------------------------------------------------- The Present() problem confuses me more and more. After I installed older nvidia drivers (because I wanted to play Thief 1 [embarrass]) the problem disappeared. I disagree with what you said about my message handling: Quote: The PostQuitMessage function indicates to the system that a thread has made a request to terminate (quit). It is typically used in response to a WM_DESTROY message. When the thread retrieves the WM_QUIT message from its message queue, it should exit its message loop and return control to the system. The exit value returned to the system must be the wParam parameter of the WM_QUIT message. I can leave PostQuitMessage() out and end the message loop, if bEndApp is true, but that would not be the windows standard way.
  10. Yes, you can find one on Gamedev.net: http://www.gamedev.net/reference/articles/article420.asp Ok, this one only describes the theory behind, and not how to use it. But some googling and searching on gamedev, gamasutra and co. would help.
  11. To sum up: An incomplete list: - swap chains - depth buffer - Non-D3DPOOL_DEFAULT objects (textures, VBs, render targets, IBs) - state blocks - render states - fonts - meshes - sprites Only shaders (since DX8) and Non-D3DPOOL_DEFAULT resources survive a call to Reset(). This way - when resetting - you can do everything you would do when creating the device.
  12. camera rotation killing me!?

    Try using this code: void CCamera::Update(void) { this->m_cView._14 = this->m_cView._24 = this-> m_cView._34 = 0.0f; this->m_cView._44 = 1.0f; this->m_cView._11 = this->m_cRight.x; this->m_cView._21 = this->m_cRight.y; this->m_cView._31 = this->m_cRight.z; this->m_cView._41 = - vec3_Dot(&this->m_cRight, &this ->m_cPos); this->m_cView._12 = this->m_cUp.x; this->m_cView._22 = this->m_cUp.y; this->m_cView._32 = this->m_cUp.z; this->m_cView._42 = - vec3_Dot(&this->m_cUp, &this-> m_cPos); this->m_cView._13 = this->m_cDir.x; this->m_cView._23 = this->m_cDir.y; this->m_cView._33 = this->m_cDir.z; this->m_cView._43 = - vec3_Dot(&this->m_cDir, &this-> m_cPos); return ; } void CCamera::RotRel(float fRotRelX, float fRotRelY) { Matrix4x4 cMatX, cMatY; this->m_fRotX += fRotRelX; this->m_fRotY += fRotRelY; // Avoid overflow if (this->m_fRotX > 2 * pi) this->m_fRotX -= (2 * pi); else if (this->m_fRotX < - 2 * pi) this->m_fRotX += (2 * pi); if (this->m_fRotY > 2 * pi) this->m_fRotY -= (2 * pi); else if (this->m_fRotY < - 2 * pi) this->m_fRotY += (2 * pi); this->m_cRight = Vector3(1.0f, 0.0f, 0.0f); this->m_cUp = Vector3(0.0f, 1.0f, 0.0f); this->m_cDir = Vector3(0.0f, 0.0f, 1.0f); m44_RotAxis(&cMatY, this->m_fRotY, &this->m_cUp); vec3_TransfCoord(&this->m_cRight, &this->m_cRight, &cMatY); vec3_TransfCoord(&this->m_cDir, &this->m_cDir, &cMatY); m44_RotAxis(&cMatX, this->m_fRotX, &this->m_cRight); vec3_TransfCoord(&this->m_cUp, &this->m_cUp, &cMatX); vec3_TransfCoord(&this->m_cDir, &this->m_cDir, &cMatX); vec3_Norm(&this->m_cDir, &this->m_cDir); this->m_cRight = *vec3_Cross(&this->m_cRight, &this-> m_cUp, &this->m_cDir); vec3_Norm(&this->m_cRight, &this->m_cRight); this->m_cUp = *vec3_Cross(&this->m_cUp, &this->m_cDir, &this->m_cRight); vec3_Norm(&this->m_cUp, &this->m_cUp); this->Update(); return ; } void CCamera::MoveRel(float fMoveRel) { this->m_cPos += (this->m_cDir * fMoveRel); this->Update(); return ; } If you want to use it, note the following: - The camera has 4 vectors: Up, Right, Direction and Position - I use my own matrix and vector functions / types. You must replace them by the according d3dx functions. - The move function can only move in camera direction. - Everytime the user presses the "move forward" key, you call MoveRel(). - Everytime the user presses a rotate key, you call RotRel() - For any further questions please post.
  13. 2 DX8 problems, again

    This code doesn't seem to make a difference. With the "while(PeekMessage())" statement I fetch all messages currently available, and after that I render. What would the "else" change, even if there was an "if" before? Did you mean: if (PeekMessage(...)) { ... } else { Render(); } This way I would only fetch ONE message every frame! Additionally, there won't be performed any rendering at all, because it is only rendered, if there is NO message in the queue!
  14. Help please

    Use the latest version of DirectX (9.0b). If you want to develop with DX you'll need the DX SDK (http://www.microsoft.com/downloads/details.aspx?FamilyID=124552ff-8363-47fd-8f3b-36c226e04c85&displaylang=en). It includes the normal runtime version, so you can use it for developing AND gaming. If you install it, you should install the debug version. If you used the internet setup the setup files may be located in a temporary folder (a hidden folder called "temp", sub-folder "DirectX 9.0") or in a folder you specified. How to use it? --> Install it. Where to get it? --> Use the link above or search on www.microsoft.com