Jump to content

SpiderPig

Members
  • Posts

    2,334
  • Joined

  • Last visited

Community Answers

  1. SpiderPig's post in Memory Pool was marked as the answer   
    @Josh I decided to do what you told me too.  I'm now using GetMemoryUsage() and it's displaying what it should.
     
    On another memory related topic "world->renderstats.vram" is the VRAM available and not in use, correct?
  2. SpiderPig's post in Minimap Generation for Ultra was marked as the answer   
    Here's some basic code of what I did if it helps.  Widget->SetTexture() is not available yet as Josh said above but once it is it should work just like that.  My code is more complex and spread-out than what I've written here but the general idea is it should render a cube in the centre of the camera and display it on the widget.  You can move the camera any where in the world you want.
    auto texture_buffer = CreateTextureBuffer(128, 128); auto camera = CreateCamera(world); camera->SetRenderLayers(2); camera->SetFov(70.0f); camera->SetRenderTarget(texture_buffer); auto cube = CreateBox(world); cube->SetRenderLayers(2); cube->SetPosition(0.0f, 0.0f, 2.0f); auto widget = CreatePanel(0, 0, 128, 128, ui->root); widget->SetTexture(texture_buffer->GetColorAttachment());  
  3. SpiderPig's post in Thread Questions was marked as the answer   
    Thanks that certainly is the way to get the most out of the threads!  With this it completed in less than one second.  I had to make sure it was actually still processing the data is was that quick.  Pretty sure it's still doing the same workload.  I can now speed up my voxel terrain by a lot!
    #include "UltraEngine.h" #include "ComponentSystem.h" using namespace UltraEngine; float DoThis() { auto r = 0.0f; for (int i = 0; i < 1000; i++) { r += sqrt(Random(2.0f, 1024.0f)); } return r; } struct ThreadManager : public Object { int current_count = 0, total_count = 1250;//10,000 / 8 (I.e. 10,000 / MaxThreads()) float result = 0.0f; function<float()> my_func; }; shared_ptr<Object> RunThread(shared_ptr<Object> extra) { auto manager = extra->As<ThreadManager>(); while (manager->current_count < manager->total_count) { if (manager->my_func != nullptr) { manager->result = manager->my_func(); } manager->current_count++; } return nullptr; } int main(int argc, const char* argv[]) { auto displays = GetDisplays(); auto window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR); auto world = CreateWorld(); auto framebuffer = CreateFramebuffer(window); auto camera = CreateCamera(world); camera->SetClearColor(0.125); camera->SetFov(70); camera->SetPosition(0, 0, -3); auto light = CreateDirectionalLight(world); light->SetRotation(35, 45, 0); light->SetRange(-10, 10); auto box = CreateBox(world); box->SetColor(0, 0, 1); auto actor = CreateActor(box); auto component = actor->AddComponent<Mover>(); component->rotation.y = 45; struct ThreadStruct { shared_ptr<Thread> thread; shared_ptr<ThreadManager> manager; }; auto available_threads = MaxThreads(); vector<shared_ptr<ThreadStruct>> threads; threads.reserve(available_threads); for (int id = 0; id < available_threads; id++) { auto s = make_shared<ThreadStruct>(); s->manager = make_shared<ThreadManager>(); s->manager->my_func = DoThis; s->thread = CreateThread(RunThread, s->manager); threads.push_back(s); } int thread_index = 0; while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { for (int id = 0; id < threads.size(); id++) { if (threads[id]->thread->GetState() == THREAD_FINISHED) { Print("Done Thread #" + String(thread_index) + " - " + String(threads[id]->manager->result)); thread_index++; threads.erase(threads.begin() + id); id--; } } world->Update(); world->Render(framebuffer); } return 0; }  
  4. SpiderPig's post in Disabled normal calculation options? was marked as the answer   
    If you change the method they will be available.  Those options don't apply to Average Normal.
  5. SpiderPig's post in Physics not working was marked as the answer   
    Time::Update(); ah well - you have to add this. ?
  6. SpiderPig's post in Lobby::Count() was marked as the answer   
    I should read more often.
  7. SpiderPig's post in Shadows Disappearing was marked as the answer   
    I found the problem to be the world size.  Making it bigger allowed the shadows to show up.  @Josh  I'm curious as to what exactly setting the world size does, because so far my models have been showing up fine, it's just the shadows that was affected.
  8. SpiderPig's post in Script:Update()/Draw()/DrawEach() Explaination was marked as the answer   
    They're not quite the same, I think the major difference is Draw() isn't called when the object is invisible  (off screen).
    Pretty sure the scene is rendered each frame.   Per loop there is one call to UpdateWorld () and then a call to RenderWorld ().
  9. SpiderPig's post in Allocating memory was marked as the answer   
    Right-o.  I found the issue.  In Visual Studio an application by default is only allowed to access 2GB of memory.  I guess this to insure that the released application wont use all of the 4GB of ram on a 32bit system so that the operating system will still run?
    Anyway, in VS2017 you can enable large Addresses in Property Pages->Linker->System.  This fixed the issue but I think it's only increased to around 3GB, I'm not sure.  Will keep reading and maybe look into exporting it as a 64bit app.  Not sure how this will work with Leadwerks 4 yet...
    Some links below;
    https://msdn.microsoft.com/en-us/library/wz223b1z.aspx
    https://stackoverflow.com/questions/5686459/what-is-the-maximum-memory-available-to-a-c-application-on-32-bit-windows
     
    Hopefully someone finds this info useful. ?
  10. SpiderPig's post in Accessing window or context by another class in CPP was marked as the answer   
    Hi, you can call Window::GetCurrent () and Context:: GetCurrent().  To access the camera in all classes however, I create a global variable that each class can access.
×
×
  • Create New...