ocaml - Issue with filling a rectangle with color in OcamlSDL -
i trying display colored square in center of window in ocamlsdl. creating surface , rectangle square , blitting on screen @ right position works without issue, when try color rectangle, part of gets colored (as seen in screenshot ).
here code :
open sdlevent open sdlkey open sdlvideo let image_src = "background.jpg" let win_x = 1200 let win_y = 800 let side = 10 let sq_size = 40 let seps = 10 let board_side = side * sq_size + seps * side let o_x = (win_x - board_side) / 2 let o_y = (win_y - board_side) / 2 let f_x = o_x + board_side let f_y = o_y + board_side let rec event_handler () = match wait_event () | keydown {keysym=key_escape} -> () | event -> event_handler () let main () = sdl.init [`video]; at_exit sdl.quit; let screen = sdlvideo.set_video_mode win_x win_y [] in let bg = sdlloader.load_image image_src in let pos_bg = sdlvideo.rect 0 0 win_x win_y in sdlvideo.blit_surface ~dst_rect:pos_bg ~src:bg ~dst:screen (); printf.printf "board side = %d, o_x = %d, o_y = %d, f_x = %d, f_y = %d\n" board_side o_x o_y f_x f_y ; let board = sdlvideo.create_rgb_surface [`hwsurface] board_side board_side 32 (int32.of_int 0) (int32.of_int 0) (int32.of_int 0) (int32.of_int 0) in let pos_board = sdlvideo.rect o_x o_y f_x f_y in sdlvideo.fill_rect ~rect:pos_board board (int32.of_int 4294967295) ; sdlvideo.blit_surface ~dst_rect:pos_board ~src:board ~dst:screen () ; sdlvideo.flip screen; event_handler () let _ = main ()
i've looked around , haven't found cases similar mine, , ocamlsdl's documentation of no help. feel missing obvious, have no idea what. suggestions ? on ubuntu 14.04 64 bit.
Comments
Post a Comment