Jump to content
  • Advertisement

Archived

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

Moe

in need of a little help (and inspiration)

This topic is 6929 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

I have started to learn Direct Draw. I have decided that it would be easier for me to write my own rappers around the windows programming instead of using a console. I have divided my program into 4 parts: 1. windows programming - in the main file 2. game and DD initialization - in a seperate .cpp file 3. main game loop - in a seperate .cpp file //not yet implemented 4. cleanup and release of resources - in a seperate .cpp file I am having trouble initializing direct draw. i am not sure if there is a problem with the header files (which is quite possible. i included the same file more than once) or if it is a problem in my code. I think that it is this line in peticular: lpdd->SetCooperativeLevel(hwnd, DDSCL_ALLOWREBOOT / DDSCL_FULLSCREEN / DDSCL_EXCLUSIVE); I feel as if i have seen the light at the end of the tunnel but i smacked into a big sheet of glass while going towards it. Can anyone give me some pointers (or inspiration, if thats what it takes)? PS - I will post all the source code and errors if you need to see it - Moe -

Share this post


Link to post
Share on other sites
Advertisement
Moe - Are those lines backslashes(/) or are they verticle bars?(/ - C++ OR) Dont #include the same header twice. If you need to have the file in multiple files, try the following:

1.) Create a small header file
2.) In the header, put the folowing:
#ifndef INCLUDED_HEADER__
#define INCLUDED_HEADER__
#include
#endif

3.) include the new header in each file you wish to have the header. The header will only be included once, and you will not get the reinitialization errors/

Share this post


Link to post
Share on other sites
Those where ORs. I guess something happened when i copied them to the forum. I will give that header file thing a try.

- Moe -

Share this post


Link to post
Share on other sites
Hey Moe,

I am also from Alberta!

I have taken a similar approach and can send you my skeleton code if you want. I put my windows stuff in one file, and a "mainapp" object in another file (where the DirectX stuff starts). Then from the windows file I just create an instance of a "mainapp" object (which thus calls the constructor, and does all initialization) on startup and and mainapp.doframe() in the message loop. When the program is done and the mainapp object goes out of scope, the destructor is automatically called and everything is cleaned up. Then whatever other details I need for the game I put in new files.

When starting a new project, I never have to touch the windows file, and just tweak the mainapp file to suit my needs.

Your SetCooperationLevel call looks good, but if you think it is the problem, check the return code from it.

aig

Share this post


Link to post
Share on other sites
Would you mind if I get that source code that you wrote?

I found another problem. In my cleanup file, I am getting 4 errors, all to do with undeclaired things. Here is the code:

//program shut down stuff
#include

int Game_Shutdown(void)
{
if (lpddsprimary)
lpddsprimary->Release();
//release the direct draw object itself
if (lpdd)
lpdd->Release();


}


the errors:
D:\PROGRAMMING\MSDEV98\MyProjects\window\winclose.cpp(6) : error C2065: ''lpddsprimary'' : undeclared identifier
D:\PROGRAMMING\MSDEV98\MyProjects\window\winclose.cpp(7) : error C2227: left of ''->Release'' must point to class/struct/union
D:\PROGRAMMING\MSDEV98\MyProjects\window\winclose.cpp(9) : error C2065: ''lpdd'' : undeclared identifier
D:\PROGRAMMING\MSDEV98\MyProjects\window\winclose.cpp(10) : error C2227: left of ''->Release'' must point to class/struct/union

It seems that it doesn''t recognize that i have already declared those things. Any suggestions?

- Moe -

Share this post


Link to post
Share on other sites

  • 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!