* HITLab, University of Washington, Seattle\r
* http://www.hitl.washington.edu/artoolkit/\r
*\r
- * The NyARToolkit is Java version ARToolkit class library.\r
- * Copyright (C)2008 R.Iizuka\r
+ * The NyARToolkit is Java edition ARToolKit class library.\r
+ * Copyright (C)2008-2009 Ryo Iizuka\r
*\r
- * This program is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU General Public License\r
- * as published by the Free Software Foundation; either version 2\r
- * of the License, or (at your option) any later version.\r
+ * This program is free software: you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation, either version 3 of the License, or\r
+ * (at your option) any later version.\r
* \r
* This program is distributed in the hope that it will be useful,\r
* but WITHOUT ANY WARRANTY; without even the implied warranty of\r
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
* GNU General Public License for more details.\r
- * \r
+ *\r
* You should have received a copy of the GNU General Public License\r
- * along with this framework; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.\r
* \r
* For further information please contact.\r
* http://nyatla.jp/nyatoolkit/\r
- * <airmail(at)ebony.plala.or.jp>\r
+ * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>\r
* \r
*/\r
package jp.nyatla.nyartoolkit.jogl.utils;\r
\r
-import javax.media.format.RGBFormat;\r
+\r
import javax.media.opengl.GL;\r
\r
import jp.nyatla.nyartoolkit.NyARException;\r
import jp.nyatla.nyartoolkit.jmf.utils.*;\r
import jp.nyatla.nyartoolkit.core.param.NyARParam;\r
-import jp.nyatla.nyartoolkit.core.rasterreader.*;\r
-\r
+import jp.nyatla.nyartoolkit.core.raster.*;\r
+import javax.media.format.*;\r
\r
/**\r
* NyARRaster_RGBにOpenGL用のデータ変換機能を追加したものです。\r
*/\r
public class GLNyARRaster_RGB extends JmfNyARRaster_RGB\r
{\r
- private byte[] _gl_buf;\r
-\r
private int _gl_flag;\r
-\r
- public GLNyARRaster_RGB(NyARParam i_param)\r
+ /**\r
+ * コンストラクタです。i_formatを取り込めるi_paramのサイズパラメタを持つ\r
+ * ラスタオブジェクトを作成します。\r
+ * @param i_param\r
+ * カメラパラメタを指定します。コンストラクタは、画面サイズ以外のパラメタを見ていません。\r
+ * @param i_format\r
+ * キャプチャ画像のピクセルフォーマットを指定します。\r
+ * @throws NyARException\r
+ */\r
+ public GLNyARRaster_RGB(NyARParam i_param,VideoFormat i_format) throws NyARException\r
{\r
- super(i_param.getScreenSize());\r
- this._gl_flag = GL.GL_RGB;\r
- this._gl_buf = new byte[this._size.w * this._size.h * 3];\r
+ super(i_param.getScreenSize(),i_format);\r
+ initMember(this.getBufferType());\r
+ return;\r
}\r
-\r
- public void setBuffer(javax.media.Buffer i_buffer, boolean i_is_reverse) throws NyARException\r
+ public GLNyARRaster_RGB(int i_width,int i_height,VideoFormat i_format) throws NyARException\r
{\r
- int buffer_type=analyzeBufferType((RGBFormat) i_buffer.getFormat());;\r
- byte[] src_buf = (byte[]) i_buffer.getData();\r
- // GL用のデータを準備\r
- if (i_is_reverse) {\r
- final int length = this._size.w * 3;\r
- int src_idx = 0;\r
- int dest_idx = (this._size.h - 1) * length; \r
- for (int i = 0; i < this._size.h; i++) {\r
- System.arraycopy(src_buf, src_idx, this._gl_buf, dest_idx, length);\r
- src_idx += length;\r
- dest_idx -= length;\r
- }\r
- } else {\r
- System.arraycopy(src_buf, 0, this._gl_buf, 0, src_buf.length);\r
- }\r
-\r
- // GLのフラグ設定\r
- switch (buffer_type) {\r
- case INyARBufferReader.BUFFERFORMAT_BYTE1D_B8G8R8_24:\r
+ super(i_width,i_height,i_format);\r
+ initMember(this.getBufferType());\r
+ return;\r
+ } \r
+ private void initMember(int i_buffer_type) throws NyARException\r
+ {\r
+ switch(i_buffer_type){\r
+ case NyARBufferType.BYTE1D_B8G8R8_24:\r
this._gl_flag = GL.GL_BGR;\r
break;\r
- case INyARBufferReader.BUFFERFORMAT_BYTE1D_R8G8B8_24:\r
+ case NyARBufferType.BYTE1D_R8G8B8_24:\r
this._gl_flag = GL.GL_RGB;\r
break;\r
default:\r
throw new NyARException();\r
}\r
- // ref_bufをgl_bufに差し替える\r
- this._ref_buf = this._gl_buf;\r
- this._reader.changeBuffer(buffer_type, this._ref_buf);\r
+ return;\r
}\r
-\r
/**\r
- * GLでそのまま描画できるRGBバッファを返す。\r
- * \r
+ * RGBバイト配列への参照値を返します。\r
+ * バッファの並び順は、getGLPixelFlagが返すデータ順で格納されています。\r
* @return\r
+ * RGBバイト配列の参照値です。\r
*/\r
public byte[] getGLRgbArray()\r
{\r
- return this._ref_buf;\r
+ return (byte[])this.getBuffer();\r
}\r
\r
/**\r
- * GL用のRGBバッファのバイト並びタイプを返す。\r
- * \r
+ * OpenGLの描画フラグを返します。\r
+ * この値は、RGBバッファのバイト並びタイプです。\r
* @return\r
+ * GL.GL_BGR等の、RGBバイト配列の形式を表す値です。\r
*/\r
public int getGLPixelFlag()\r
{\r
return this._gl_flag;\r
}\r
+\r
}\r