Guest User

Untitled

a guest
May 22nd, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.95 KB | None | 0 0
  1. int GzPutDisplay(GzDisplay *display, int i, int j, GzIntensity r, GzIntensity g, GzIntensity b, GzIntensity a, GzDepth z)
  2. {
  3. /* write pixel values into the display */
  4.  
  5.     GzPixel currPixel = {r, g, b, a, z};
  6.     //Bound checking
  7.     if(i < 0 || i >= display->xres || j < 0 || j >= display->yres) return GZ_FAILURE; //Ignore anything outside of the resolution
  8.     display->fbuf[j * display->xres + i] = currPixel;
  9.     return GZ_SUCCESS;
  10. }
  11.  
  12. int GzGetDisplay(GzDisplay *display, int i, int j, GzIntensity *r, GzIntensity *g, GzIntensity *b, GzIntensity *a, GzDepth *z)
  13. {
  14.     /* pass back pixel value in the display */
  15.     /* check display class to see what vars are valid */
  16.  
  17.     //Bound checking
  18.     if(i < 0 || i >= display->xres || j < 0 || j >= display->yres) return GZ_FAILURE;
  19.     GzPixel currPixel = display->fbuf[j * display->xres + i];
  20.     *r = currPixel.red;
  21.     *g = currPixel.green;
  22.     *b = currPixel.blue;
  23.     *a = currPixel.alpha;
  24.     *z = currPixel.z;
  25.  
  26.     return GZ_SUCCESS;
  27. }
Add Comment
Please, Sign In to add comment