; hgcapture使用サンプル #include "hgimg3.as" #include "d3m.hsp" ; 以下の行をコメントアウトするとウインドウ表示になる #define FULLSCR #packopt name "07_hgcapture" ; file name #packopt type 0 ; generate ".exe" #define TEXFILE "tex.png" #pack TEXFILE #define KB_ESC 128 framerate = 60 title "Screen 0" ; メイン表示ウインドウを確保 dispid = 2 #ifdef FULLSCR ; get desktop size dispw = ginfo_dispx disph = ginfo_dispy bgscr dispid, dispw, disph, 0, 0, 0, dispw, disph #else dispw = 1600 disph = 900 screen dispid, dispw, disph, 0 title "Screen " + dispid #endif ; hgcapture用バッファを確保 vscrw = 800 vscrh = 450 tbufid = 6 buffer tbufid, vscrw, vscrh ; 仮想画面相当の表示ウインドウを確保 vscrid = 5 ;modevalue = screen_hide modevalue = 0 screen vscrid, vscrw, vscrh, modevalue title "Screen " + vscrid hgini ; load texture texload2 TEXFILE texid = stat ; get texture ID texw = 512 texh = 512 clscolor $4080c0 ; set clear color angle = 0.0 time_start = d3timer() *mainloop repeat ; get FPS tm = d3timer() - time_start fps = d3getfps() ; ESC key to exit stick k, 0 if k & KB_ESC : break angle += 0.5 hgdraw ; draw images (HGIMG3) objmax = 96 repeat objmax r = double(vscrh) * 0.5 a = angle + (270.0 / double(objmax)) * double(cnt) x = int(r * cos(deg2rad(a))) + (vscrw / 2) y = int(r * sin(deg2rad(a))) + (vscrh / 2) d = double(cnt) / double(objmax) src_x = (idx \ 2) * texw src_y = ((idx / 2) \2) * texh idx = (cnt \ 4) rot = deg2rad(angle * 2.0 + 360.0 * d) ; scale = 1.0 - (0.75 * d) scale = 2.0 - (1.75 * d) dst_w = int(double(texw) * scale) dst_h = int(double(texh) * scale) ; draw image by celput gmode gmode_rgb0, texw, texh pos x, y hgrotate texid, src_x, src_y, rot, dst_w, dst_h loop if 0 { t = (1000 / framerate) - 1 if t <= 0 : t = 1 hgsync t } else { hgsync 12 } ; HGIMG3 の描画結果をキャプチャしてbuffer(ID=tbufid)にコピー ; 右端と下端に数ドット黒部分が出るのはバグらしい gsel tbufid ; redraw 0 hgcapture ; redraw 1 ; メイン表示ウインドウにHGIMG3の描画結果を描画していく gsel dispid redraw 0 ; tbufid から dispid に拡大描画 (HSP標準描画機能) if 1 { gmode gmode_gdi pos 0, 0 gzoom dispw, disph, tbufid, 0, 0, vscrw, vscrh, 0 } else { gmode gmode_gdi, vscrw, vscrh pos (dispw / 2), (disph / 2) grotate tbufid, 0, 0, 0.0, dispw, disph } ; draw text (HSP標準描画機能) if 1 { font "Tahoma", 20, 1, 2 objcolor 255, 255, 255 color 16, 16, 16 pos 16, 16 mes strf("[%dx%d] %d FPS", vscrw, vscrh, fps), 4 } redraw 1 await (1000 / framerate) loop *mainloop_end end