Windowsのコンパイル環境の作成

サンプルのシューティング(バイザライザー)を動かして動作確認をします。
その後、ガンハウンドのソースのコンパイルと実行の手順を説明します。

・インストール方法
・トラブル対応
・その他

ライブラリの調査、研究報告など
http://dragon.suplex.net/

手順1.インストール

VC2015を用意します。VC2013を使用する場合は「トラブル」の項目を参考にvcxprojファイルの一部を書き換えると動作させることができます。

gitリポジトリよりソース一式をダウンロード
https://bitbucket.org/garuruLabs/gxlib/downloads

  • ダウンロード > 「リポジトリをダウンロードする」をクリック

ダウンロードしてきたZIPファイルを都合のいいディレクトリに展開します

各種ライブラリをインストールする

DirectX SDKを用意する

Windows環境ではOpenGL環境とDirectX環境を選択できます。DirectX版を使用する際はDirectX9のSDKを用意してください。
既に環境がある場合には「手順.2」に進んでください。

[手順]
DirectXSDK(Microsoft DirectX SDK (August 2009))のダウンロード

ダウンロード後、インストールを行いインストールしたSDKのincludeとLibフォルダにパスを設定するか
もしくは、インストール後のファイルをgxLibの以下のフォルダへコピーします。

Microsoft DirectX SDK (August 2009)/Include/*.*
 ↓ ここにコピーする
gxLib/platform/Windows/Include/directx9/*.*

Microsoft DirectX SDK (August 2009)/Lib/*.*
 ↓ ここにコピーする
gxLib/platform/Windows/lib/directx9/*.*

※上記のフォルダにはgxLibのプロジェクト設定(*.vcxproj)で最初からパスを通しています。

フォルダ構成はこうなります。

gxLib/platform/Windows/include/directx9/audiodefs.h
 ~
gxLib/platform/Windows/include/directx9/xnamathvector.inl
gxLib/platform/Windows/lib/directx9/x64
gxLib/platform/Windows/lib/directx9/x86

OpenCV

http://opencv.org/wp-content/themes/opencv/images/logo.png
Windows環境で動画の再生に「OpenCV」を利用します。以下よりver3.1以降を取得してください。(2.4.x系は未検証)

http://opencv.org/
※DOWNLOADS > VERSION 3.1 > OpenCV for Windows

openCVのヘッダーファイル群を以下に配置します
※platform/windows/include/フォルダも作成してください

platform/windows/include/openCV/opencv
platform/windows/include/openCV/opencv2

oggVorbis

http://xiph.org/images/logos/fish_xiph_org.png
Windows環境で圧縮音楽の再生に「ogg Vorvis」を使用します

http://xiph.org/downloads/から以下のファイルをダウンロードして下さい。

libogg(1.3.2) libogg-1.3.2.zip
libvorbis(1.3.5) libvorbis-1.3.5.zip

oggVorbisのヘッダーファイル群を以下に配置します

platform/Windows/include/vorbis
platform/Windows/include/ogg

freeGlut

http://freeglut.sourceforge.net/images/opengl.png
OpenGLを使用する場合はfreeGlutを使用します

http://freeglut.sourceforge.net/ > Downloadから「Freeglut 3.0.0」をダウンロードします。

以下のDLLをexeファイルと同じ階層に格納します

run/opencv_ffmpeg310_64.dll
run/opencv_world310.dll
run/opencv_world310d.dll

ライブラリファイルの配置

各種ライブラリファイルそれぞれパスの通った場所へインストールを
行いますが、gxLibフォルダの以下の配置でも自動的に認識可能です。

platform/windows/lib
│  
├─directx9
│  ├─x64
│  │      d2d1.lib
│  │      d3d10.lib
│  │      d3d10_1.lib
│  │      d3d11.lib
│  │      d3d9.lib
│  │      d3dcompiler.lib
│  │      D3DCSX.lib
│  │      D3DCSXd.lib
│  │      d3dx10.lib
│  │      d3dx10d.lib
│  │      d3dx11.lib
│  │      d3dx11d.lib
│  │      d3dx9.lib
│  │      d3dx9d.lib
│  │      d3dxof.lib
│  │      dinput8.lib
│  │      dsound.lib
│  │      dwrite.lib
│  │      DxErr.lib
│  │      dxgi.lib
│  │      dxguid.lib
│  │      X3DAudio.lib
│  │      xapobase.lib
│  │      xapobased.lib
│  │      XAPOFX.lib
│  │      XInput.lib
│  │      
│  └─x86
│          d2d1.lib
│          d3d10.lib
│          d3d10_1.lib
│          d3d11.lib
│          d3d9.lib
│          d3dcompiler.lib
│          D3DCSX.lib
│          D3DCSXd.lib
│          d3dx10.lib
│          d3dx10d.lib
│          d3dx11.lib
│          d3dx11d.lib
│          d3dx9.lib
│          d3dx9d.lib
│          d3dxof.lib
│          dinput8.lib
│          dsetup.lib
│          dsound.lib
│          dwrite.lib
│          DxErr.lib
│          dxgi.lib
│          dxguid.lib
│          X3DAudio.lib
│          xapobase.lib
│          xapobased.lib
│          XAPOFX.lib
│          XInput.lib
│          
├─freeglut
│      d_freeGlutx64.lib
│      d_freeGlutx86.lib
│      r_freeGlutx64.lib
│      r_freeGlutx86.lib
│      
├─oggVorbis
│  │  r_libogg_static_x64.lib
│  │  r_libogg_static_x86.lib
│  │  r_libvorbisfile_static_x64.lib
│  │  r_libvorbisfile_static_x86.lib
│  │  r_libvorbis_static_x64.lib
│  │  r_libvorbis_static_x86.lib
│  │  
│  └─debug
│      ├─x64
│      │      d_libogg_static_x64.lib
│      │      d_libvorbisfile_static_x64.lib
│      │      d_libvorbis_static_x64.lib
│      │      
│      └─x86
│              d_libogg_static_x86.lib
│              d_libvorbisfile_static_x86.lib
│              d_libvorbis_static_x86.lib
│              
└─openCV
        opencv_world310.lib
        opencv_world310d.lib

手順2.コンパイルして実行する

gxLib.slnファイルからプロジェクトを起動する

F5キーで実行し、VISORISERが起動することを確認してください

100%"

手順3.ガンハウンドのソースをコンパイルして実行する

  • ガンハウンドのソースをダウンロード
    ダウンロードしてきたgunhoundフォルダを配置します
    src/gunhound
    src/gunvalken.h
  • プロジェクトへ追加
     src/gunhound、src/gunvalken.hをVCのソリューションエクスプローラーのSource Filesにドラッグ&ドロップして登録してください
    vc01.png
  • ライブラリにhitManagerの機能を追加します
    ファイルをソリューションエクスプローラーに追加してください
    gxLib/util/hitManager/CCollisionManager.h
    gxLib/util/hitManager/CCollisionManager.cpp
vc02.png
  • ゲームプログラムの呼び出し
    src/gameMain.cpp
    gxBool GameMain()
    {
    	gxBool GunHoundMain(gxBool bReset);
    	GunHoundMain( gxFalse );
    }

gxLib.h 29行目

#define WINDOW_W (480)
#define WINDOW_H (272)

トラブル対応

OpenGLに切り替えるには?

以下の定義を切り替えます。
gxLib.h

#define PLATFORM_WIN32_DIRECTX9
//#define PLATFORM_WIN32_OPENGL

  ↓

//#define PLATFORM_WIN32_DIRECTX9
#define PLATFORM_WIN32_OPENGL

実行時に必要になるopenCVのDLLを以下にコピーしてください。

run/opencv_ffmpeg310_64.dll
run/opencv_world310.dll
run/opencv_world310d.dll

vorbis/vorbisfile.h No such file or directry

ogg vorbisのヘッダーファイルが見つかっていません。ヘッダーファイルを格納した場所へのパス設定を見なおしてみてください。gxLibのデフォルトでは下記の2箇所に格納されれば自動的に認識します

platform/windows/include/ogg/
platform/windows/include/vorbis/

opencv/opencv.hpp No such file or directry

同じくopencvのヘッダーが見つかっていません。「platform/windows/include/openCV/」に以下の2つのフォルダを配置してください。

platform/windows/include/openCV/opencv
platform/windows/include/openCV/opencv2

構文エラー : 識別子 'D3DMULTISAMPLE_TYPE

DirectXのSDKが入っていないか、SDKのフォルダへパスが通ってない可能性があります
gxLibでは以下に配置すると自動的にコンパイル対象に追加されます

platform/windows/include/openCV/directx9

VC2013を使ってコンパイルする

SDKのバージョン番号が異なる場合コンパイル時にエラーが出力されるので適切なバージョン番号に設定してください。

platform/Windows/DirectX.vcxproj
platform/Windows/OpenGL.vcxproj

<PlatformToolset>v140</PlatformToolset>
 ↓
<PlatformToolset>v120</PlatformToolset>

その他

includeファイルの構成

platform/windows/include
│  
├─directx9
│      audiodefs.h
│      comdecl.h
│      D2D1.h
│      D2D1Helper.h
│      D2DBaseTypes.h
│      D2Derr.h
│      D3D10.h
│      D3D10effect.h
│      d3d10misc.h
│      d3d10sdklayers.h
│      D3D10shader.h
│      D3D10_1.h
│      D3D10_1shader.h
│      D3D11.h
│      D3D11SDKLayers.h
│      D3D11Shader.h
│      d3d9.h
│      d3d9caps.h
│      d3d9types.h
│      D3Dcommon.h
│      D3Dcompiler.h
│      D3DCSX.h
│      D3DX10.h
│      d3dx10async.h
│      D3DX10core.h
│      D3DX10math.h
│      D3DX10math.inl
│      D3DX10mesh.h
│      D3DX10tex.h
│      D3DX11.h
│      D3DX11async.h
│      D3DX11core.h
│      D3DX11tex.h
│      d3dx9.h
│      d3dx9anim.h
│      d3dx9core.h
│      d3dx9effect.h
│      d3dx9math.h
│      d3dx9math.inl
│      d3dx9mesh.h
│      d3dx9shader.h
│      d3dx9shape.h
│      d3dx9tex.h
│      d3dx9xof.h
│      D3DX_DXGIFormatConvert.inl
│      Dcommon.h
│      dinput.h
│      dinputd.h
│      dsconf.h
│      dsetup.h
│      dsound.h
│      DWrite.h
│      dxdiag.h
│      DxErr.h
│      dxfile.h
│      DXGI.h
│      DXGIFormat.h
│      DXGIType.h
│      dxsdkver.h
│      gameux.h
│      PIXPlugin.h
│      rmxfguid.h
│      rmxftmpl.h
│      rpcsal.h
│      X3DAudio.h
│      xact3.h
│      xact3d3.h
│      xact3wb.h
│      XAPO.h
│      XAPOBase.h
│      XAPOFX.h
│      XAudio2.h
│      XAudio2fx.h
│      XDSP.h
│      XInput.h
│      xma2defs.h
│      xnamath.h
│      xnamathconvert.inl
│      xnamathmatrix.inl
│      xnamathmisc.inl
│      xnamathvector.inl
│      
├─ogg
│      ogg.h
│      os_types.h
│      
├─openCV
│  ├─opencv
│  │      cv.h
│  │      cv.hpp
│  │      cvaux.h
│  │      cvaux.hpp
│  │      cvwimage.h
│  │      cxcore.h
│  │      cxcore.hpp
│  │      cxeigen.hpp
│  │      cxmisc.h
│  │      highgui.h
│  │      ml.h
│  │      
│  └─opencv2
│      │  calib3d.hpp
│      │  core.hpp
│      │  cvconfig.h
│      │  features2d.hpp
│      │  flann.hpp
│      │  highgui.hpp
│      │  imgcodecs.hpp
│      │  imgproc.hpp
│      │  ml.hpp
│      │  objdetect.hpp
│      │  opencv.hpp
│      │  opencv_modules.hpp
│      │  photo.hpp
│      │  shape.hpp
│      │  stitching.hpp
│      │  superres.hpp
│      │  video.hpp
│      │  videoio.hpp
│      │  videostab.hpp
│      │  world.hpp
│      │  
│      ├─calib3d
│      │      calib3d.hpp
│      │      calib3d_c.h
│      │      
│      ├─core
│      │  │  affine.hpp
│      │  │  base.hpp
│      │  │  bufferpool.hpp
│      │  │  core.hpp
│      │  │  core_c.h
│      │  │  cuda.hpp
│      │  │  cuda.inl.hpp
│      │  │  cuda_stream_accessor.hpp
│      │  │  cuda_types.hpp
│      │  │  cvdef.h
│      │  │  cvstd.hpp
│      │  │  cvstd.inl.hpp
│      │  │  directx.hpp
│      │  │  eigen.hpp
│      │  │  fast_math.hpp
│      │  │  ippasync.hpp
│      │  │  mat.hpp
│      │  │  mat.inl.hpp
│      │  │  matx.hpp
│      │  │  neon_utils.hpp
│      │  │  ocl.hpp
│      │  │  ocl_genbase.hpp
│      │  │  opengl.hpp
│      │  │  operations.hpp
│      │  │  optim.hpp
│      │  │  persistence.hpp
│      │  │  private.cuda.hpp
│      │  │  private.hpp
│      │  │  ptr.inl.hpp
│      │  │  saturate.hpp
│      │  │  sse_utils.hpp
│      │  │  traits.hpp
│      │  │  types.hpp
│      │  │  types_c.h
│      │  │  utility.hpp
│      │  │  va_intel.hpp
│      │  │  version.hpp
│      │  │  wimage.hpp
│      │  │  
│      │  └─hal
│      │          hal.hpp
│      │          interface.h
│      │          intrin.hpp
│      │          intrin_cpp.hpp
│      │          intrin_neon.hpp
│      │          intrin_sse.hpp
│      │          
│      ├─features2d
│      │      features2d.hpp
│      │      
│      ├─flann
│      │      allocator.h
│      │      all_indices.h
│      │      any.h
│      │      autotuned_index.h
│      │      composite_index.h
│      │      config.h
│      │      defines.h
│      │      dist.h
│      │      dummy.h
│      │      dynamic_bitset.h
│      │      flann.hpp
│      │      flann_base.hpp
│      │      general.h
│      │      ground_truth.h
│      │      hdf5.h
│      │      heap.h
│      │      hierarchical_clustering_index.h
│      │      index_testing.h
│      │      kdtree_index.h
│      │      kdtree_single_index.h
│      │      kmeans_index.h
│      │      linear_index.h
│      │      logger.h
│      │      lsh_index.h
│      │      lsh_table.h
│      │      matrix.h
│      │      miniflann.hpp
│      │      nn_index.h
│      │      object_factory.h
│      │      params.h
│      │      random.h
│      │      result_set.h
│      │      sampling.h
│      │      saving.h
│      │      simplex_downhill.h
│      │      timer.h
│      │      
│      ├─highgui
│      │      highgui.hpp
│      │      highgui_c.h
│      │      
│      ├─imgcodecs
│      │      imgcodecs.hpp
│      │      imgcodecs_c.h
│      │      ios.h
│      │      
│      ├─imgproc
│      │  │  imgproc.hpp
│      │  │  imgproc_c.h
│      │  │  types_c.h
│      │  │  
│      │  └─detail
│      │          distortion_model.hpp
│      │          
│      ├─ml
│      │      ml.hpp
│      │      
│      ├─objdetect
│      │      detection_based_tracker.hpp
│      │      objdetect.hpp
│      │      objdetect_c.h
│      │      
│      ├─photo
│      │      cuda.hpp
│      │      photo.hpp
│      │      photo_c.h
│      │      
│      ├─shape
│      │      emdL1.hpp
│      │      hist_cost.hpp
│      │      shape.hpp
│      │      shape_distance.hpp
│      │      shape_transformer.hpp
│      │      
│      ├─stitching
│      │  │  warpers.hpp
│      │  │  
│      │  └─detail
│      │          autocalib.hpp
│      │          blenders.hpp
│      │          camera.hpp
│      │          exposure_compensate.hpp
│      │          matchers.hpp
│      │          motion_estimators.hpp
│      │          seam_finders.hpp
│      │          timelapsers.hpp
│      │          util.hpp
│      │          util_inl.hpp
│      │          warpers.hpp
│      │          warpers_inl.hpp
│      │          
│      ├─superres
│      │      optical_flow.hpp
│      │      
│      ├─video
│      │      background_segm.hpp
│      │      tracking.hpp
│      │      tracking_c.h
│      │      video.hpp
│      │      
│      ├─videoio
│      │      cap_ios.h
│      │      videoio.hpp
│      │      videoio_c.h
│      │      
│      └─videostab
│              deblurring.hpp
│              fast_marching.hpp
│              fast_marching_inl.hpp
│              frame_source.hpp
│              global_motion.hpp
│              inpainting.hpp
│              log.hpp
│              motion_core.hpp
│              motion_stabilizing.hpp
│              optical_flow.hpp
│              outlier_rejection.hpp
│              ring_buffer.hpp
│              stabilizer.hpp
│              wobble_suppression.hpp
│              
└─vorbis
        codec.h
        vorbisenc.h
        vorbisfile.h

LUAを利用する

Cocos2Dxを利用する

zLibを利用したpngファイルの使用