Jump to content

Canardia

Developers
  • Posts

    4,127
  • Joined

  • Last visited

Everything posted by Canardia

  1. Well do it the other way around: put your game in thread 1, and leave the main thread for loading models then. It's the same effect, except then there is no waiting at all. I'm gonna make a new demo next, which uses that idea
  2. No, it doesn't pause your game, because it happens only before the game starts, and you can then even do some intro/menu/video in another thread, while the main thread is busy.
  3. Here is a demo which demonstrates multithreading in LE2. It uses 3 threads plus the main thread: 1) Thread 1 loads models from memory 2) Thread 2 turns them 3) Thread 3 waits until all models are loaded and then gravitates them One model must be loaded once in the main thread, but that is not a big issue as you can reuse them anyway and loading 1 models doesn't take very long, so it's only a small delay when the game starts. After that everything is multithreaded and there is no waiting time while loading new models and levels. Here is the source code: #include "engine.h" #include "pthread.h" #include <vector> #include <string> #define NUMTHREADS 3 #define NUMMODELS 1000 #define LOCK pthread_mutex_lock(&count_mutex); #define UNLOCK pthread_mutex_unlock(&count_mutex); #define WriteText(y,s) SetColor(Vec4(0,0,0,1));DrawText(2,y+1,s.c_str());SetColor(Vec4(1));DrawText(1,y,s.c_str()); using namespace std; pthread_t callThd[NUMTHREADS]; pthread_mutex_t count_mutex; vector<TMesh> model; string s1="Thread 1 Idle",s2="Thread 2 Idle",s3="Thread 3 Idle"; void *LoadModels(void *arg) { LOCK s1="Thread 1 Loading Oildrums"; UNLOCK for(int i=0;i<NUMMODELS;i++) { LOCK BP e=LoadModel("oildrum.gmf"); MoveEntity(e,Vec3(-9+2*(i/10%10),2+1*(i/100),2*(i%10))); TurnEntity(e,Vec3(90,0,0)); SetBodyMass(e,1); EntityType(e,1); SetBodyElasticity(e,2); SetBodyGravityMode(e,0); model.push_back(e); UNLOCK Sleep(20); } LOCK s1="Thread 1 Done"; UNLOCK pthread_exit(NULL); } void *TurnModels(void *arg) { LOCK s2="Thread 2 Turning Oildrums"; UNLOCK bool done=false; while(!done) { LOCK int n=model.size(); UNLOCK for(int i=0;i<n;i++) { LOCK TurnEntity(model.at(i),Vec3(0.1*AppSpeed(),AppSpeed(),0.0*AppSpeed())); UNLOCK } Sleep(1); if(n>=NUMMODELS)done=true; } LOCK s2="Thread 2 Done"; UNLOCK pthread_exit(NULL); } void *GravitateModels(void *arg) { LOCK s3="Thread 3 Waiting for all Oildrums to arrive"; UNLOCK bool done=false; while(!done) { LOCK int n=model.size(); UNLOCK if(n==NUMMODELS) { LOCK s3="Thread 3 Waiting 5 seconds"; UNLOCK Sleep(5000); LOCK s3="Thread 3 Gravitating Oildrums"; UNLOCK for(int i=0;i<n;i++) { LOCK SetBodyGravityMode(model.at(i),1); UNLOCK } done=true; } Sleep(1); } LOCK s3="Thread 3 Done"; UNLOCK pthread_exit(NULL); } int main(int argc, char* argv[]) { Initialize(); Graphics(800,600); pthread_attr_t attr; pthread_mutex_init(&count_mutex,NULL); pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr,PTHREAD_CREATE_JOINABLE); TFramework fw=CreateFramework(); HideEntity(LoadModel("oildrum.gmf")); // initialize FBO for other threads TCamera cam=GetLayerCamera(GetFrameworkLayer(0)); MoveEntity(cam,Vec3(0,5,-10)); TurnEntity(CreateDirectionalLight(),Vec3(45,45,0)); EntityType(CreateTerrain(128),1); SetFarDOF(1); SetDistanceFog(1); SetBackgroundColor(Vec4(0.8,0.8,1,1)); Collisions(); // create other threads pthread_create(&callThd[0],&attr,LoadModels,(void*)1); pthread_create(&callThd[1],&attr,TurnModels,(void*)2); pthread_create(&callThd[2],&attr,GravitateModels,(void*)3); while( !AppTerminate() && !KeyHit() ) { LOCK UpdateFramework(); RenderFramework(); SetBlend(BLEND_ALPHA); WriteText(20,s1); WriteText(40,s2); WriteText(60,s3); SetBlend(BLEND_NONE); UNLOCK Flip(0); Sleep(1); } // kill other threads pthread_detach(callThd[0]); pthread_detach(callThd[1]); pthread_detach(callThd[2]); // wait for other threads to finish pthread_join(callThd[0],NULL); pthread_join(callThd[1],NULL); pthread_join(callThd[2],NULL); // destroy mutex engine pthread_attr_destroy(&attr); pthread_mutex_destroy(&count_mutex); pthread_exit(NULL); return Terminate(); } And here is the complete Code::Blocks project with executable demo also:
  4. I changed only the first post to make the feature request described properly.
  5. Yeah, but the original feature request was about having materials without textures to be supported in LE, I just didn't know how that technology was called It has its own benefits, as you can zoom is as much you want and never see pixelation, and you can scale the model as big you want and also have no pixelation. And you use no texture memory on the GPU. The only downside is that you need a bit more triangles for the model, but that doesn't matter as you can make lods with UU3D very easily. And since many model formats and 3D editors support materials without textures, I think GMF and LE should support it too. There are many free models done this way, so it would be much easier to import them.
  6. Yeah, you can have diffuse+specular+transparency and lots of other things without textures, and many formats, like lwo support that and UU3D can load and display it correctly too: Now I found the option in UU3D to convert all materials to vertex colors, and it doesn't look too bad in LE. I still need to move the windows to the foreground world so they are transparent: Ah, cool, when I add a simple 1x1 specular texture, it looks even better in LE: And with posteffects, like SSAO and FSAA it looks damn good for a model without any textures
  7. The materials in UU3D are defining the vertex color, and its specular and opacity. So I can't delete the materials in UU3D, because then it gets completely white again.
  8. The main problem seems to be that the other threads don't have an active OpenGL canvas or driver, so for example LoadTexture fails because the maximum texture size is 0 (instead of 8192 like on the main thread). However, when I preload and free the models in the main thread first, then it works also on the other threads: FreeEntity(LoadMesh("oildrum.gmf")); FreeEntity(LoadMesh("mushroom.gmf"));
  9. I have some models which don't have textures, but only materials with diffuse+specular+transparency+ambient+emissive+shininess colors. They look fine in UU3D, but in Editor they are just plain white.
  10. What else than scoring should I add to the Guess A Number game?
  11. Actually, how do you know that normals and speculars are not working? You don't seem to have anykind of camera movement in the example. I think they work just fine, but you are looking at the oildrum from an angle which doesn't show them much.
  12. You should post a minimal demo so that others can see if the bug occurs also to them, or is it only some config/driver problem of your PC.
  13. I think textures had to be square too, and a potence of 2.
  14. Textures must be in png, bmp, or jpg I think. Microsoft .dds didn't exist at that time yet. But png is anyway the best texture format, since it supports lossless compression and transparency, no other format supports those. You should have a look at LE 1.0.3 also, it has realtime brushes LE 1.1 was a complete rewrite and some cool features were lost, and some other cool features were added. Then there was also a major change between LE 1.13 and 1.15, and I had to use both engines for different levels in the game I was writing back then. It looks like LE 3.0 will have again those cool brush features of LE 1.0, and also the cool forward rendering on LE 1.13.
  15. LE 1.0 and 1.1 loads .mesh, .b3d, and .3dw models. I can't remember if it loads other formats too.
  16. FPU is used automatically in C++ when you enable the fast math compiler option.
  17. Reusable topics are like reusable code. They should be always preferred instead of making duplicate new posts. I don't know why many people seem to think the other way around, it just makes no sense to me. Do they code like that too?
  18. I was going to say the same. But now you made me thinking of a new experiment: What if you would first make a text based guess the number game, and then stepwise expand it, like first graphical based text, then using 2D graphics, then 3D graphics, then add maybe some more guessing questions, record number guessing history in a database, add multiplayer modes: turn based, split screen, .... This would make an interesting tutorial, because the game would be ready already in the first step. Then the question is which programming language to use, and I would think C++, since that's the most popular at the moment. But keeping it simple C++, which modern C++ allows, so we don't need to get into all the old C++ version's difficulties. Long talk, short sense (like they say in Germany), here we go: http://www.leadwerks.com/werkspace/page/Documentation/LE2/tutorials/_/programming/cpp/guess-a-number-r78
  19. LEO has had a few updates, mostly due to missing commands. So it has now all commands, which the C API has too. All LEO changes are documented in the changes.txt file in the LEO folder.
  20. The performance of Unity is still horrible, and it doesn't support shadows on Android and iPhone, which ShiVa3D does.
  21. It's question of definiton what "engine" means. With the engine comes a bunch of tools which allows to convert from about 10 different formats (x, b3d, 3ds, dae, 3dw, fbx, md3, ...) to gmf format. Then you can buy Ultimate Unwrap 3D and convert from hundreds of formats to gmf and to hundreds of other formats. The engine runtime reads only gmf format, because it's an optimized game runtime format, while most other formats are transport formats, to make it easier to load and save them from 3D modelling programs, where loading and saving speed is not as important as the ability to fix files if they are wrong.
  22. You should add a Google+ share button too (or only). I have already more friends there than in Facebook, and more followers than in Twitter.
  23. You could make several face animations, and then mix them. Or you could move the face bones with some sine curves programmatically.
  24. LE2 supports SLI, but your SLI drivers must support it. 3way SLI however is not as fast as a single 3 times faster GPU, because there are some huge delays in the memory exchange. I think a nVidia GTX 590 should be fast enough to run 5760x1080 at 60 FPS. You might however need to render 3 times instead, if the GPU does not natively support such resolution.
  25. I would use MinGW C++ with Code::Blocks.
×
×
  • Create New...