home *** CD-ROM | disk | FTP | other *** search
/ Computer Panoráma / computer_panorama_1997-12-hibas.iso / SHARE / GRAPH / PTC051.ZIP / EXAMPLES / PRIMARY.TXT < prev    next >
Text File  |  1997-09-04  |  2KB  |  47 lines

  1.                          ===========================
  2.                          = primary surface example =
  3.                          ===========================
  4.  
  5.  
  6. Overview
  7. --------
  8.  
  9. This example explicitly sets up a 32bit ARGB8888 video mode, then accesses
  10. the primary surface and writes directly to it. The primary surface is the
  11. video surface that is currently being displayed on screen. By writing to this
  12. primary surface you write directly to the screen. The only drawback is that
  13. the nice virtual 32bit mode advantage is lost. This example will only work
  14. when an ARGB8888 video mode is available.
  15.  
  16.  
  17.  
  18.  
  19. Accessing the primary surface
  20. -----------------------------
  21.  
  22. >    // get primary surface (display surface)
  23. >    Surface *primary=ptc.GetPrimary();
  24. >    if (!primary || !primary->ok())
  25. >    {
  26. >        ptc.Close();
  27. >        cout << "could not access primary surface\n";
  28. >        return 0;
  29. >    }
  30.  
  31. The code above attempts to get a pointer to the primary surface. It is very
  32. careful to check that the primary surface is a) non-NULL b) valid. The reason
  33. for this is that not all interfaces are capable of direct screen access. Once
  34. the GDI interface for win32 is completed, it will be the first interface that
  35. doesn't have a primary surface directly available. Why? Because you cannot
  36. directly write to a GDI - and what good is a surface if YOU cannot directly 
  37. write to it? :)
  38.  
  39. Take care of the primary surface pointer you retrieve from the PTC object.
  40. Don't assume that it will remain valid forever - it will be deleted when the
  41. interface changes modes (on a PTC::Init, PTC::SetMode and PTC::Close). In all
  42. other situations PTC guarantees that the primary surface will remain valid
  43. for you - this is why primary.cpp can grab the primary surface once and then
  44. use it for the rest of the program safely.
  45.  
  46. Delete or Surface::Free the primary surface pointer at your own risk. *BOOM*
  47.