-
Posts
243 -
Joined
-
Last visited
Content Type
Blogs
Forums
Store
Gallery
Videos
Blog Comments posted by Furbolg
-
-
"Good programming" doesnt mean to optimize every little if, switch etc. When you use inheritance (which josh does) and maybe use virtual functions (which josh probably does) then this is going to waste much more cycles then you can safe by optimize hundreds of little ifs.
"Good programming" means in my understanding maintainable understandle code (short but precise comments, good parameter names etc.)
No it will not exponentially sum up because you do other stuff as well. As i said if you render a model it has much more cpu cycles wasted than your small optimizations can safe.
- 2
-
The problem with putting functions which are not connected to the context, except that they use the current context, is that when a user makes multiple contexts, then for example context3->DrawImage() will still draw to context1, if it's the current context.
I believe Josh can handle this.
Of course you could fix this by doing a context3->Activate() if it's not the current context, but that will make things slower, because a if() check is slower than a integer assignment.
Sure an if (asm cmp) will slow down nearly everything because rendering a model / light or playing a sound has so few cpu cycles that every if counts... serious Lumooja, do you listen to yourself ?
@ xtrempb:
I think he means something like this
// "slow" for(int i = 0; i < vector.size(); ++i) { } // "fast" int vectorsize = vector.size(); for(int i = 0; i < vectorsize; ++i) { }
-
Thats beautiful (c++ eyes) I love it
-
@ Lumooja: Sure ...
Premature optimization is the root of all evil and the algorithm is more important than this little tricks.
- 3
-
@ ZioRed:
Possible but wouldn't it be better to use the stack instead of the heap for this approach ?
@CGMan:
No its not (only) a buffer, its a "collection" of states (and some more).
Lets say you want to create 2 context objects (editor with 2+ windows), how would you do that ? I mean how can you tell which Draw::SetColor belongs to which context ?
@All / Josh:
As i said dont take this as flaming, i just want to share my opinion/experience i made with c++.
-
Nice progress but... first sorry to be such a criticism guy but as a c++ programmer i have some issues:
1. inconsistent context
Draw::SetColor(0,0,0); context->Clear(); //Display the device information on the screen Draw::SetBlendMode(Blend::Alpha); Draw::SetColor(1,1,1); Draw::Text("Orientation: "+String(Device::GetOrientation()),2,2); Draw::Text("Acceleration: "+Device::GetAcceleration().ToString(),2,22); Draw::SetBlendMode(Blend::Solid);
Why you switch from context to a static class and backwards ? (You should put this Draw:: stuff into the context imho)
2. Why you have to release your shape at this
//Create a shape shape = Shape::PolyMesh(model->GetSurface(0)); model->SetShape(shape); model->SetPosition(0,0,0); shape->Release();
In my opinion you shouldn't release the shape (safe it as reference) or release it in the ->SetShape Method.
This is just my opinion and it is not ment to be negative.
-
So simple, yet, I have never come accross it before.
If you think about its very logical. You called each for iteration a function compared to call it once and save the result temporarly.
Another good optimization is for two dimensional array, take care of your traversing order e,g.
// creation unsigned char** myarray = new unsigned char*[1024]; for (int i = 0; i < 1024; ++i) { myarray[i] = new unsigned char; } // update for(int y = 0; y < 1024; ++y) { for(int x = 0; x < 1024; ++x) { myarray[y][x] = 0; // swapping x and y results in decrease/increase of nearly 50% on my system .... its because cache misses and miss prediction of cpu. } }
- 1
-
Hi Aggror,
very honest posting. Thanks for writing it, very interesting to see what are the good and the bad side of an project with this many people.
I'll be excited to see your next project
-
Depend on the style of the dungeon, but i would say 3.
-
Good to hear that but its also bad.
I have though you are releasing the Leadwerks3D Homepage + option to preorder the Upgrade
One Little Thing
in Development Blog
A blog by Josh in General
Posted
Hi Josh, really nice to hear this.
One question: why the addhook function has a reference for the first parameter ? (if you use native datatypes (int, float ,char etc) it dont make sense to use reference/pointer because the variable/parameter which stores the adress also consumes memory. So you should use call by value in this case (int hookid))