Posted to tcl by ro at Sun Jan 06 23:25:07 GMT 2008view raw

  1. tcl3d> SDL_VideoInfo x
  2. _38678502_p_SDL_VideoInfo
  3. tcl3d> x cget -video_mem
  4. 0
  5.  
  6. tcl3d> SDL_Init $SDL_INIT_VIDEO
  7. 0
  8.  
  9. tcl3d> SDL_SetVideoMode 256 256 32 0
  10. _801d8102_p_SDL_Surface
  11.  
  12. tcl3d> set screen _801d8102_p_SDL_Surface
  13. _801d8102_p_SDL_Surface
  14.  
  15. # this is like: screen->pixels
  16. tcl3d> set pixels [$screen cget -pixels]
  17. _78f58502_p_void
  18.  
  19. tcl3d> $screen cget -format
  20. _f8048002_p_SDL_PixelFormat
  21.  
  22. tcl3d> set pixel_format [$screen cget -format]
  23. _f8048002_p_SDL_PixelFormat
  24.  
  25. tcl3d> SDL_MapRGB $pixel_format 1 0 33
  26. 65569
  27.  
  28. tcl3d> set pitch [$screen cget -pitch]
  29. 1024
  30.  
  31. proc offset {x y} {global pitch; expr {(($pitch / 4) * $y) + $x}}
  32.  
  33. tcl3d> offset 255 255
  34. 65535
  35.  
  36. tcl3d> SDL_LockSurface $screen
  37. 0
  38. tcl3d> SDL_UnlockSurface $screen
  39.  
  40. tcl3d> SDL_Flip $screen
  41. 0
  42.  
  43. tcl3d> set rect [SDL_Rect]
  44. _40578102_p_SDL_Rect
  45.  
  46. tcl3d> $rect configure -x 0 -y 0 -w 200 -h 200
  47. tcl3d> $rect cget -x
  48. 0
  49. tcl3d> $rect cget -y
  50. 0
  51. tcl3d> $rect cget -w
  52. 200
  53. tcl3d> $rect cget -h
  54. 200
  55.  
  56.  
  57. tcl3d> SDL_LockSurface $screen
  58. 0
  59. tcl3d> SDL_FillRect $screen $rect 32
  60. 0
  61. tcl3d> SDL_UnlockSurface $screen
  62. tcl3d> SDL_Flip $screen
  63. 0
  64.  
  65. tcl3d> proc color {r g b} {global pixel_format ; SDL_MapRGB $pixel_format $r $g $b}
  66.  
  67. proc paint {r g b} {
  68. global screen rect
  69. SDL_LockSurface $screen
  70. SDL_FillRect $screen $rect [color $r $g $b]
  71. SDL_UnlockSurface $screen
  72. SDL_Flip $screen
  73. }
  74.  
  75. proc fun {} {
  76. for {set i 0} {$i < 256} {incr i} {paint 0 0 $i}
  77. for {set i 0} {$i < 256} {incr i} {paint 0 $i 0}
  78. for {set i 0} {$i < 256} {incr i} {paint $i 0 0}
  79. }
  80.