本文整理汇总了Java中com.jogamp.common.nio.Buffers.newDirectIntBuffer方法的典型用法代码示例。如果您正苦于以下问题:Java Buffers.newDirectIntBuffer方法的具体用法?Java Buffers.newDirectIntBuffer怎么用?Java Buffers.newDirectIntBuffer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jogamp.common.nio.Buffers
的用法示例。
在下文中一共展示了Buffers.newDirectIntBuffer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: createPostprocessingSurface
import com.jogamp.common.nio.Buffers; //导入方法依赖的package包/类
public void createPostprocessingSurface(final int shaderNumber, final int textureID) {
final ArrayList<float[]> listVertices = new ArrayList<float[]>();
final ArrayList<float[]> listUvMapping = new ArrayList<float[]>();
listVertices.add(new float[] { -1, -1, 0, -1, 1, 0, 1, 1, 0, 1, -1, 0 });
listUvMapping.add(new float[] { 0, 0, 0, 1, 1, 1, 1, 0 });
// VERTICES POSITIONS BUFFER
storeDataInAttributeList(AbstractShader.POSITION_ATTRIBUTE_IDX, VERTICES_IDX, listVertices, shaderNumber);
// UV MAPPING (If a texture is defined)
storeDataInAttributeList(AbstractShader.UVMAPPING_ATTRIBUTE_IDX, UVMAPPING_IDX, listUvMapping, shaderNumber);
gl.glActiveTexture(GL.GL_TEXTURE0);
gl.glBindTexture(GL.GL_TEXTURE_2D, textureID);
// INDEX BUFFER
final int[] intIdxBuffer = new int[] { 0, 1, 2, 0, 2, 3 };
final IntBuffer ibIdxBuff = Buffers.newDirectIntBuffer(intIdxBuffer);
// Select the VBO, GPU memory data, to use for colors
gl.glBindBuffer(GL2.GL_ELEMENT_ARRAY_BUFFER, fboHandles[IDX_BUFF_IDX]);
final int numBytes = intIdxBuffer.length * 4;
gl.glBufferData(GL2.GL_ELEMENT_ARRAY_BUFFER, numBytes, ibIdxBuff, GL2.GL_STATIC_DRAW);
ibIdxBuff.rewind();
}
示例4: checkShaderLogInfo
import com.jogamp.common.nio.Buffers; //导入方法依赖的package包/类
public static void checkShaderLogInfo(GL2 inGL, int inShaderObjectID) {
IntBuffer tReturnValue = Buffers.newDirectIntBuffer(1);
inGL.glGetShaderiv(inShaderObjectID, GL2.GL_COMPILE_STATUS, tReturnValue);
if (tReturnValue.get(0) == GL.GL_FALSE) {
inGL.glGetShaderiv(inShaderObjectID, GL2.GL_INFO_LOG_LENGTH, tReturnValue);
final int length = tReturnValue.get(0);
String out = null;
if (length > 0) {
final ByteBuffer infoLog = Buffers.newDirectByteBuffer(length);
inGL.glGetShaderInfoLog(inShaderObjectID, infoLog.limit(), tReturnValue, infoLog);
final byte[] infoBytes = new byte[length];
infoLog.get(infoBytes);
out = new String(infoBytes);
System.out.print(out);
}
throw new GLException("Error during shader compilation:\n" + out + "\n");
}
}
示例5: checkProgramLogInfo
import com.jogamp.common.nio.Buffers; //导入方法依赖的package包/类
public static void checkProgramLogInfo(GL2 inGL, int inShaderObjectID) {
IntBuffer tReturnValue = Buffers.newDirectIntBuffer(1);
inGL.glGetProgramiv(inShaderObjectID, GL2.GL_LINK_STATUS, tReturnValue);
if (tReturnValue.get(0) == GL.GL_FALSE) {
inGL.glGetProgramiv(inShaderObjectID, GL2.GL_INFO_LOG_LENGTH, tReturnValue);
final int length = tReturnValue.get(0);
String out = null;
if (length > 0) {
final ByteBuffer infoLog = Buffers.newDirectByteBuffer(length);
inGL.glGetProgramInfoLog(inShaderObjectID, infoLog.limit(), tReturnValue, infoLog);
final byte[] infoBytes = new byte[length];
infoLog.get(infoBytes);
out = new String(infoBytes);
System.out.print(out);
}
throw new GLException("Error during shader linking:\n" + out + "\n");
}
}
示例6: stopPicking
import com.jogamp.common.nio.Buffers; //导入方法依赖的package包/类
public void stopPicking(GL2 gl) {
gl.glMatrixMode(GL2.GL_PROJECTION);
gl.glPopMatrix();
gl.glMatrixMode(GL2.GL_MODELVIEW);
gl.glFlush();
int hits = gl.glRenderMode(GL2.GL_RENDER);
if (hits != 0) {
System.out.println("HITS: " + hits);
selectBuffer.get(selectBuf);
processHits(hits, selectBuf);
selectBuf = new int[512];
selectBuffer = Buffers.newDirectIntBuffer(512);
} else {
fm.setSelection(-1, -1, -1);
}
}
示例7: display
import com.jogamp.common.nio.Buffers; //导入方法依赖的package包/类
public void display(GLAutoDrawable drawable)
{
GL2 gl = drawable.getGL().getGL2();
switch(cmd)
{
case UPDATE:
drawScene(gl);
break;
case SELECT:
int buffsize = 512;
double x = (double) mouse_x, y = (double) mouse_y;
int[] viewPort = new int[4];
IntBuffer selectBuffer = Buffers.newDirectIntBuffer(buffsize);
int hits = 0;
gl.glGetIntegerv(GL2.GL_VIEWPORT, viewPort, 0);
gl.glSelectBuffer(buffsize, selectBuffer);
gl.glRenderMode(GL2.GL_SELECT);
gl.glInitNames();
gl.glMatrixMode(GL2.GL_PROJECTION);
gl.glPushMatrix();
gl.glLoadIdentity();
glu.gluPickMatrix(x, (double) viewPort[3] - y, 5.0d, 5.0d, viewPort, 0);
glu.gluOrtho2D(0.0d, 1.0d, 0.0d, 1.0d);
drawScene(gl);
gl.glMatrixMode(GL2.GL_PROJECTION);
gl.glPopMatrix();
gl.glFlush();
hits = gl.glRenderMode(GL2.GL_RENDER);
processHits(hits, selectBuffer);
cmd = UPDATE;
break;
}
}
示例8: setIndexes
import com.jogamp.common.nio.Buffers; //导入方法依赖的package包/类
/**
*
* @param indices
*/
public final void setIndexes(final int[] indices) {
final IntBuffer buffer = Buffers.newDirectIntBuffer(indices.length);
buffer.put(indices);
buffer.rewind();
setBuffer(buffer);
}
示例9: ComparisonGLEventListener
import com.jogamp.common.nio.Buffers; //导入方法依赖的package包/类
public ComparisonGLEventListener() {
info = new ComparisonListenerInfo();
int[] z = {0};
this.zero = Buffers.newDirectIntBuffer(z);
/*models.add(null);
models.add(null);*/
info.getModels().add(null);
info.getModels().add(null);
}
示例10: updateCloud
import com.jogamp.common.nio.Buffers; //导入方法依赖的package包/类
@Override
public void updateCloud(PointCloud cloud) {
if (cloud != null) {
this.nbPoints = cloud.size();
if (this.nbPoints > 0) {
//init all arrays
int[] indiceArray = new int[cloud.size()];
float[] colorArray = new float[cloud.size() * 3];
float[] vertexArray = new float[cloud.size() * 3];
int i = 0;//indice index
int j = 0;//color and vertex index
//fill arrays
for (PointColor point : cloud.getPoints()) {
indiceArray[i] = i;
i++;
vertexArray[j] = point.getX();
colorArray[j] = (float) (point.getColor().getRed() / 255.0f);
j++;
vertexArray[j] = point.getY();
colorArray[j] = (float) (point.getColor().getGreen() / 255.0f);
j++;
vertexArray[j] = point.getZ();
colorArray[j] = (float) (point.getColor().getBlue() / 255.0f);
j++;
}
//fill buffer
this.vertex = Buffers.newDirectFloatBuffer(vertexArray);
this.color = Buffers.newDirectFloatBuffer(colorArray);
this.indice = Buffers.newDirectIntBuffer(indiceArray);
this.indiceCount = indiceArray.length;
}
}
}
示例11: linkProgram
import com.jogamp.common.nio.Buffers; //导入方法依赖的package包/类
final public boolean linkProgram(int programId) {
gl.glLinkProgramARB(programId);
// check state
IntBuffer linkStatus = IntBuffer.allocate(1);
gl.glGetProgramiv(programId, GL2.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;
}
示例12: 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, GLES2.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;
}
示例13: renderInit
import com.jogamp.common.nio.Buffers; //导入方法依赖的package包/类
/**
* Requests buffers from OpenGL to allow the vertex, normal, texCoord, and element buffers to
* be used when rendering. This must be called before {@code render}
* @param gl
*/
public void renderInit(GL3 gl) {
if (model == null) {
IntBuffer tempBuffer2 = Buffers.newDirectIntBuffer(1);
gl.glGenVertexArrays(1, tempBuffer2);
vertexArrayBufferPos = tempBuffer2.get(0);
IntBuffer tempBuffer = Buffers.newDirectIntBuffer(4);
gl.glGenBuffers(4, tempBuffer);
vertexBufferPos = tempBuffer.get(0);
normalBufferPos = tempBuffer.get(1);
texCoordBufferPos = tempBuffer.get(2);
elementBufferPos = tempBuffer.get(3);
gl.glBindVertexArray(vertexArrayBufferPos);
gl.glEnableVertexAttribArray(0);
gl.glEnableVertexAttribArray(1);
gl.glEnableVertexAttribArray(2);
gl.glBindBuffer(GL3.GL_ARRAY_BUFFER, vertexBufferPos);
gl.glBufferData(GL3.GL_ARRAY_BUFFER, vertexBuffer.capacity()*4, vertexBuffer, GL3.GL_STATIC_DRAW);
gl.glVertexAttribPointer(0, 3, GL3.GL_FLOAT, false, 0, 0);
gl.glBindBuffer(GL3.GL_ARRAY_BUFFER, normalBufferPos);
gl.glBufferData(GL3.GL_ARRAY_BUFFER, normalBuffer.capacity()*4, normalBuffer, GL3.GL_STATIC_DRAW);
gl.glVertexAttribPointer(1, 3, GL3.GL_FLOAT, false, 0, 0);
gl.glBindBuffer(GL3.GL_ARRAY_BUFFER, texCoordBufferPos);
gl.glBufferData(GL3.GL_ARRAY_BUFFER, texCoordBuffer.capacity()*4, texCoordBuffer, GL3.GL_STATIC_DRAW);
gl.glVertexAttribPointer(2, 2, GL3.GL_FLOAT, false, 0, 0);
gl.glBindBuffer(GL3.GL_ELEMENT_ARRAY_BUFFER, elementBufferPos);
gl.glBufferData(GL3.GL_ELEMENT_ARRAY_BUFFER, elementBuffer.capacity()*4, elementBuffer, GL3.GL_STATIC_DRAW);
gl.glBindBuffer(GL.GL_ELEMENT_ARRAY_BUFFER, 0);
gl.glBindVertexArray(0);
} else {
model.init(gl);
}
}
示例14: Mesh
import com.jogamp.common.nio.Buffers; //导入方法依赖的package包/类
public Mesh(float[] V, int[] F) {
//---
this.vertices = Buffers.newDirectFloatBuffer(V.length);
this.vertices.put(V);
this.vertices.rewind();
//---
this.faces = Buffers.newDirectIntBuffer(F.length);
this.faces.put(F);
this.faces.rewind();
}
示例15: load
import com.jogamp.common.nio.Buffers; //导入方法依赖的package包/类
@Override
public void load(GL2 gl)
throws IOException
{
IntBuffer handleBuffer = Buffers.newDirectIntBuffer(1);
gl.glGenTextures(1, handleBuffer);
handle = handleBuffer.get();
bind(gl);
}