Jump to content
  • Advertisement

sainimu78

Member
  • Content Count

    16
  • Joined

  • Last visited

Community Reputation

121 Neutral

About sainimu78

  • Rank
    Member
  1. HRESULT hr; HDC hDc; IDirectDraw7* pDDraw; DDSURFACEDESC2 dDrawSurfDesc={0}; LPDIRECTDRAWSURFACE7 pDDrawSurf; LPDIRECTDRAWSURFACE7 pDDrawBcak; DDSCAPS2 ddscaps = {0}; hr = DirectDrawCreateEx(NULL, (LPVOID*)&pDDraw, IID_IDirectDraw7, NULL); hr = pDDraw->SetCooperativeLevel(hWnd, DDSCL_NORMAL);//DDSCL_ALLOWREBOOT | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN); //hr = pDDraw->SetDisplayMode(100, 100, 24, 0, 0); /* RECT rc; GetWindowRect(hWnd, &rc); SetWindowPos(hWnd, 0, rc.left, rc.top, rc.left+200, rc.top+200, 0); */ dDrawSurfDesc.dwSize = sizeof(dDrawSurfDesc); dDrawSurfDesc.dwFlags = DDSD_CAPS; dDrawSurfDesc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; hr = pDDraw->CreateSurface(&dDrawSurfDesc, &pDDrawSurf, NULL); hr = pDDrawSurf->Lock(NULL, &dDrawSurfDesc, DDLOCK_SURFACEMEMORYPTR, NULL); An error occurs at the last line. the error code is "0x887601b3 ". I don't know how to fix it    How to lock the primary surface? 
  2.     Oh, God, I'm making a GUI that will rendering images captured by an industrial camera in very high resolution. High resolution means a general size window can't fit that image size. If the image zoom out to fit the window, any details in the image can't be seen. If the image display on window with intact size, the users can drag some scrolls to see whole image. This is correct solution. My GUI shows in the attach file. Only part area of the whole need to rendering, so I use a RECT to Present(). pVertices[0].position = D3DXVECTOR3( -in->width/2, in->height/2, 0.0f); pVertices[0].color = 0xffffffff; pVertices[1].position = D3DXVECTOR3( -in->width/2, -in->height/2, 0.0f); pVertices[1].color = 0xffffffff; pVertices[2].position = D3DXVECTOR3( in->width/2, -in->height/2, 0.0f); pVertices[2].color = 0xffffffff; pVertices[3].position = D3DXVECTOR3( -in->width/2, in->height/2, 0.0f); pVertices[3].color = 0xffffffff; pVertices[4].position = D3DXVECTOR3( in->width/2, in->height/2, 0.0f); pVertices[4].color = 0xffffffff; pVertices[5].position = D3DXVECTOR3( in->width/2, -in->height/2, 0.0f); pVertices[5].color = 0xffffffff; pVertices[0].tu = 0.0f; pVertices[0].tv = 0.0f; pVertices[1].tu = 0.0f; pVertices[1].tv = in->height; pVertices[2].tu = in->width; pVertices[2].tv = in->height; pVertices[3].tu = 0.0f; pVertices[3].tv = 0.0f; pVertices[4].tu = in->width; pVertices[4].tv = 0.0f; pVertices[5].tu = in->width; pVertices[5].tv = in->height; g_pVB->Unlock(); --------------------------------------- D3DXMATRIXA16 matProj; D3DXMatrixOrthoLH(&matProj, 2, 2, 0, 1); g_pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj ); how can the window show the whole image. no zooming, no filterring,
  3.     That it is.   How to allocate a back buffer in specified size matters now.
  4.   I got it, but I think having the same size window is hard. Commonly, a window can be created is limited in 1400x800px.   So, I want to query a back buffer whose size is as the same as my source image. Actually, I tried that, but failed, I can't find anymore tutorials or articles about how to query back buffer in specified size.
  5. I have tried. I used the "Textures" example in dx sdk june10, but all my tryings of displaying look so pixelated.   Should I set the back buffer size to the image size? How to do this?   Or other methods should I take? if( FAILED( g_pd3dDevice->CreateVertexBuffer( 6*2 * sizeof( CUSTOMVERTEX ), 0, D3DFVF_CUSTOMVERTEX, D3DPOOL_DEFAULT, &g_pVB, NULL ) ) ) { return E_FAIL; } // Fill the vertex buffer. We are setting the tu and tv texture // coordinates, which range from 0.0 to 1.0 CUSTOMVERTEX* pVertices; if( FAILED( g_pVB->Lock( 0, 0, ( void** )&pVertices, 0 ) ) ) return E_FAIL; pVertices[0].position = D3DXVECTOR3( -1.0f, 1.0f, 0.0f); pVertices[0].color = 0xffffffff; pVertices[1].position = D3DXVECTOR3( -1.0f, -1.0f, 0.0f); pVertices[1].color = 0xffffffff; pVertices[2].position = D3DXVECTOR3( 1.0f, -1.0f, 0.0f); pVertices[2].color = 0xffffffff; pVertices[3].position = D3DXVECTOR3( -1.0f, 1.0f, 0.0f); pVertices[3].color = 0xffffffff; pVertices[4].position = D3DXVECTOR3( 1.0f, 1.0f, 0.0f); pVertices[4].color = 0xffffffff; pVertices[5].position = D3DXVECTOR3( 1.0f, -1.0f, 0.0f); pVertices[5].color = 0xffffffff; pVertices[0].tu = 0.0f; pVertices[0].tv = 0.0f; pVertices[1].tu = 0.0f; pVertices[1].tv = 1.0f; pVertices[2].tu = 1.0f; pVertices[2].tv = 1.0f; pVertices[3].tu = 0.0f; pVertices[3].tv = 0.0f; pVertices[4].tu = 1.0f; pVertices[4].tv = 0.0f; pVertices[5].tu = 1.0f; pVertices[5].tv = 1.0f; g_pVB->Unlock(); ......... cvNamedWindow("nihao"); cvResizeWindow(400, 300); hWnd = (HWND)cvGetWindowHandle("nihao"); ......... in=cvLoadImage("24bpp_1920*1200_1.bmp", 1); RECT rc; rc.left = 0, rc.top = 0; rc.right = in->width;//1920 rc.bottom = in->height;//1200 g_pd3dDevice->Present( NULL, &rc, hWnd, NULL ); I create a small size window of 400x300px on purpose that I had tested it out that the more pixelated the displaying , the smaller the window is.  
  6.     How to ensure that?   I have tried : in = cvLoadImage("24bpp_1920x1200_1.bmp", 1); rc.left = 0; rc.top =0; rc.bottom = in->height; rc.right = in->width; cvReleaseImage(&in); g_pd3dDevice->SetScissorRect(&rc); g_pd3dDevice->GetScissorRect(&rc); IDirect3DSurface9* pSurf = NULL; IDirect3DSurface9* pBB = NULL; IDirect3DSwapChain9* pSwapChain = NULL; g_pd3dDevice->GetSwapChain(0, &pSwapChain); pSwapChain->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &pSurf); g_pd3dDevice->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &pBB); hr = g_pd3dDevice->StretchRect(pSurf, NULL, pBB, &rc, D3DTEXF_LINEAR); Both methods totally make no effects. There are still pixelated 
  7.   I test it out The buffer size is equal to the window size.  But a window size is limited, commonly, in 1400x800   I tried pDevice->SetScissorRect(), It doesn't work.   How to set the buffer size?
  8. My program is modified from the sample code "texture" in dxsdk_june10.   This sample code load a texture using CreateTextureFromFile(). I substituted that function with CreateTexture() that loads a texture from memory
  9.   I need a window displaying a image by using dx.   I added.  these tow lines  ......... g_pd3dDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR); g_pd3dDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR); g_pd3dDevice->SetTexture( 0, g_pTexture ); .......... and they make no effects. The image displaying on the window is blurred or, say, pixelated as before.         I don't know how to enable mipmaps, could you?
  10. Let's make it simple Just how should I display the source image on the dx rendering scene, ignoring the displaying size.    
  11. The source image is 1920x1200 px.    Here is my render funtion: VOID Render() { // Clear the backbuffer and the zbuffer g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB( 0, 0, 255 ), 1.0f, 0 ); // Begin the scene if( SUCCEEDED( g_pd3dDevice->BeginScene() ) ) { g_pd3dDevice->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_BORDER); g_pd3dDevice->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_BORDER); g_pd3dDevice->SetSamplerState(0, D3DSAMP_BORDERCOLOR, 0x000000ff); g_pd3dDevice->SetTexture( 0, g_pTexture ); // Render the vertex buffer contents g_pd3dDevice->SetStreamSource( 0, g_pVB, 0, sizeof( CUSTOMVERTEX ) ); g_pd3dDevice->SetFVF( D3DFVF_CUSTOMVERTEX ); g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, 2);//2 * 50 - 2 ); // End the scene g_pd3dDevice->EndScene(); } // Present the backbuffer contents to the display // shows in two windows g_pd3dDevice->Present( NULL, NULL, NULL, NULL ); HWND hWnd = WindowFromDC(g_hDc); RECT rc; rc.bottom = 600, rc.left = 100, rc.right = 600, rc.top = 100; //RECT rc; rc.bottom = in->height, rc.left = 0, rc.right = in->width, rc.top = 0; g_pd3dDevice->Present( NULL, &rc, hWnd, NULL ); } What will be seen shows in the attach file   Why does the image the program displays look so blurred? How to set the texture to look better. The source image is 1920x1200 px !
  12. Thanks a lot. Your advices are very helpful and my problem get solved  . 
  13. I have a window and I can get a HDC via GetDC() from the window. Now I want a cube rendering on the HDC that can be gotten from my own window, how should I do? The rendering function looks like this: void D3dRender(HDC myHdc) { //usual D3dRender on the HDC I provide }  Only can I find examples of rendering on the HDC created by D3D itself. Thus I can pD3dSurface->GetDC(), but can't "pD3dSurface->SetDC()". Yes, there is no such method in IDirect3DSurface9 class.
  14.    DeviceCaps Viewer is very helpful to underestanding  Thank you, I know how to do
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!