Advertisement

Transparency

Started by September 27, 2000 06:54 PM
19 comments, last by Blue*Omega 24 years, 1 month ago
You could have a long list of all your objects and then make up a function that determines the distance from the viewer (you could also add in to not worry about those that were out of camera). After this is determined, sort from largest distance to smallest in an array then have a switch structure inside a for loop like this...

        int MyListOfObjects[256];bool RenderComplete = false;//// sort the objects in here...////for (int count = 0; count < 256; count++){  switch(MyListOfObjects[count])  {    case 0:    {      RenderComplete = true;      break;    }      case 1:    {      FuncitonToDrawSomeObject();      break;    }    ... etc...  }  if (RenderComplete)    break;}    


You should probably use an enum list so that you get statements like case FIRSTBOX: instead of case 1:... This is the fastest code to figure out for this question, but i'm not sure if it's the faster executing code out there for this specific procedure...

NeHe... I think that splitting the code so that it has the funciton prototypes in .h files and the code for those in .cpp files etc. is a very good idea. It usually allows for the same base program to be used over and over without cutnpasting, instead you could just copy the main.cpp and the others might be named as windowcommands.h, windowcommands.cpp, drawcommands.h, drawcommands.cpp... That would give you the base to a program... Then you add in other header files like texturedbox.h and texturedbox.cpp and code the box in for those... Include into your drawcommands.h and call the function/class funciton in the RenderScene() function... That's what I've been doing and it works well, especially for demos that you want to use the same base code over and over again...

S.

Edited by - Strylinys on October 1, 2000 10:15:23 AM

This topic is closed to new replies.

Advertisement