#### Archived

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

# tutorial 6.5

This topic is 6234 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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.

##### Share on other sites
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.

##### Share on other sites
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

##### Share on other sites
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.

##### Share on other sites
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

##### Share on other sites
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.

##### Share on other sites
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

1. 1
2. 2
3. 3
Rutin
22
4. 4
JoeJ
16
5. 5

• 14
• 29
• 13
• 11
• 11
• ### Forum Statistics

• Total Topics
631774
• Total Posts
3002291
×