Author Topic: progress when precalcing and loading..  (Read 4639 times)

0 Members and 1 Guest are viewing this topic.

Offline marlon

  • C= 64
  • **
  • Posts: 38
  • Karma: 15
    • View Profile
progress when precalcing and loading..
« on: April 30, 2012 »
Hello all you mighty DBF'ers!   =)


Before my code is running I am initializing some stuff..
Loading my heightmap into the grid and calcing all the normals for that..
Then I do that Icosahedron for my jellyball..
And loading textures for those..

But when all those things are in progress I can not see anything on screen.. Just white screen..
I would like to print out some text and maybe a progressbar so I can follow what is going on..
But it is like I do not get anything on screen except when I run things from my MainWinLoop...

Anyone got any clues on how to do this..?

-marlon

Offline Raizor

  • Founder Member
  • Pentium
  • ********
  • Posts: 1154
  • Karma: 175
    • View Profile
Re: progress when precalcing and loading..
« Reply #1 on: April 30, 2012 »
I suggest loading assets and pre-calcing in a separate background thread. Your 'loader' thread can then update a variable to indicate percentage complete and finally set a flag (bool variable) when everything is loaded.

In your main thread, just check if [complete] is false, and if so, draw a progress bar to indicate the percentage complete value. When [complete] is set to true by the background thread (because everything is loaded), you can start your demo/intro.

IQ's 64k intro framework already includes something like this. It's worth checking out.
raizor

Challenge Trophies Won:

Offline marlon

  • C= 64
  • **
  • Posts: 38
  • Karma: 15
    • View Profile
Re: progress when precalcing and loading..
« Reply #2 on: April 30, 2012 »
ok.. thanks Raizor

I will take a look at it!   =)

Offline marlon

  • C= 64
  • **
  • Posts: 38
  • Karma: 15
    • View Profile
Re: progress when precalcing and loading..
« Reply #3 on: May 02, 2012 »
I am thinking of it is possible to run my Initialize thread from my MainMessageLoop?
All that thru a CreateThread...

The CreateThread Function will initialize all the stuff and then put the Status/Progress in some global variable/variables and then let the MainMessageLoop print that to the screen.. When the thread is finished the Intro/Demo will continue..

Yes?

-marlon

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: progress when precalcing and loading..
« Reply #4 on: May 03, 2012 »
Quote
The CreateThread Function will initialize all the stuff and then put the Status/Progress in some global variable/variables and then let the MainMessageLoop print that to the screen.. When the thread is finished the Intro/Demo will continue..
Yes?

Yes. That's it.

If you are using the C runtime libraries in your initialisation code, you need to use _beginthread or _beginthreadex instead of CreateThread so that it all works properly.

Jim
Challenge Trophies Won:

Offline marlon

  • C= 64
  • **
  • Posts: 38
  • Karma: 15
    • View Profile
Re: progress when precalcing and loading..
« Reply #5 on: May 05, 2012 »
First I setup Opengl in some PreInitialization...
When that is done I use a window to print what is Calculating and Loading..
The Calculations and Loading routines are called from the Thread..
..

So..
1. Initialize OpenGL
2. Start a Setup Routine That is calling a Thread to do the Calculation and Loaidng.. (The Thread is calling several routines)
3. The Setup Routine also Prints out the Status of the Thread..
4. When The Setup Routine is Done my SceneDrawing is Starting up instead..

It looks like everything is loading and calculating.. but..
Then it comes to setting up the VBO in the Thread..
Boom..  =(

-> glGenBuffers( 1, &cJellyBall->vBuf);
     glBindBuffer( GL_ARRAY_BUFFER_ARB, cJellyBall->vBuf );
     glBufferData( GL_ARRAY_BUFFER_ARB, cJellyBall->m_iNumVertices * sizeof(VECTOR3D), cJellyBall->m_rgsVertices,    GL_STATIC_DRAW_ARB );


This is where it stops.. All my objects are created dynamically..
But says that it got some adress violation..  Humm..  =(