2008. 12. 30.

SDL 다중 Surface 예제

뭉기적 뭉기적 거리다가 생각난김에 코딩해서 작성해봄..

SDL 에서는 CREATE-SURFACE 로 surface를 생성한 다음 BLIT-SURFACE 로 *default-surface* 에 복사하면 출력이 가능하다.

먼저 surface 를 저장할 리스트를 선언한다.
(defparameter *test-surface* nil)

다음에 지정한 색상으로  리스트 안의 모든 surface 를 칠할 함수

<br />(defun fill_surfaces (list_sf color)<br />  (cond ((null list_sf) nil)<br />		(t <br />		 (sdl:fill-surface color :surface (car list_sf))<br />		 (fill_surfaces (cdr list_sf) color))))<br />



이제 리스트 안의 모든 surface 를 Bit-Blit 으로 디폴트 surface 에 복사하는 함수


<br />(defun blit_surfaces (list_sf)<br />  (cond ((null list_sf) nil)<br />		(t<br />		 (sdl:blit-surface (car list_sf))<br />		 (blit_surfaces (cdr list_sf)))))<br />



완성된 테스트 코드..


<br />(defun surface-test ()<br />  (sdl:with-init ()<br />	(sdl:window 320 240 :title-caption "SDL-TTF Font Example")<br />	(push (sdl:create-surface 50 60) *test-surface*)<br />	(push (sdl:create-surface 50 60 :x 100 :y 120) *test-surface*)<br />	(fill_surfaces *test-surface* sdl:*white*)<br />    (blit_surfaces *test-surface*)<br />	(sdl:with-events ()<br />		(:quit-event () <br />		    (setf *test-surface* nil)<br />		    t)<br />		(:video-expose-event () (sdl:update-display))<br />		(:idle () (sdl:update-display)))))<br />


다음번에는 Timer관련해서 애니메이션을 시켜보도록 하겠다..

댓글 없음:

댓글 쓰기