Jump to content
  • Advertisement
Sign in to follow this  
Tsuyo

CreateDevice using R8G8B8 returns NULL [c++][dx9]

This topic is 2610 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey guys, hopefully this is the right section here.
First, to introduce myself, i switched a half a year ago to C++ because i like it much more than the .NET languages.
I started Dx a while ago and never had problems with it, but now i'm having a bit trouble.

I create my Direct3DDevice9 Pointer like so:


LPDIRECT3D9 pD3D = Direct3DCreate9(D3D_SDK_VERSION);
D3DPRESENT_PARAMETERS params;
params.Windowed = TRUE;
params.SwapEffect = D3DSWAPEFFECT_DISCARD;
params.BackBufferFormat = D3DFMT_R8G8B8;
params.Flags |= D3DPRESENTFLAG_LOCKABLE_BACKBUFFER;

pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_HARDWARE_VERTEXPROCESSING, &d3dpp, &pd3dDevice);


But if i use D3DFMT_R8G8B8 as the BackBufferFormat, the Device is NULL. Using X8R8G8B8, it works.
Could someone tell me, why this error occours? What i want to do is to draw onto my Logitech G19 Keyboard LCD.
I can use Gdi+, but since i'm in a process(Games/Videoplayer/etc), i wanted to use Dx directly. The G19 Documentation says, i have to transfer a 32bpp bitmap. Wich doesnt work with X8R8G8B8, because of this:

cuz.png
I use this code wich i'm working on for around two days since i've never worked with LockRect and stuff:

Device->GetRenderTarget(0, &Surface);
Device->BeginScene();
Device->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_ARGB(255, 255, 0 , 0), 0 , 0 );
Device->EndScene();
Device->Present(NULL, NULL, NULL, NULL);

IDirect3DSurface9 * pp = NULL;
Device->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_LEFT, &Surface);

D3DLOCKED_RECT Rect;
if(Surface->LockRect(&Rect, NULL, D3DLOCK_READONLY | D3DLOCK_DONOTWAIT) == D3D_OK){
lgLcdBitmapQVGAx32 bmp;
bmp.hdr.Format = LGLCD_BMP_FORMAT_QVGAx32;
memcpy(bmp.pixels, Rect.pBits, LGLCD_QVGA_BMP_WIDTH * LGLCD_QVGA_BMP_HEIGHT * LGLCD_QVGA_BMP_BPP);
lgLcdUpdateBitmap(LCD->Output->GetDeviceId(), &bmp.hdr, LGLCD_SYNC_UPDATE(LGLCD_PRIORITY_NORMAL));
} else {
printf("ERR");
}


I hope someone can help me here since i'm very new into this topic.

Best Regards
Tsuyo

Share this post


Link to post
Share on other sites
Advertisement
Thank you for your response,
using D3DFMT_A8R8G8B8, it works :)

greetings

Share this post


Link to post
Share on other sites
You must enumerate supported back buffer formats for a specific adapter format. Also it depends on fullscreen/windowed mode.

For example, I have an Intel(R) 946GZ on-board adapter on my computer at work. And it supports XRGB8 and ARGB8 for 32-bit fullscreen mode; but in windowed mode it supports ARGB8, XRGB8, R5G6B5, A2RGB10 and A1RGB5.

So, I reccomend you to take a look at DirectX Caps Viewer or enumerate the devices manually. You can make the better choice by these.

hth.
-R

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!