tutorial 6.5

Started by
5 comments, last by Rapsey 22 years, 9 months ago
i dont know about all of you but i dont see any improvement in the way the code was organized into classes. Having so many classes doesnt make the code more readable, quite the oposite if you ask me. Its not that i dont like OO but this is a little to extreme.
  
void CDirect3D::Clear(DWORD dwColor)
{
	pDevice->Clear( 0, NULL, D3DCLEAR_TARGET, dwColor, 1.0f, 0 );
}

void CDirect3D::Present()
{
	pDevice->Present(NULL, NULL, NULL, NULL);
}

void CDirect3D::BeginScene()
{
	pDevice->BeginScene();
}

void CDirect3D::EndScene()
{
	pDevice->EndScene();
}
  
DrawScene is a time critical function and having a method only to have it call another method and nothing else isnt a good idea really.
Advertisement
In that case, I wouldn''t have a method just to call another method. You''re right, that is pretty pointless. Just call pDevice->BeginScene() in that case. That''s what I''d do. But I''m not a very object-oriented programmer, so don''t blindly trust me.
It''s supposed to help because it helps you by keeping your code cleaner so you don''t have to type alot.

Eric Wright o0Programmer0o
AcidRain Productions
http://www.acidrainproductions.com
Eric Wright o0Programmer0o
yes its cleaner, but its allso in 11 files. Which makes it slower to compile, slower to run(because of OO not files) and it makes it 1000x more difficult to read, and since the people reading these tutorials are mostly newbies it allso makes it harder for them to understand the code.
I may write a tut for nexe on helping the code look clearer to newbies, but it should pretty much be self explanatory.

Eric Wright o0Programmer0o
AcidRain Productions
http://www.acidrainproductions.com
Eric Wright o0Programmer0o
The point of wrapping it was to hide the stuff that already been taught in previous tutorials so you can focus on what''s being taught in the current one. It also teaches good coding practice (It''d be done in a similar manner even if I were doing procedural instead of OO), and other stuff may be added later to those functions, they''re only barebone for now.
G''day!

In my tutorials I have a similar D3D8 wrapper. All of the initialization takes a few lines and we''re running. My early tutorials step through the initialization, so I don''t see any need to do that every tutorial. I''m happy to wrap a lot of that stuff away so we can focus on the NEW stuff.

A good reason for the thin wrapper on BeginScene (for example) is so that you can do:
my_CDirect3D->BeginScene() rather than
my_CDirect3D->m_d3d_device->BegineScene()
which is just ugly.

The performance impact is minimal in cases like this. If you''re REALLY concerned about the overhead you can make them inline, then there isn''t any.

If people are reading the more complex tutorials and getting caught by code like this, then they probably aren''t ready for the complex tutorials yet.

As for compiling slower, there is little difference in the compile time, and since you won''t need to re-compile the engine source after the first time it can actually be faster for subsequent compilations.

Another important point is that the tutorials (both Sean''s and mine) are unoptimized code. It''s designed to be clean and easily modified. Optimizing should be done at the end of the project when you can actually track where your speed hits are. If the biggest performance drain on your code is a thin wrapper like this, your code is better than mine.


Stay Casual,

Ken
Drunken Hyena
Stay Casual,KenDrunken Hyena

This topic is closed to new replies.

Advertisement