Модераторы: Rickert, Alexeis, BorisVorontsov
  

Поиск:

Ответ в темуСоздание новой темы Создание опроса
> Получить BitMap из поверхности Direct3D, не получается( 
:(
    Опции темы
Sartorius
Дата 27.1.2007, 08:21 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Эксперт
***


Профиль
Группа: Завсегдатай
Сообщений: 1568
Регистрация: 18.7.2006
Где: Ivory tower

Репутация: нет
Всего: 37



 Всем привет smile 
Пытаюсь записать avi-ку из сцены Direct3D. Для этого необходимо получать битмапы и присоединять их к avi-файлу. Вот с этим то и проблема(((

Делаю так:
Получаю поверхность и контекст от нее
Код

g_pd3dDevice->CreateOffscreenPlainSurface(WINDOW_WIDTH, WINDOW_HIGHT,D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &_surface, 0); 

// Получаем описание поверхности
_surface->GetDesc(&surfaceDesc);
_surface->GetDC(&hdcsceen);


далее создаю совместимый контекст в памяти
Код

hdcscreen = CreateCompatibleDC(hdcsceen);


и DIB секцию под него

Код

            BITMAPINFO bi; ZeroMemory(&bi,sizeof(bi)); BITMAPINFOHEADER &bih = bi.bmiHeader;
            bih.biSize=sizeof(bih);
            bih.biWidth=WINDOW_WIDTH;
            bih.biHeight=WINDOW_HIGHT;
            bih.biPlanes=1;
            bih.biBitCount=24; //???
            bih.biCompression=BI_RGB;
            bih.biSizeImage = ((bih.biWidth*bih.biBitCount/8+3)&0xFFFFFFFC)*bih.biHeight;
            bih.biXPelsPerMeter=10000;
            bih.biYPelsPerMeter=10000;
            bih.biClrUsed=0;
            bih.biClrImportant=0;
            
            hbm=CreateDIBSection(hdcscreen,(BITMAPINFO*)&bih,DIB_RGB_COLORS,&bits,NULL,NULL);
            HGDIOBJ holdb=SelectObject(hdcscreen,hbm);


потом просто 
Код

BitBlt(hdcscreen, 0, 0, WINDOW_WIDTH, WINDOW_HIGHT, hdcsceen, 0, 0, SRCCOPY); 


Но сцены в итоге там нет. Все что рисуешь на hdcsceen GDI есть, а Direct3D нет...
Кто может че нить посоветовать?
PM MAIL ICQ   Вверх
Sartorius
Дата 27.1.2007, 15:14 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Эксперт
***


Профиль
Группа: Завсегдатай
Сообщений: 1568
Регистрация: 18.7.2006
Где: Ivory tower

Репутация: нет
Всего: 37



 Ну хоть какой-нить пример захвата 3D сцены, чтоб DIB потом можно было в памяти получить.... smile 
Нигде не могу найти  smile 

Во... кое чего нашел на sourcecodeplanet: мало ли кому пригодиться (сейчас возможности прикрутить к своей проге нет)
Код


/*
//    Take screenshots in DirectX apps, Fast!!
//    deja_vu [ 11:46 PM 9/5/2003 ]
//    comments to : [email protected]
*/


/*
// This tutorial assumes that you have pretty basic knowledge of DirectX..
// how to initialise DirectX and create a Direct3D device. it is assumed that 
// a Direct3D device called "g_pd3dDevice" has been created..
*/

void TakeScreenShot(char* filename)
{
    /*
        we create a pointer to the IDirect3DSurface8 interface.. this is to store the
        actual Direct3D surface thats being used as the render target..
    */
    LPDIRECT3DSURFACE8 surf = NULL;

    /*
        we then get the current render target from the Direct3D device.. here 
        g_pd3dDevice is the Direct3D device which I assume was created earlier.. 
        The GetRenderTarget() function retrieves a pointer to the current Direct3D 
        surface thats being used as a render target..
    */
    if(g_pd3dDevice->GetRenderTarget(&surf) == D3D_OK)
    {
    /*
        The D3DXSaveSurfaceToFile() function takes in 5 parameters,
        1st param    -  filename to save the surface to..

        2nd param    -  is a D3DXIMAGE_FILEFORMAT flag, D3DXIFF_BMP
                   and D3DXIFF_DDS seems to be the only two 
                   supported.. for now!?

        3rd param    -  is the pointer to the Direct3DSurface( the one we
                   want to save)

        4th param    -  this is a pointer to PALETTEENTRY structure. we are 
                   not using it so, NULL..

        5th param    -  this is a rect specifing the area to be saved.. the 
                   total area is saved if this is NULL is passed..
    */
        D3DXSaveSurfaceToFile(filename,D3DXIFF_BMP,surf,NULL,NULL);
    }

    //    to prevent any memory leaks we release the surface after we use it..
    if(surf != NULL)
        surf->Release();
}



Это сообщение отредактировал(а) Sartorius - 27.1.2007, 15:36
PM MAIL ICQ   Вверх
  
Ответ в темуСоздание новой темы Создание опроса
Вы можете найти полезным что...
Alexeis
Rickert
  • Английская документация по DirectX лежит где-то здесь.
  • Английская документация по OpenGL лежит где-то там.
  • Гейм-дев у нас обсуждают где-то тут

Ждём вас! С уважением, Alexeis, Rickert.

 
0 Пользователей читают эту тему (0 Гостей и 0 Скрытых Пользователей)
0 Пользователей:
« Предыдущая тема | C/C++: Мультимедия, OpenGL/DirectX | Следующая тема »


 




[ Время генерации скрипта: 0.0417 ]   [ Использовано запросов: 22 ]   [ GZIP включён ]


Реклама на сайте     Информационное спонсорство

 
По вопросам размещения рекламы пишите на vladimir(sobaka)vingrad.ru
Отказ от ответственности     Powered by Invision Power Board(R) 1.3 © 2003  IPS, Inc.