home *** CD-ROM | disk | FTP | other *** search
/ 3D Games - Real-time Rend…ng & Software Technology / 3D Games - Real-time Rendering & Software Technology.iso / flysdk / lib / render / render.cpp next >
Encoding:
C/C++ Source or Header  |  2000-12-12  |  1.9 KB  |  88 lines

  1. #include "../Fly3D.h"
  2.  
  3. FLY_API render *rend=0;
  4.  
  5. FLY_API PIXELFORMATDESCRIPTOR rendermodes[256];
  6. FLY_API int rendermodesindx[256];
  7. FLY_API DEVMODE videomodes[256];
  8. FLY_API int numvideomodes=0;
  9. FLY_API int numrendermodes=0;
  10. FLY_API int selvideomode=0;
  11. FLY_API int selrendermode=0;
  12.  
  13. FLY_API int ntextureunits=1;
  14. FLY_API int nhwlights=4;
  15. FLY_API int nregcomb=0;
  16. FLY_API int screen_sx=0,screen_sy=0;
  17. FLY_API int fullscreen=0;
  18. FLY_API int colorbits=0;
  19. FLY_API int stencilbits=0;
  20. FLY_API int depthbits=0;
  21. FLY_API int accumbits=0;
  22. FLY_API int alphabits=0;
  23. FLY_API float brightness=1.0f;
  24. FLY_API RECT winrect;
  25.  
  26. void FlyGetProfile(LPTSTR section, LPTSTR key, LPBYTE lpData, DWORD cbData)
  27. {
  28.     HKEY key1,key2,key3,key4;
  29.  
  30.     if (ERROR_SUCCESS==RegOpenKeyEx(HKEY_CURRENT_USER,"Software",0,KEY_READ,&key1))
  31.     {
  32.         if (ERROR_SUCCESS==RegOpenKeyEx(key1,"Paralelo",0,KEY_READ,&key2))
  33.         {
  34.             if (ERROR_SUCCESS==RegOpenKeyEx(key2,"Fly3D",0,KEY_READ,&key3))
  35.             {
  36.                 if (ERROR_SUCCESS==RegOpenKeyEx(key3,section,0,KEY_READ,&key4))
  37.                 {
  38.                     RegQueryValueEx(key4, key, 0, 0, lpData, &cbData);
  39.                     RegCloseKey(key4);
  40.                 }
  41.                 RegCloseKey(key3);
  42.             }
  43.             RegCloseKey(key2);
  44.         }
  45.         RegCloseKey(key1);
  46.     }
  47. }
  48.  
  49. FLY_API void init_render(int type)
  50. {
  51.     free_render();
  52.     
  53.     FlyGetProfile("Settings","videomode", (unsigned char *)&selvideomode, sizeof(int));
  54.     FlyGetProfile("Settings","rendermode", (unsigned char *)&selrendermode, sizeof(int));
  55.     FlyGetProfile("Settings","brightness", (unsigned char *)&brightness, sizeof(float));
  56.  
  57.     switch(type)
  58.     {
  59.     case FLY_RENDER_OPENGL:
  60.         rend=new renderGL();
  61.         break;
  62.     }
  63.  
  64.     if (rend)
  65.     {
  66.         rend->CreateView();
  67.         rend->InitView();
  68.     }
  69. }
  70.  
  71. FLY_API void free_render()
  72. {
  73.     if (fullscreen)
  74.         ChangeDisplaySettings(NULL,CDS_FULLSCREEN);
  75.  
  76.     if (rend)
  77.     {
  78.         rend->DeleteView();
  79.         delete rend;
  80.         rend=0;
  81.     }
  82.  
  83.     numvideomodes=0;
  84.     selvideomode=0;
  85.     numrendermodes=0;
  86.     selrendermode=0;
  87. }
  88.