本文整理汇总了Java中com.sun.opengl.util.BufferUtil类的典型用法代码示例。如果您正苦于以下问题:Java BufferUtil类的具体用法?Java BufferUtil怎么用?Java BufferUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BufferUtil类属于com.sun.opengl.util包,在下文中一共展示了BufferUtil类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createFrameBufferObject
import com.sun.opengl.util.BufferUtil; //导入依赖的package包/类
private static void createFrameBufferObject(GL gl, int[] frameBuffer,
int[] colorBuffer, int width,
int height) {
gl.glGenFramebuffersEXT(1, frameBuffer, 0);
gl.glBindFramebufferEXT(GL.GL_FRAMEBUFFER_EXT, frameBuffer[0]);
gl.glGenTextures(1, colorBuffer, 0);
gl.glBindTexture(GL.GL_TEXTURE_2D, colorBuffer[0]);
gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_RGBA,
width, height,
0, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE,
BufferUtil.newByteBuffer(width * height * 4));
gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR);
gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR);
gl.glFramebufferTexture2DEXT(GL.GL_FRAMEBUFFER_EXT,
GL.GL_COLOR_ATTACHMENT0_EXT,
GL.GL_TEXTURE_2D, colorBuffer[0], 0);
gl.glBindTexture(GL.GL_TEXTURE_2D, 0);
int status = gl.glCheckFramebufferStatusEXT(GL.GL_FRAMEBUFFER_EXT);
if (status == GL.GL_FRAMEBUFFER_COMPLETE_EXT) {
gl.glBindFramebufferEXT(GL.GL_FRAMEBUFFER_EXT, 0);
} else {
throw new IllegalStateException("Frame Buffer Oject not created.");
}
}
示例2: VertexArray
import com.sun.opengl.util.BufferUtil; //导入依赖的package包/类
public VertexArray( int capacity, int coord_size, int col_size, int tex_size )
{
v_buf = BufferUtil.newFloatBuffer( coord_size * capacity );
c_buf = BufferUtil.newFloatBuffer( col_size * capacity );
t_buf = BufferUtil.newFloatBuffer( tex_size * capacity );
if( col_size > 0 )
this.has_color = true;
if( tex_size > 0 )
this.has_tex = true;
this.coord_size = coord_size;
this.col_size = col_size;
this.tex_size = tex_size;
}
示例3: transferStreamToByteBuffer
import com.sun.opengl.util.BufferUtil; //导入依赖的package包/类
private static ByteBuffer transferStreamToByteBuffer(InputStream stream, int numBytes) throws IOException
{
if (stream == null)
{
String message = Logging.getMessage("nullValue.InputStreamIsNull");
Logging.logger().severe(message);
throw new IllegalArgumentException(message);
}
if (numBytes < 1)
{
Logging.logger().severe("WWIO.NumberBytesTransferLessThanOne");
throw new IllegalArgumentException(Logging.getMessage("WWIO.NumberBytesTransferLessThanOne"));
}
int bytesRead = 0;
int count = 0;
byte[] bytes = new byte[numBytes];
while (count >= 0 && (numBytes - bytesRead) > 0)
{
count = stream.read(bytes, bytesRead, numBytes - bytesRead);
if (count > 0)
{
bytesRead += count;
}
}
ByteBuffer buffer = BufferUtil.newByteBuffer(bytes.length); // to get a jogl-compatible buffer
return buffer.put(bytes);
}
示例4: VertexBufferObject
import com.sun.opengl.util.BufferUtil; //导入依赖的package包/类
public VertexBufferObject(DreiDeEsObject obj) {
// System.out.println("FOO1");
vertexe = BufferUtil.newFloatBuffer(obj.faceCount * 9 + 9);
// System.out.println("FOO2");
float v[] = new float[obj.faceCount * 9];
// System.out.println("FOO3");
int pos = 0;
// System.out.println("FOO FacCount " + obj.faceCount);
for (int i = 0; i < obj.faceCount; i++) {
// System.out.println("FACE "+ i + " von " + obj.faceCount);
// System.out.println("POS " + pos);
for (int f = 0; f < 3; f++) {
float x = obj.vertexe[obj.faces[i][f]][0] * 30;
float y = obj.vertexe[obj.faces[i][f]][1] * 30;
float z = obj.vertexe[obj.faces[i][f]][2] * 30;
v[pos++] = x;
v[pos++] = y;
v[pos++] = z;
}
// System.out.println("FOO " + pos);
}
// System.out.println("FOOXi");
vertexe.put(v);
// System.out.println("FOOX");
fVertexe = v;
}
示例5: ParticleSystem
import com.sun.opengl.util.BufferUtil; //导入依赖的package包/类
ParticleSystem(OpenPoolExampleWithFluids ope, int numParticles) {
particles = new Particle[numParticles];
for (int i = 0; i < numParticles; i++) {
particles[i] = new Particle(ope);
}
particleIndex = 0;
// 2 coordinates per point, 2 points per particle (current and previous)
positions = BufferUtil.newFloatBuffer(particles.length * 2 * 2);
// 3 parameters per point, 2 colors per particle (current and previous)
colors = BufferUtil.newFloatBuffer(particles.length * 3 * 2);
}
示例6: ParticleSystem
import com.sun.opengl.util.BufferUtil; //导入依赖的package包/类
ParticleSystem(OpenPoolExampleWithFluids ope, int numParticles) {
particles = new Particle[numParticles];
for (int i = 0; i < numParticles; i++) {
particles[i] = new Particle(ope);
}
particleIndex = 0;
// 2 coordinates per point, 2 points per particle (current and previous)
positions = BufferUtil.newFloatBuffer(particles.length * 2 * 2);
// 3 parameters per point, 2 colors per particle (current and previous)
colors = BufferUtil.newFloatBuffer(particles.length * 3 * 2);
}
示例7: addToProfile
import com.sun.opengl.util.BufferUtil; //导入依赖的package包/类
private synchronized void addToProfile(double lon1, double lat1, double lon2, double lat2,
double step_len, double line_h,
Ellipsoid.DistAz daz, Ellipsoid.LatLonAz llaz, Point3d p3d) {
daz = navigator.getGlobe().getEllipsoid().inverseGeodesic(lat1, lon1, lat2, lon2, daz);
if (line_buffer.remaining() <= 3*(2+(int)Math.ceil(daz.dist/step_len))) {
FloatBuffer tmp = BufferUtil.newFloatBuffer(line_buffer.capacity()*2 + 3*(2+(int)Math.ceil(daz.dist/step_len)));
tmp.put(line_buffer);
line_buffer = tmp;
}
navigator.getGlobe().getEllipsoid().toCartesian(lat1, lon1, navigator.getGlobe().getElevation(lon1, lat1)+line_h, p3d);
p3d.sub(navigator.getOrigin());
line_buffer.put((float)p3d.x);
line_buffer.put((float)p3d.y);
line_buffer.put((float)p3d.z);
double lat = lat1;
double lon = lon1;
while (daz.dist > step_len) {
llaz = navigator.getGlobe().getEllipsoid().forwGeodesic(lat, lon, step_len, daz.az12, llaz);
lat = llaz.lat;
lon = llaz.lon;
navigator.getGlobe().getEllipsoid().toCartesian(lat, lon, navigator.getGlobe().getElevation(lon, lat)+line_h, p3d);
p3d.sub(navigator.getOrigin());
line_buffer.put((float)p3d.x);
line_buffer.put((float)p3d.y);
line_buffer.put((float)p3d.z);
daz = navigator.getGlobe().getEllipsoid().inverseGeodesic(lat, lon, lat2, lon2, daz);
}
navigator.getGlobe().getEllipsoid().toCartesian(lat2, lon2, navigator.getGlobe().getElevation(lon2, lat2)+line_h, p3d);
p3d.sub(navigator.getOrigin());
line_buffer.put((float)p3d.x);
line_buffer.put((float)p3d.y);
line_buffer.put((float)p3d.z);
}
示例8: InterleavedVertexArray
import com.sun.opengl.util.BufferUtil; //导入依赖的package包/类
public InterleavedVertexArray( int capacity, int format )
{
switch( format )
{
case GL.GL_V2F:
coord_size = 2;
break;
case GL.GL_V3F:
coord_size = 3;
break;
case GL.GL_C3F_V3F:
coord_size = 3;
col_size = 3;
break;
case GL.GL_N3F_V3F:
coord_size = 3;
nor_size = 3;
break;
case GL.GL_C4F_N3F_V3F:
coord_size = 3;
col_size = 4;
nor_size = 3;
break;
case GL.GL_T2F_V3F:
coord_size = 3;
tex_size = 2;
break;
case GL.GL_T4F_V4F:
coord_size = 4;
tex_size = 4;
break;
case GL.GL_T2F_C3F_V3F:
coord_size = 3;
col_size = 3;
tex_size = 2;
break;
case GL.GL_T2F_N3F_V3F:
coord_size = 3;
nor_size = 3;
tex_size = 2;
break;
case GL.GL_T2F_C4F_N3F_V3F:
coord_size = 3;
nor_size = 3;
col_size = 4;
tex_size = 2;
break;
case GL.GL_T4F_C4F_N3F_V4F:
coord_size = 4;
nor_size = 3;
col_size = 4;
tex_size = 4;
break;
default:
throw new RuntimeException( "unsupported vertex format" );
}
buf = BufferUtil.newFloatBuffer( ( coord_size + col_size + tex_size + nor_size ) * capacity );
this.format = format;
if( tex_size > 0 )
has_tex = true;
}
示例9: getBuffer
import com.sun.opengl.util.BufferUtil; //导入依赖的package包/类
private FloatBuffer getBuffer(int a_floats)
{
return BufferUtil.newFloatBuffer( a_floats );
}