• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

Archived

This topic is now archived and is closed to further replies.

Guest Anonymous Poster

Why doesnt this work?

17 posts in this topic


Esap1,

Let me preface this by saying that I am not a Direct3D guru, but have some experience with COM.

The only thing that really jumped out at me was the fact that you were Querying an uninitialized interface pointer for itself..:


lpd3d->QueryInterface(IID_IDirect3D2, ...)

that line should read:

lpdd->QueryInterface(IID_IDirect3D2, (void**)&lpd3d)

Since you need to query the IDirectDraw interface for the IDirect3D interface.

As a side note, you might want to consider taking the time to create your own exception handling class, something that takes an HRESULT and maps it to a string definition of what went wrong.

HTH,

-mordell

0

Share this post


Link to post
Share on other sites
1 more thing, when I set hardware to 1 as it is there, it cant get past AddAttachedSurface, but if I set it to 0, it cant get past the CreateDevice, I just dont know what wrong:
0

Share this post


Link to post
Share on other sites
Since you have a primary surface and a back surface, I assume you want to flip. But eeeeh, you didn't make code to flip your surface. Change that...

------------------
Dance with me......

0

Share this post


Link to post
Share on other sites
I have other code in a function to flip the surface but my program cant even get past that function
0

Share this post


Link to post
Share on other sites
PLEASE, I STILL NEED HELP, Please , if yo can please try to help me, thanx alot
0

Share this post


Link to post
Share on other sites
Ok

1) Get lost of the DDSCL_MODEX
2) Use (DirectDraw->)QueryInterface before you set the display mode.
3) use "FrontBuffer->GetAttachedSurface(&caps, &BackBuffer);" instead of AddAttachedSurface();

I Use addattchedSurface to attach the z buffer.

I would go for the following items in the following order:
1) DirectDrawCreate()
2) SetCooperativeLevel()
3) QueryInterface()
4) SetDisplayMode()
5) CreateSurface()
6) GetAttachedSurface()
( 7) CreateSurface + AddAttachedSurface for zbuffer)
8) CreateDevice()
9) CreateViewPort()
10) AddViewPort()
11) SetCurrentViewPort()
12) SetTransform()

etc etc..........

------------------
Dance with me......

0

Share this post


Link to post
Share on other sites
Thanks, but one more question, what CAPS should I use for the GetAttachedSurface for the back buffer,
thanks alot
0

Share this post


Link to post
Share on other sites
I was wondering if yo have to CreateSurface a Backbuffer before you use AddAttachedSurface,
Also Im doing everything right
but AddAttachedSurface returns an error.
thank you!
0

Share this post


Link to post
Share on other sites
Look at the following bit.

DDSURFACEDESC ddsd;

ZeroMemory(&ddsd, sizeof(ddsd));

ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP | DDSCAPS_COMPLEX | DDSCAPS_3DDEVICE | DDSCAPS_VIDEOMEMORY;

ddsd.dwBackBufferCount = 1;

err = dd->CreateSurface(&ddsd, &FrontBuffer, NULL);

if (err != DD_OK)
{
ddsd.ddsCaps.dwCaps &= ~DDSCAPS_VIDEOMEMORY;
err = dd->CreateSurface(&ddsd, &FrontBuffer, NULL);
}

if (err != DD_OK)
{
return FALSE;
}

DDSCAPS caps;

caps.dwCaps = DDSCAPS_BACKBUFFER;
err = FrontBuffer->GetAttachedSurface(&caps, &BackBuffer);

if (err != DD_OK)
{
return FALSE;
}

memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(DDSURFACEDESC);
ddsd.dwFlags = DDSD_WIDTH | DDSD_HEIGHT |DDSD_CAPS | DDSD_ZBUFFERBITDEPTH;
ddsd.dwHeight = height;
ddsd.dwWidth = width;
ddsd.dwZBufferBitDepth = bpp;
ddsd.ddsCaps.dwCaps = DDSCAPS_ZBUFFER | DDSCAPS_SYSTEMMEMORY;

err = dd->CreateSurface(&ddsd, &ZBuffer, 0);
if(err != DD_OK)
{
return FALSE;
}

err = BackBuffer->AddAttachedSurface(ZBuffer);

if(err != DD_OK)
{
return FALSE;
}

------------------
Dance with me......

0

Share this post


Link to post
Share on other sites
I tried that exact code and it died on that first CreateSuface(FrontBuffer
it jus kills it, i had to EndTask to get out of it, thanks for helpin the new guy.
0

Share this post


Link to post
Share on other sites
Do you get an error returned from CreateSurface, and if so which error?

DirectDraw's error codes can be helpful.

0

Share this post


Link to post
Share on other sites
The only way I no it was CreateSurface that killed it was because 1 time it didnt Totaly Freeze my comp. I some how got it out and it did return a long error, though I didnt write it down. Every time I run the program it freezes and I can only turn off my comp, tried everything.
0

Share this post


Link to post
Share on other sites
If you want to debug your program you shouldn't use the FULLSCREEN flag. Just test the program in windowed mode and switch then to fullscreen. But be aware of the fact that you cant flip pages in windowed modes.
0

Share this post


Link to post
Share on other sites
heres the code, im a begginner so dont laugh if its obvios

LPDIRECT3D2 lpd3d;
LPDIRECT3DDEVICE2 lpd3ddevice;
LPDIRECTDRAW lpdd = NULL;
LPDIRECTDRAWSURFACE lpddsprimary = NULL;
LPDIRECTDRAWSURFACE lpddsbackbuffer = NULL;
LPDIRECTDRAWPALETTE lpddpal = NULL;
PALETTEENTRY color_palette[256];
DDSURFACEDESC ddsd;
DDSCAPS ddscaps;
HRESULT ddrval;
HWND main_window_handle=NULL;

int hardware;

int DD_Init(HWND hwnd)
{
// this function is responsible for initializing direct draw, it creates a
// primary surface

int index; // looping index
// now that the windows portion is complete, start up direct draw
if (DirectDrawCreate(NULL,&lpdd,NULL)!=DD_OK)
{
// shutdown any other dd objects and kill window
DD_Shutdown();
return(0);
} // end if

// now set the coop level to exclusive and set for full screen and mode x
if (lpdd->SetCooperativeLevel(hwnd, DDSCL_ALLOWREBOOT | DDSCL_EXCLUSIVE |
DDSCL_FULLSCREEN | DDSCL_ALLOWMODEX)!=DD_OK)
{
// shutdown any other dd objects and kill window
DD_Shutdown();
return(0);
} // end if

// now set the display mode
if (lpdd->SetDisplayMode(SCREEN_WIDTH,SCREEN_HEIGHT,SCREEN_BPP)!=DD_OK)
{
// shutdown any other dd objects and kill window
DD_Shutdown();
return(0);
} // end if

// Create the primary surface
ZeroMemory(&ddsd, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;

if (lpdd->CreateSurface(&ddsd,&lpddsprimary,NULL)!=DD_OK)
{
// shutdown any other dd objects and kill window
DD_Shutdown();
return(0);
} // end if

ZeroMemory(&ddsd, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
ddsd.dwWidth = SCREEN_WIDTH;
ddsd.dwHeight = SCREEN_HEIGHT;
hardware=1; //Forse Hardware Acceleration
if (hardware)
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE | DDSCAPS_VIDEOMEMORY;

else
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE | DDSCAPS_SYSTEMMEMORY;

if (lpdd->CreateSurface(&ddsd, &lpddsbackbuffer,NULL) != DD_OK) return(0);
if (lpddsprimary->AddAttachedSurface(lpddsbackbuffer) != DD_OK) return(0);


//Query the hardware

if (lpd3d->QueryInterface(IID_IDirect3D2, (LPVOID *)&lpd3d) != S_OK)
return (0);


// Create the D3D device

if (lpd3d->CreateDevice(IID_IDirect3DHALDevice, lpddsbackbuffer, &lpd3ddevice) != D3D_OK)
return FALSE;

// return success if we got this far
return(1);

} // end DD_Init

---------------------------------
Thank yo so much
also, sorry for the length
I dont really know whats wrong but it cant get past the Query Interface, also I am forcing hardware acceleration (I THINK) jus to make it easier,
Thanks again,

0

Share this post


Link to post
Share on other sites
when I turn off fullscreen mode and dont change the video mode the program seems to work as it does not return an error. Though onces I use full screen and hardware acceleration I found out that when I use CreateSurface(Front_Buffer), It returns DDER_INVALIDCAPS. I dont no if Im using the right caps. THANX AGAIN!
0

Share this post


Link to post
Share on other sites