本文整理汇总了Java中com.jogamp.common.nio.Buffers类的典型用法代码示例。如果您正苦于以下问题:Java Buffers类的具体用法?Java Buffers怎么用?Java Buffers使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Buffers类属于com.jogamp.common.nio包,在下文中一共展示了Buffers类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import com.jogamp.common.nio.Buffers; //导入依赖的package包/类
@Override
public void init() {
if(init && GLOptions.USE_VBOS){
vertexBuffer = Buffers.newDirectDoubleBuffer(1024*8*size/4 * 3);
texCoordBuffer = Buffers.newDirectFloatBuffer(1024*8*size/4 * 2);
colorBuffer = Buffers.newDirectFloatBuffer(1024*8*size/4 * 4);
normalBuffer = Buffers.newDirectFloatBuffer(1024*8*size/4 * 3);
init= false;
}else{
if(GLOptions.USE_VBOS){
clear();
}
}
this.hasColor = false;
this.hasTexture = false;
this.hasNormals = false;
vertices = 0;
a=1;
if(!GLOptions.USE_VBOS){
gl.glBegin(mType);
}
}
示例2: init
import com.jogamp.common.nio.Buffers; //导入依赖的package包/类
@Override
public void init() {
if(init && GLOptions.USE_VBOS){
vertexBuffer = Buffers.newDirectDoubleBuffer(1024*size/ 3);
texCoordBuffer = Buffers.newDirectFloatBuffer(1024*size/ 2);
colorBuffer = Buffers.newDirectFloatBuffer(1024*size/ 4);
init= false;
}else{
if(GLOptions.USE_VBOS){
clear();
}
}
this.hasColor = false;
this.hasTexture = false;
vertices = 0;
a=1;
if(!GLOptions.USE_VBOS){
gl.glBegin(mType);
}
}
示例3: init
import com.jogamp.common.nio.Buffers; //导入依赖的package包/类
@Override
public void init() {
if(init && useVBOs){
vertexBuffer = Buffers.newDirectDoubleBuffer(1024*8*size/4 * 2);
texCoordBuffer = Buffers.newDirectFloatBuffer(1024*8*size/4 * 2);
colorBuffer = Buffers.newDirectFloatBuffer(1024*8*size);
init= false;
}else{
if(useVBOs){
clear();
}
}
this.hasColor = false;
this.hasTexture = false;
vertices = 0;
a=1;
if(!useVBOs){
gl.glBegin(mType);
}
}
示例4: init
import com.jogamp.common.nio.Buffers; //导入依赖的package包/类
@Override
public void init() {
if(GLOptions.USE_VBOS){
vertexBuffer = Buffers.newDirectFloatBuffer(1024*size/ 4);
texCoordBuffer = Buffers.newDirectFloatBuffer(1024*size/ 2);
colorBuffer = Buffers.newDirectFloatBuffer(1024*size/ 4);
}else{
if(GLOptions.USE_VBOS){
clear();
}
}
this.hasColor = false;
this.hasTexture = false;
vertices = 0;
a=1;
if(!GLOptions.USE_VBOS){
gl.glBegin(mType);
}
}
示例5: transform
import com.jogamp.common.nio.Buffers; //导入依赖的package包/类
private void transform() {
float[] val = new float[vertexBuffer.limit()];
vertexBuffer.get(val, 0, val.length);
float[] out = new float[val.length/4*3];
int ind = 0;
while(ind < val.length/4){
float[] o = transformV(val[ind*4], val[ind*4+1], val[ind*4+2], val[ind*4+3]);
for(int i = 0; i < o.length; i++){
out[ind*3+i] = o[i];
}
ind++;
}
this.vertexBuffer = Buffers.newDirectFloatBuffer(out);
}
示例6: init
import com.jogamp.common.nio.Buffers; //导入依赖的package包/类
@Override
public void init() {
if(init && GLOptions.USE_VBOS){
vertexBuffer = Buffers.newDirectFloatBuffer(1024*size/ 3);
texCoordBuffer = Buffers.newDirectFloatBuffer(1024*size/ 2);
colorBuffer = Buffers.newDirectFloatBuffer(1024*size/ 4);
init= false;
}else{
if(GLOptions.USE_VBOS){
clear();
}
}
this.hasColor = false;
this.hasTexture = false;
vertices = 0;
a=1;
if(!GLOptions.USE_VBOS){
gl.glBegin(mType);
}
}
示例7: init
import com.jogamp.common.nio.Buffers; //导入依赖的package包/类
@Override
public void init() {
if(init && useVBOs){
vertexBuffer = Buffers.newDirectFloatBuffer(1024*8*size/4 * 2);
texCoordBuffer = Buffers.newDirectFloatBuffer(1024*8*size/4 * 2);
colorBuffer = Buffers.newDirectFloatBuffer(1024*8*size);
init= false;
}else{
if(useVBOs){
clear();
}
}
this.hasColor = false;
this.hasTexture = false;
vertices = 0;
a=1;
if(!useVBOs){
gl.glBegin(mType);
}
}
示例8: init
import com.jogamp.common.nio.Buffers; //导入依赖的package包/类
@Override
public void init() {
if(init && GLOptions.USE_VBOS){
vertexBuffer = Buffers.newDirectFloatBuffer(1024*8*size/4 * 3);
texCoordBuffer = Buffers.newDirectFloatBuffer(1024*8*size/4 * 2);
colorBuffer = Buffers.newDirectFloatBuffer(1024*8*size/4 * 4);
normalBuffer = Buffers.newDirectFloatBuffer(1024*8*size/4 * 3);
init= false;
}else{
if(GLOptions.USE_VBOS){
clear();
}
}
this.hasColor = false;
this.hasTexture = false;
this.hasNormals = false;
vertices = 0;
a=1;
if(!GLOptions.USE_VBOS){
gl.glBegin(mType);
}
}
示例9: toImage
import com.jogamp.common.nio.Buffers; //导入依赖的package包/类
/**
* Turns gl to BufferedImage with fixed format
*
* @param gl
* @param w
* @param h
* @return
*/
protected BufferedImage toImage(GL2 gl, int w, int h) {
gl.glReadBuffer(GL.GL_FRONT); // or GL.GL_BACK
ByteBuffer glBB = Buffers.newDirectByteBuffer(4 * w * h);
gl.glReadPixels(0, 0, w, h, GL2.GL_BGRA, GL.GL_BYTE, glBB);
BufferedImage bi = new BufferedImage(w, h, BufferedImage.TYPE_INT_BGR);
int[] bd = ((DataBufferInt) bi.getRaster().getDataBuffer()).getData();
for (int y = 0; y < h; y++) {
for (int x = 0; x < w; x++) {
int b = 2 * glBB.get();
int g = 2 * glBB.get();
int r = 2 * glBB.get();
int a = glBB.get(); // not using
bd[(h - y - 1) * w + x] = (b << 16) | (g << 8) | r | 0xFF000000;
}
}
return bi;
}
示例10: initializeCrossline
import com.jogamp.common.nio.Buffers; //导入依赖的package包/类
private void initializeCrossline(DrawContext dc) {
DoubleBuffer verts = crossLine;
if (verts == null)
verts = Buffers.newDirectDoubleBuffer(points.size() * 3);
for (LatLon point : points)
{
double alt =
elevation + baseHeight * exageration * (yMax - yMin) * crossLinePercent;
Vec4 p1 =
dc.getGlobe().computePointFromPosition(point.getLatitude(), point.getLongitude(), alt);
verts.put(p1.x - referenceCenter.x);
verts.put(p1.y - referenceCenter.y);
verts.put(p1.z - referenceCenter.z);
}
this.crossLine = verts;
}
示例11: getDataBuffer
import com.jogamp.common.nio.Buffers; //导入依赖的package包/类
/**
* Get a buffer with all vertices of the SurfaceCompilation.
*
* @return A buffer with all vertices of the SurfaceCompilation.
*/
public FloatBuffer getDataBuffer() {
final List<Float> dataList = new ArrayList<>();
//Iterate over all vertices in the SurfaceCompilation.
for (IndexedVertex vertex : vertices) {
//And store all vertices' data in an ArrayList.
dataList.add(vertex.getVertex().getPositionA()[IND_X]);
dataList.add(vertex.getVertex().getPositionA()[IND_Y]);
dataList.add(vertex.getVertex().getPositionA()[IND_Z]);
dataList.add(vertex.getVertex().getNormalA()[IND_X]);
dataList.add(vertex.getVertex().getNormalA()[IND_Y]);
dataList.add(vertex.getVertex().getNormalA()[IND_Z]);
dataList.add(vertex.getVertex().getTextureA()[IND_X]);
dataList.add(vertex.getVertex().getTextureA()[IND_Y]);
dataList.add(vertex.getVertex().getTextureA()[IND_Z]);
}
final float[] dataArray = new float[dataList.size()];
//Convert the ArrayList into an array.
for (int i = 0; i < dataArray.length; i++) {
dataArray[i] = dataList.get(i);
}
//Deliver it in the form of a buffer.
return Buffers.newDirectFloatBuffer(dataArray);
}
示例12: getIndicesBuffers
import com.jogamp.common.nio.Buffers; //导入依赖的package包/类
/**
* Get a list of buffers with the indices of all vertices of all surfaces.
*
* @return A list of buffers with the indices of all vertices of all
* surfaces.
*/
public List<IntBuffer> getIndicesBuffers() {
final List<IntBuffer> indicesBufferList = new ArrayList<>();
//Iterate over the surfaces in the SurfaceCompilation.
for (Surface surface : surfaces) {
//Get the list of indices from the surface.
final List<Integer> indicesList = surface.getIndices();
final int[] indicesArray = new int[indicesList.size()];
//And convert it from an ArrayList to an array.
for (int i = 0; i < indicesArray.length; i++) {
indicesArray[i] = indicesList.get(i);
}
//Add it to the buffer list in the form of a buffer.
indicesBufferList.add(Buffers.newDirectIntBuffer(indicesArray));
}
return indicesBufferList;
}
示例13: setBlending
import com.jogamp.common.nio.Buffers; //导入依赖的package包/类
private Map<String, Object> setBlending() {
Map<String, Object> result = new HashMap<>();
GL2 gl = drawable.getGL().getGL2();
IntBuffer equation = Buffers.newDirectIntBuffer(1);
gl.glGetIntegerv(GL_BLEND_EQUATION, equation);
result.put("equation", equation);
IntBuffer sourceFactor = Buffers.newDirectIntBuffer(1);
gl.glGetIntegerv(GL_BLEND_SRC, sourceFactor);
result.put("sourceFactor", sourceFactor);
IntBuffer destinationFactor = Buffers.newDirectIntBuffer(1);
gl.glGetIntegerv(GL_BLEND_DST, destinationFactor);
result.put("destinationFactor", destinationFactor);
boolean enabled = gl.glIsEnabled(GL_BLEND);
result.put("enabled", enabled);
gl.glBlendFunc(GL_SRC_ALPHA, GL_ONE);
gl.glBlendEquation(GL_FUNC_ADD);
gl.glEnable(GL_BLEND);
return result;
}
示例14: linkProgram
import com.jogamp.common.nio.Buffers; //导入依赖的package包/类
final public boolean linkProgram(int programId) {
gl.glLinkProgram(programId);
// check state
IntBuffer linkStatus = IntBuffer.allocate(1);
gl.glGetProgramiv(programId, GL3.GL_LINK_STATUS, linkStatus);
while (linkStatus.remaining() > 0) {
int result = linkStatus.get();
if (result == 0) {
// get error
IntBuffer infoLogLengthBuffer = Buffers.newDirectIntBuffer(1);
ByteBuffer infoLogBuffer = Buffers.newDirectByteBuffer(2048);
gl.glGetProgramInfoLog(programId, infoLogBuffer.limit(), infoLogLengthBuffer, infoLogBuffer);
final byte[] infoLogBytes = new byte[infoLogLengthBuffer.get()];
infoLogBuffer.get(infoLogBytes);
String infoLogString = new String(infoLogBytes);
// be verbose
Console.println("[" + programId + "]: failed: " + infoLogString);
//
return false;
}
}
//
return true;
}
示例15: drawVBO
import com.jogamp.common.nio.Buffers; //导入依赖的package包/类
@Override
void drawVBO(GL2 gl) {
gl.glBindBuffer( GL.GL_ARRAY_BUFFER, bufferName);
gl.glEnableClientState( GL2.GL_VERTEX_ARRAY );
gl.glEnableClientState( GL2.GL_NORMAL_ARRAY );
gl.glEnableClientState( GL2.GL_TEXTURE_COORD_ARRAY);
gl.glNormalPointer(GL.GL_FLOAT, 8 * Buffers.SIZEOF_FLOAT, 0 );
gl.glTexCoordPointer( 2, GL.GL_FLOAT, 8 * Buffers.SIZEOF_FLOAT, 3 * Buffers.SIZEOF_FLOAT );
gl.glVertexPointer(3, GL.GL_FLOAT, 8 * Buffers.SIZEOF_FLOAT, 5 * Buffers.SIZEOF_FLOAT);
gl.glMultiDrawArrays(GL2.GL_TRIANGLE_STRIP, firstOffsets, 0, countOffsets, 0, 6);
gl.glDisableClientState( GL2.GL_VERTEX_ARRAY );
gl.glDisableClientState( GL2.GL_NORMAL_ARRAY );
gl.glDisableClientState( GL2.GL_TEXTURE_COORD_ARRAY);
// unbind buffer
gl.glBindBuffer( GL.GL_ARRAY_BUFFER, 0);
}