home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / oglgold.zip / SAMPLES / TK / RANDOM.C < prev    next >
Text File  |  1997-09-30  |  2KB  |  55 lines

  1. static char sccsid[] = "@(#)27    1.1  src/gos/3d/opengl/gltest/tkdemos/random.c, gltest, opengl_1.0 8/15/95 20:18:13";
  2. //
  3. //   COMPONENT_NAME: GLTEST
  4. //
  5. //   FUNCTIONS: Systems
  6. //        myrand
  7. //        mysrand
  8. //        
  9. //
  10. //   ORIGINS: 27
  11. //
  12. //
  13. //   (C) COPYRIGHT International Business Machines Corp. 1993
  14. //   All Rights Reserved
  15. //   Licensed Materials - Property of IBM
  16. //   US Government Users Restricted Rights - Use, duplication or
  17. //   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  18. //
  19.  
  20. //
  21. // Permission to use, copy, modify, and distribute this software and its
  22. // documentation for any purpose and without fee is hereby granted, provided
  23. // that the above copyright notice appear in all copies and that both that
  24. // copyright notice and this permission notice appear in supporting
  25. // documentation, and that the name of I.B.M. not be used in advertising
  26. // or publicity pertaining to distribution of the software without specific,
  27. // written prior permission. I.B.M. makes no representations about the
  28. // suitability of this software for any purpose.  It is provided "as is"
  29. // without express or implied warranty.
  30. //
  31. // I.B.M. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
  32. // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL I.B.M.
  33. // BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  34. // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  35. // OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  36. // CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  37. //
  38. // Author:  John Spitzer, IBM AWS Graphics Systems (Austin)
  39. //
  40. // Need predicatable, reproducible numbers over a number of platforms
  41. // Thus, we need an implementation independent psuedo-random number
  42. // generator.  Here, we use the Linear Congruential Method.
  43.  
  44. static seed = 1;
  45.  
  46. void mysrand(int i)
  47. {
  48.     seed = i;
  49. }
  50.  
  51. int myrand()
  52. {
  53.     return seed = (seed*7621 + 1)&0xffff;
  54. }
  55.