Advertisement

problems intializing d3d

Started by February 27, 2000 02:06 PM
7 comments, last by Brad8383 25 years ago
could anyone tell me whats wrong with this? It exits after a call to addviewport... Globals LPDIRECTDRAW4 lpdd; LPDIRECTDRAWSURFACE4 front,back; LPDIRECT3D3 d3d; LPDIRECT3DDEVICE3 device; LPDIRECT3DVIEWPORT3 Viewport; D3DVIEWPORT2 Viewdata; init function int Game_Init(void *parms = NULL, int num_parms = 0) { LPDIRECTDRAW dd; DirectDrawCreate(NULL,ⅆ,NULL); dd->QueryInterface(IID_IDirectDraw4,(LPVOID*)&lpdd); lpdd->SetCooperativeLevel(main_window_handle,DDSCL_FULLSCREEN / DDSCL_ALLOWREBOOT / DDSCL_EXCLUSIVE / DDSCL_FPUSETUP); lpdd->SetDisplayMode(640,480,16,0,0); DDSURFACEDESC2 ddsd; ZeroMemory(&ddsd,sizeof(ddsd)); ddsd.dwSize = sizeof(ddsd); ddsd.dwFlags = DDSD_CAPS / DDSD_BACKBUFFERCOUNT; ddsd.dwBackBufferCount = 1; ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE / DDSCAPS_FLIP / DDSCAPS_COMPLEX; lpdd->CreateSurface(&ddsd,&front,NULL); DDSCAPS2 ddscaps; ZeroMemory(&ddscaps, sizeof(ddscaps)); ddscaps.dwCaps = DDSCAPS_3DDEVICE / DDSCAPS_BACKBUFFER; front->GetAttachedSurface(&ddscaps,&back); lpdd->QueryInterface(IID_IDirect3D3,(LPVOID*)&d3d); if(FAILED(d3d->CreateDevice(IID_IDirect3DMMXDevice,back,&device,NULL))) d3d->CreateDevice(IID_IDirect3DRGBDevice,back,&device,NULL); //create viewport memset(&Viewdata,0,sizeof(Viewdata)); Viewdata.dwSize = sizeof(Viewdata); Viewdata.dwWidth = 640; Viewdata.dwHeight = 480; d3d->CreateViewport(&Viewport,NULL); //message box here pops up if(FAILED(device->AddViewport(Viewport))) MessageBox(main_window_handle,"kasjfd","sdlk",MB_OK); //one here doesnt and even the one in the if statement doesnt show up Viewport->SetViewport2(&Viewdata); device->SetCurrentViewport(Viewport); return(1); }
The same thing happened to me, I assume you were following along the tutorial for 3d tiles in 2d games or something. I still haven''t figured it out, but I''m going through brackets source code, trying to see what I did wrong. Good luck.
Advertisement
Yeah. And the source compiles so it must be something im doing.
Do the binaries I shipped with it run okay? If not, then it might be something with your graphics card and D3D (there are too many little issues to work around in D3D). If the binaries worked, then I''ll have a look at your code as soon as my brain finishes rebooting.
I have an idea for you (it works for me sometimes at least ). Remove the file from your project, and then readd the same file. Let me know if it works then.
Problem solved. Had to make the front surface a 3ddevice too. i just had the back since thats the only one you draw to it had me tricked.
Advertisement
New problem. my triangles dont show up. heres the main loop

if (KEYDOWN(VK_ESCAPE))
PostQuitMessage(0);
D3DTLVERTEX vertex[4];
device->BeginScene();
device->SetLightState(D3DLIGHTSTATE_MATERIAL,NULL);
device->SetRenderState(D3DRENDERSTATE_FILLMODE,D3DFILL_WIREFRAME);
vertex[0].color = D3DRGB(1.0f,1.0f,1.0f);
vertex[1].color = D3DRGB(1.0f,1.0f,1.0f);
vertex[2].color = D3DRGB(1.0f,1.0f,1.0f);
vertex[3].color = D3DRGB(1.0f,1.0f,1.0f);
vertex[0].sx = 50;
vertex[0].sy = 50;
vertex[1].sx = 60;
vertex[1].sy = 40;
vertex[2].sx = 60;
vertex[2].sy = 60;
vertex[3].sx = 70;
vertex[3].sy = 50;
device->DrawPrimitive(D3DPT_TRIANGLESTRIP,D3DFVF_TLVERTEX,vertex,4,D3DDP_DONOTLIGHT / D3DDP_DONOTCLIP);
device->EndScene();
front->Flip(NULL,DDFLIP_WAIT);
can anyone help? i have to get this done asap.
Fixed it. I did end up having to set up the 3d clipper info for it to work.

This topic is closed to new replies.

Advertisement