Jump to content
  • Advertisement

Archived

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

J2xC

Turning the start of my engine from C to C++

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

Ok, at the moment I''ve only written code for wrappers for DX, 2d polygon stuff, and bitmap manipulation, for a 32 bit engine with variable resolution... At the moment, everything''s written in pretty much straight C with a couple of exceptions. But I''m considering making the whole thing C++. Firstly, I''d like to put my DX object, DX primary surface, and back buffer, along with commands functions for manipulating the surfaces all into one Class. Is this a good idea? Is there really any major difference between using malloc and free or new and delete? And for file manipulation is the C++ method any better than the C method? As far as I can tell, apart from the Class thing, switching to C++ wouldn''t actually change much. Also, seeing as I''m using 32 bit, and I''m going to be using 800*600 resolution, that''s gonna make primary + back surface nearly 4 MB, if I add to that offscreen surfaces for keeping tiles, and graphics for animations in, that makes about 6MB, and if I make it tripple bufferred 8MB. So I''m wondering, should I make it tripple bufferred, or double bufferred, as with double bufferring, even with a 4MB video card, primary, and double buffer could be kept in vid memory, with tripple, that wouldn''t be possible... So, how many people would you say actually have 8 MB video cards, and how much slower is system memory than video memory? J2xC (J. Connolly) "Then study this: Borg provokes Klingon, Klingon breaks Borg's nose" Belanna Torres, Star Trek Voyager 5.11 "Someone to watch over me"

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
> ... So, how many people would you say actually
> have 8 MB video cards?

Not many I think. 32M is more common. So I wouldn''t worry about 6MB not fitting in the video memory.

Share this post


Link to post
Share on other sites
You can assume than any 3d card out is 16Mb at least.

For 2d assume 8Mb cards.

(I know that 3d cards memory can be used the way you want, it''s just that 2d games ''must'' be more widly available)


-* So many things to do, so few time to spend *-

Share this post


Link to post
Share on other sites
If you aim for the mainstream...well I don''t think you should assume a 8MB video card. 4MB would be more safe to assume. Say the Riva 128 card series and older ATI cards. It''s likely anyone with a computer with that''s two or three years old or so does have a video card like this, I know I do.
Another option would to be let the user choose resolution. Sounds like a good idea to me, shouldn''t be to much fuzz either.

"Paranoia is the belief in a hidden order behind the visible." - Anonymous

Share this post


Link to post
Share on other sites
I think triple buffering is only useful at high frame rates on high performance systems. It not nearly as important as double buffering. Triple buffering solves a bottleneck issue where the renderer has the primary buffer locked & the next frame is ready to be swapped into place...

And it''s my opinion that there''s no technical advantage to C or C++; it''s only how you organize your code. If you want to use (or learn?) an OOP design then use C++ - its better suited to it. There really is nothing that can be done in either language that is absolutely impossible in the other.

I use C++ because I like its constructors & destructors - IMNSHO its the only language that implements them properly. Templates are VvVvVery nice too. And so is operator overloading, like new & delete... you just delete it, it knows how big it is...

Share this post


Link to post
Share on other sites
Hmm... didn't mean to make such a big issue out of the tripple vs double-buffering thing. It was C or C++ that I was interested in...

Do people think it'll:
a: be easier for me to write the engine in C++? I already know C++, and the only reason I originally wrote the engine beginnings on C, was I couldn't think of a good system to keep things in classes...

I was thinking of a class something like this:

    
class DD_WRAPPER_CLASS
{
public:
DD_WRAPPER_CLASS(); // Initializes DD objects, etc.
~DD_WRAPPER_CLASS();
// Store ddsd.lPitch into this variable

int pitch_back; // When Lock_Back() called
UINT mem_ptr_back; // You get the idea

int pitch_primary; // etc.

UINT mem_ptr_primary;

private:
LPDIRECTDRAW4 lpdd;
LPDIRECTDRAWSURFACE4 lpdds_primary;
LPDIRECTDRAWSURFACE4 lpdds_back;
int Lock_Back();
int Lock_Primary();
int Flip_Surfaces();
};


You get the general idea right?

b: Would it be easier to manage? It would wouldn't it?

J2xC (J. Connolly)

"Then study this: Borg provokes Klingon, Klingon breaks Borg's nose" Belanna Torres, Star Trek Voyager 5.11 "Someone to watch over me"



Edited by - J2xC on June 27, 2000 7:51:31 PM

Share this post


Link to post
Share on other sites
Of course it would be easier to manage if you know C++. If you use C++ and know it better than you should use it. If you know C, like it better, than use C, dont matter really.

-----------------------------

A wise man once said "A person with half a clue is more dangerous than a person with or without one."

Share this post


Link to post
Share on other sites
as far as the video card goes, 4mb would be the definite lowest possible i would write for, but because of all these systems w/ onboard cards ( i haven''t seen a single one with < 8mb ) and all the free comp deals, if anyone who''s not a gamer wants a computer, they''re gonna get at least 8mb of video. so i believe 8mb would be safe to assume, and if not, DX will stick it in system memory... big deal...
farmersckn

Sometimes even chickens need to eat... Don't bang your head against a wall just to enjoy the good feeling when you stop.

Share this post


Link to post
Share on other sites
I''m not too far along yet, but this is how I laid out my wrapper... if it helps

    
class CFrame
{
public:

CFrame(HINSTANCE newInst, int newShowCmd);

~CFrame();
///////////////////

//Rendering Methods

HRESULT Initialize3DEnvironment();
void AttachWorld(CWorld* LookAtMe);
HRESULT RestoreSurfaces();

////////////////

//Window Methods

static LRESULT CALLBACK WinProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
void Show();
int Run();
operator HWND();
protected:
//////////////////

//Rendering Routines

HRESULT InitializeDirectDraw();

//////////////////

//Windows Routines

HRESULT Initialized()
{
if((DirectDrawInit&&Direct3DInit)!=0)
return(S_OK);
else
return(-1);
}
int MsgPump();
private:
/////////////

//State Flags

BOOLEAN DirectDrawInit;
BOOLEAN Direct3DInit;

//////////////////////

//Rendering Properties

IDirectDraw7* lpDD7; //LPDIRECTDRAW7 lpDD7 works too...

IDirectDrawSurface7* lpSecondarySurface;
IDirectDrawSurface7* lpPrimarySurface;
IDirect3D7* lpD3D7;
IDirect3DDevice7* lpD3D7Device;
RECT rcScreenRect;
RECT rcViewportRect;

///////////////////

//Window Properties

static CWorld* lpWorld;
HWND hWnd;
WNDCLASSEX wndMain;
HINSTANCE hInstance;
int nShowCmd;
BOOLEAN Registered;
BOOLEAN Visible;
BOOLEAN Created;
DWORD errorcode;
ATOM RegAtom;
};

Share this post


Link to post
Share on other sites
Kewl... except I''m writing 2d engine...

I''ve decided I''m just going to use the "best of both languages"... e.g. whatever is most simple/convenient/quick for me


J2xC (J. Connolly)

"Then study this: Borg provokes Klingon, Klingon breaks Borg's nose" Belanna Torres, Star Trek Voyager 5.11 "Someone to watch over me"

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.

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

Sign me up!