2 * PROJECT: NyARToolkit JOGL utilities.
\r
3 * --------------------------------------------------------------------------------
\r
4 * This work is based on the original ARToolKit developed by
\r
7 * HITLab, University of Washington, Seattle
\r
8 * http://www.hitl.washington.edu/artoolkit/
\r
10 * The NyARToolkit is Java version ARToolkit class library.
\r
11 * Copyright (C)2008 R.Iizuka
\r
13 * This program is free software; you can redistribute it and/or
\r
14 * modify it under the terms of the GNU General Public License
\r
15 * as published by the Free Software Foundation; either version 2
\r
16 * of the License, or (at your option) any later version.
\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
23 * You should have received a copy of the GNU General Public License
\r
24 * along with this framework; if not, write to the Free Software
\r
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
\r
27 * For further information please contact.
\r
28 * http://nyatla.jp/nyatoolkit/
\r
29 * <airmail(at)ebony.plala.or.jp>
\r
32 package jp.nyatla.nyartoolkit.jogl.utils;
\r
34 import javax.media.format.RGBFormat;
\r
35 import javax.media.opengl.GL;
\r
37 import jp.nyatla.nyartoolkit.NyARException;
\r
38 import jp.nyatla.nyartoolkit.jmf.utils.*;
\r
39 import jp.nyatla.nyartoolkit.core.param.NyARParam;
\r
40 import jp.nyatla.nyartoolkit.core.rasterreader.*;
\r
44 * NyARRaster_RGBにOpenGL用のデータ変換機能を追加したものです。
\r
46 public class GLNyARRaster_RGB extends JmfNyARRaster_RGB
\r
48 private byte[] _gl_buf;
\r
50 private int _gl_flag;
\r
52 public GLNyARRaster_RGB(NyARParam i_param)
\r
54 super(i_param.getScreenSize());
\r
55 this._gl_flag = GL.GL_RGB;
\r
56 this._gl_buf = new byte[this._size.w * this._size.h * 3];
\r
59 public void setBuffer(javax.media.Buffer i_buffer, boolean i_is_reverse) throws NyARException
\r
61 int buffer_type=analyzeBufferType((RGBFormat) i_buffer.getFormat());;
\r
62 byte[] src_buf = (byte[]) i_buffer.getData();
\r
65 final int length = this._size.w * 3;
\r
67 int dest_idx = (this._size.h - 1) * length;
\r
68 for (int i = 0; i < this._size.h; i++) {
\r
69 System.arraycopy(src_buf, src_idx, this._gl_buf, dest_idx, length);
\r
74 System.arraycopy(src_buf, 0, this._gl_buf, 0, src_buf.length);
\r
78 switch (buffer_type) {
\r
79 case INyARBufferReader.BUFFERFORMAT_BYTE1D_B8G8R8_24:
\r
80 this._gl_flag = GL.GL_BGR;
\r
82 case INyARBufferReader.BUFFERFORMAT_BYTE1D_R8G8B8_24:
\r
83 this._gl_flag = GL.GL_RGB;
\r
86 throw new NyARException();
\r
88 // ref_bufをgl_bufに差し替える
\r
89 this._ref_buf = this._gl_buf;
\r
90 this._reader.changeBuffer(buffer_type, this._ref_buf);
\r
94 * GLでそのまま描画できるRGBバッファを返す。
\r
98 public byte[] getGLRgbArray()
\r
100 return this._ref_buf;
\r
104 * GL用のRGBバッファのバイト並びタイプを返す。
\r
108 public int getGLPixelFlag()
\r
110 return this._gl_flag;
\r