OSDN Git Service

Merge branch 'git-svn'
[nyartoolkit-and/nyartoolkit-and.git] / tags / 2.5.1 / src.utils / jogl / jp / nyatla / nyartoolkit / jogl / utils / GLNyARRaster_RGB.java
1 /* \r
2  * PROJECT: NyARToolkit JOGL utilities.\r
3  * --------------------------------------------------------------------------------\r
4  * This work is based on the original ARToolKit developed by\r
5  *   Hirokazu Kato\r
6  *   Mark Billinghurst\r
7  *   HITLab, University of Washington, Seattle\r
8  * http://www.hitl.washington.edu/artoolkit/\r
9  *\r
10  * The NyARToolkit is Java edition ARToolKit class library.\r
11  * Copyright (C)2008-2009 Ryo Iizuka\r
12  *\r
13  * This program is free software: you can redistribute it and/or modify\r
14  * it under the terms of the GNU General Public License as published by\r
15  * the Free Software Foundation, either version 3 of the License, or\r
16  * (at your option) any later version.\r
17  * \r
18  * This program is distributed in the hope that it will be useful,\r
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
21  * GNU General Public License for more details.\r
22  *\r
23  * You should have received a copy of the GNU General Public License\r
24  * along with this program.  If not, see <http://www.gnu.org/licenses/>.\r
25  * \r
26  * For further information please contact.\r
27  *      http://nyatla.jp/nyatoolkit/\r
28  *      <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>\r
29  * \r
30  */\r
31 package jp.nyatla.nyartoolkit.jogl.utils;\r
32 \r
33 \r
34 import javax.media.opengl.GL;\r
35 \r
36 import jp.nyatla.nyartoolkit.NyARException;\r
37 import jp.nyatla.nyartoolkit.jmf.utils.*;\r
38 import jp.nyatla.nyartoolkit.core.param.NyARParam;\r
39 import jp.nyatla.nyartoolkit.core.raster.*;\r
40 import jp.nyatla.nyartoolkit.core.types.NyARBufferType;\r
41 \r
42 import javax.media.format.*;\r
43 \r
44 /**\r
45  * NyARRaster_RGBにOpenGL用のデータ変換機能を追加したものです。\r
46  */\r
47 public class GLNyARRaster_RGB extends JmfNyARRaster_RGB\r
48 {\r
49         private int _gl_flag;\r
50         /**\r
51          * コンストラクタです。i_formatを取り込めるi_paramのサイズパラメタを持つ\r
52          * ラスタオブジェクトを作成します。\r
53          * @param i_param\r
54          * カメラパラメタを指定します。コンストラクタは、画面サイズ以外のパラメタを見ていません。\r
55          * @param i_format\r
56          * キャプチャ画像のピクセルフォーマットを指定します。\r
57          * @throws NyARException\r
58          */\r
59         public GLNyARRaster_RGB(NyARParam i_param,VideoFormat i_format) throws NyARException\r
60         {\r
61                 super(i_param.getScreenSize(),i_format);\r
62                 initMember(this.getBufferType());\r
63                 return;\r
64         }\r
65         public GLNyARRaster_RGB(int i_width,int i_height,VideoFormat i_format) throws NyARException\r
66         {\r
67                 super(i_width,i_height,i_format);\r
68                 initMember(this.getBufferType());\r
69                 return;\r
70         }       \r
71         private void initMember(int i_buffer_type) throws NyARException\r
72         {\r
73                 switch(i_buffer_type){\r
74                 case NyARBufferType.BYTE1D_B8G8R8_24:\r
75                         this._gl_flag = GL.GL_BGR;\r
76                         break;\r
77                 case NyARBufferType.BYTE1D_R8G8B8_24:\r
78                         this._gl_flag = GL.GL_RGB;\r
79                         break;\r
80                 default:\r
81                         throw new NyARException();\r
82                 }\r
83                 return;\r
84         }\r
85         /**\r
86          * RGBバイト配列への参照値を返します。\r
87          * バッファの並び順は、getGLPixelFlagが返すデータ順で格納されています。\r
88          * @return\r
89          * RGBバイト配列の参照値です。\r
90          */\r
91         public byte[] getGLRgbArray()\r
92         {\r
93                 return (byte[])this.getBuffer();\r
94         }\r
95 \r
96         /**\r
97          * OpenGLの描画フラグを返します。\r
98          * この値は、RGBバッファのバイト並びタイプです。\r
99          * @return\r
100          * GL.GL_BGR等の、RGBバイト配列の形式を表す値です。\r
101          */\r
102         public int getGLPixelFlag()\r
103         {\r
104                 return this._gl_flag;\r
105         }\r
106 \r
107 }\r