本文整理汇总了Java中com.jogamp.opengl.GL3类的典型用法代码示例。如果您正苦于以下问题:Java GL3类的具体用法?Java GL3怎么用?Java GL3使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GL3类属于com.jogamp.opengl包,在下文中一共展示了GL3类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import com.jogamp.opengl.GL3; //导入依赖的package包/类
@Override
public void init(GLAutoDrawable drawable) {
context = drawable.getContext();
GL3 gl = drawable.getGL().getGL3();
gl.setSwapInterval(0);
gl.glEnable(GL.GL_DEPTH_TEST);
log.info("GL Vendor: " + gl.glGetString(GL.GL_VENDOR));
log.info("GL Renderer: " + gl.glGetString(GL.GL_RENDERER));
log.info("GL Version: " + gl.glGetString(GL.GL_VERSION));
log.info("GLSL Version: " + gl.glGetString(GL2.GL_SHADING_LANGUAGE_VERSION));
log.debug("Changed context: " + context.getGLVersion());
ogl.setOgl(gl);
synchronized (contextWait) {
contextWait.notify();
}
}
示例2: assureBuffers
import com.jogamp.opengl.GL3; //导入依赖的package包/类
protected void assureBuffers(){
// VBO handles
if(HANDLE_vbo_idx[0] == 0) gl.glGenBuffers(1, HANDLE_vbo_idx, 0);
if(HANDLE_vbo_pos[0] == 0) gl.glGenBuffers(1, HANDLE_vbo_pos, 0);
if(HANDLE_vbo_col[0] == 0) gl.glGenBuffers(1, HANDLE_vbo_col, 0);
// if(HANDLE_vbo_vel[0] == 0) gl.glGenBuffers(1, HANDLE_vbo_vel, 0);
// if(HANDLE_vbo_con[0] == 0) gl.glGenBuffers(1, HANDLE_vbo_con, 0);
if(HANDLE_vbo_quad[0] == 0){
float[] quad = { -1,-1, -1,+1, +1,-1, +1,+1};
gl.glGenBuffers(1, HANDLE_vbo_quad, 0);
gl.glBindBuffer(GL3.GL_ARRAY_BUFFER, HANDLE_vbo_quad[0]);
gl.glBufferData(GL3.GL_ARRAY_BUFFER, quad.length * 4, FloatBuffer.wrap(quad), GL3.GL_STATIC_DRAW);
gl.glBindBuffer(GL3.GL_ARRAY_BUFFER, 0);
}
}
示例3: dispose
import com.jogamp.opengl.GL3; //导入依赖的package包/类
@Override
public void dispose(RenderContext context) {
GL3 gl = context.getDrawable().getGL().getGL3();
// delete buffer
int[] obj = {sprite, vao, vbo.handle};
gl.glDeleteTextures(1, obj, 0);
gl.glDeleteVertexArrays(1, obj, 1);
gl.glDeleteBuffers(1, obj, 2);
vao = -1;
vbo = null;
// delete shader
prog.dispose(gl);
}
示例4: initialize
import com.jogamp.opengl.GL3; //导入依赖的package包/类
@Override
public void initialize(RenderContext context) throws IOException, ShaderCompileException, ShaderLinkException {
this.context = context;
GL3 gl = context.getDrawable().getGL().getGL3();
tilecopy = context.getShaderManager().load(TILE_COPY_SHADER_SRC);
uTileCopyTransform = (UniformMat4f) tilecopy.getUniform("u_tilecopy");
uProjection = (UniformMat4f) context.getUniformManager().getGlobalUniform("u_projection");
uView = (UniformMat4f) context.getUniformManager().getGlobalUniform("u_view");
uViewScale = (Uniform1f) context.getUniformManager().getGlobalUniform("u_viewscale");
uViewport = (UniformVec4f) context.getUniformManager().getGlobalUniform("u_viewport");
UniformSampler2D uColorSampler = (UniformSampler2D) tilecopy.getUniform("u_color_sampler");
UniformSampler2D uDepthSampler = (UniformSampler2D) tilecopy.getUniform("u_depth_sampler");
uColorSampler.set(TEX_UNIT_TILE_COLOR);
uDepthSampler.set(TEX_UNIT_TILE_DEPTH);
quad = new TileQuad();
quad.initialize(gl);
}
示例5: dispose
import com.jogamp.opengl.GL3; //导入依赖的package包/类
/**
* Disposes this {@code TileBuffer}.
*
* @param context the context on which the tiles are displayed.
*/
void dispose(RenderContext context) {
if (fbo == -1) return;
GL3 gl = context.getDrawable().getGL().getGL3();
int[] obj = {fbo, color, depth};
// detach textures fron fbo
gl.glBindFramebuffer(GL3.GL_FRAMEBUFFER, fbo);
gl.glFramebufferTexture2D(GL3.GL_FRAMEBUFFER, GL3.GL_COLOR_ATTACHMENT0, GL3.GL_TEXTURE_2D, 0, 0);
gl.glFramebufferTexture2D(GL3.GL_FRAMEBUFFER, GL3.GL_DEPTH_ATTACHMENT, GL3.GL_TEXTURE_2D, 0, 0);
gl.glBindFramebuffer(GL3.GL_FRAMEBUFFER, 0);
// delete fbo and textrues
gl.glDeleteFramebuffers(1, obj, 0);
gl.glDeleteTextures(2, obj, 1);
fbo = -1;
color = -1;
depth = -1;
}
示例6: display
import com.jogamp.opengl.GL3; //导入依赖的package包/类
@Override
public void display(RenderContext context) {
GL3 gl = context.getDrawable().getGL().getGL3();
// enable blending
context.BlendMode.enable(gl);
context.BlendMode.setEquation(gl, GL3.GL_FUNC_ADD);
context.BlendMode.setFactors(gl, GL3.GL_SRC_ALPHA, GL3.GL_ONE_MINUS_SRC_ALPHA, GL3.GL_ONE,
GL3.GL_ONE_MINUS_SRC_ALPHA);
// set line style
try {
context.Lines.setLineSmoothEnabled(gl, true);
context.Lines.setLineSmoothHint(gl, GL3.GL_NICEST);
context.Lines.setLineWidth(gl, linewidth);
} catch (Throwable t) {
/* TODO: use proper line rendering
* Will throw on implementations that do not support the specified line settings.
* For now, we ignore those and use the default settings provided by the implementation.
*/
}
shader.bind(gl);
uColor.set(color);
mesh.display(context, vao);
}
示例7: disposeFrameBuffer
import com.jogamp.opengl.GL3; //导入依赖的package包/类
/**
* Disposes the frame-buffer used to store the rendered map.
*
* @param context the context on which this visualizer operates.
*/
private void disposeFrameBuffer(RenderContext context) {
if (backbuffer == null) return;
GL3 gl = context.getDrawable().getGL().getGL3();
int[] obj = {backbuffer.fbo, backbuffer.color, backbuffer.depth};
// detach textures
gl.glBindFramebuffer(GL3.GL_FRAMEBUFFER, backbuffer.fbo);
gl.glFramebufferTexture2D(GL3.GL_FRAMEBUFFER, GL3.GL_COLOR_ATTACHMENT0, GL3.GL_TEXTURE_2D, 0, 0);
gl.glFramebufferTexture2D(GL3.GL_FRAMEBUFFER, GL3.GL_DEPTH_ATTACHMENT, GL3.GL_TEXTURE_2D, 0, 0);
gl.glBindFramebuffer(GL3.GL_FRAMEBUFFER, 0);
// delete objects
gl.glDeleteFramebuffers(1, obj, 0);
gl.glDeleteTextures(2, obj, 1);
backbuffer = null;
// delete vao, shader
empty.dispose(gl);
fboCopyShader.dispose(gl);
}
示例8: info
import com.jogamp.opengl.GL3; //导入依赖的package包/类
void info(){
String txt_device = context.gl.glGetString(GL3.GL_RENDERER).trim().split("/")[0];
String txt_app = getClass().getSimpleName();
String txt_fps = String.format(Locale.ENGLISH, "[%s] [%s] [%d/%d] [%7.2f fps] [particles %,d] ",
txt_app, txt_device,
pg_canvas.width,
pg_canvas.height,
frameRate, particles.getCount()
);
fill(col_fg);
noStroke();
rect(0, height, 650, - 20);
fill(255,128,0);
text(txt_fps, 10, height-6);
surface.setTitle(txt_fps);
}
示例9: updateText
import com.jogamp.opengl.GL3; //导入依赖的package包/类
public void updateText(GL3 gl, VBO vbo, Observer observer){
ArrayList<Float> newVerts = new ArrayList<>();
if(observer.getSelectedBody() != null) {
String bodyStrings[] = observer.getSelectedBody().toString(observer).split("\n");
setFontSize(0.65f);
loadString(-0.995f, 1, bodyStrings[0], newVerts);
setFontSize(0.45f);
loadString(-0.995f, 1 - 0.07f, bodyStrings[1], newVerts);
loadString(-0.995f, 1 - 0.11f, bodyStrings[2], newVerts);
}
float verts[] = Utils.floatArrayList2FloatArray(newVerts);
vbo.update(gl, 4 * 9 * arrayStart, verts);
}
示例10: initShaders
import com.jogamp.opengl.GL3; //导入依赖的package包/类
/**
* Initialize the shaders and the shader program
*
* @param gl The GL context
*/
private void initShaders(GL3 gl)
{
shaderProgramID = gl.glCreateProgram();
int vertexShaderID = gl.glCreateShader(GL_VERTEX_SHADER);
gl.glShaderSource(vertexShaderID, 1,
new String[]{vertexShaderSource}, null);
gl.glCompileShader(vertexShaderID);
gl.glAttachShader(shaderProgramID, vertexShaderID);
gl.glDeleteShader(vertexShaderID);
int fragmentShaderID = gl.glCreateShader(GL_FRAGMENT_SHADER);
gl.glShaderSource(fragmentShaderID, 1,
new String[]{fragmentShaderSource}, null);
gl.glCompileShader(fragmentShaderID);
gl.glAttachShader(shaderProgramID, fragmentShaderID);
gl.glDeleteShader(fragmentShaderID);
gl.glLinkProgram(shaderProgramID);
gl.glValidateProgram(shaderProgramID);
}
示例11: Viereck
import com.jogamp.opengl.GL3; //导入依赖的package包/类
public void Viereck(GL3 gl, Vec3 A, Vec3 B, Vec3 C, Vec3 D,
Vec3 n) // Normale
{
vb.setNormal(n.x, n.y, n.z);
vb.putVertex(A.x, A.y, A.z); // Dreieck 1
vb.putVertex(B.x, B.y, B.z);
vb.putVertex(C.x, C.y, C.z);
vb.putVertex(C.x, C.y, C.z); // Dreieck 2
vb.putVertex(D.x, D.y, D.z);
vb.putVertex(A.x, A.y, A.z);
}
示例12: init
import com.jogamp.opengl.GL3; //导入依赖的package包/类
/**
* Sets up the screen.
*
* @see GLEventListener#init(GLAutoDrawable)
*/
@Override
public void init(GLAutoDrawable drawable) {
drawable.setGL(new DebugGL2((GL2) drawable.getGL()));
final GL2 gl = (GL2)drawable.getGL();
StatusPrinter.print("INFO", "--- Initializing OpenGL ", Canvas.class);
StatusPrinter.print("INFO", "OpenGL Vendor: " + gl.glGetString(GL2.GL_VENDOR), Canvas.class);
StatusPrinter.print("INFO", "OpenGL Version: " + gl.glGetString(GL2.GL_VERSION), Canvas.class);
StatusPrinter.print("INFO", "OpenGL Renderer: " + gl.glGetString(GL2.GL_RENDERER), Canvas.class);
StatusPrinter.print("INFO", "OpenGL Language Version " + gl.glGetString(GL2.GL_SHADING_LANGUAGE_VERSION), Canvas.class);
StatusPrinter.print("INFO", "OpenGL Extensions: " + gl.glGetString(GL2.GL_EXTENSIONS), Canvas.class);
animator = new FPSAnimator(this, 500);
animator.start();
GLComponent.gl = gl;
GLComponent.gl3 = (GL3)drawable.getGL();
GLComponent.glu = new GLU();
GLComponent.glut = new GLUT();
ALComponent.al = ALFactory.getAL();
try {
turret.preInit();
} catch (TextureException | ModelReaderObjException | ModelReader3dsException | IOException e) {
e.printStackTrace();
}
turret.init();
}
示例13: prepareRender
import com.jogamp.opengl.GL3; //导入依赖的package包/类
@Override
protected void prepareRender()
{
//gl = new TraceGL3(glComponent.getGL().getGL3(), System.out);
// The check whether this cast is valid was
// done during the initialization:
gl = (GL3)glComponent.getGL();
glContext.setGL(gl);
}
示例14: dispose
import com.jogamp.opengl.GL3; //导入依赖的package包/类
@Override
public void dispose(RenderContext context) throws Exception {
GL3 gl = context.getDrawable().getGL().getGL3();
if (this.shader != null)
this.shader.dispose(gl);
if (this.vao != null)
this.vao.dispose(gl);
if (this.mesh != null)
this.mesh.dispose(context);
}
示例15: generateConnectorMesh
import com.jogamp.opengl.GL3; //导入依赖的package包/类
private Mesh generateConnectorMesh(Graph graph) {
int restart = context.PrimitiveRestart.getIndex();
double lanewidth = config.visualization.style.getNormalizedStreetLaneWidth(19);
ArrayList<Vec2d> vertices = new ArrayList<>();
ArrayList<Integer> indices = new ArrayList<>();
for (Node node : graph.getNodes()) {
addConnectors(vertices, indices, restart, node, lanewidth);
}
FloatBuffer vb = FloatBuffer.allocate(vertices.size() * 2);
for (Vec2d v : vertices) {
vb.put((float) v.x);
vb.put((float) v.y);
}
vb.rewind();
IntBuffer ib = IntBuffer.allocate(indices.size());
for (int i : indices) {
ib.put(i);
}
ib.rewind();
int usage = GL3.GL_STATIC_DRAW;
int mode = GL3.GL_LINE_STRIP;
return SingleFloatAttributeIndexedMesh.newPos2Mesh(usage, mode, vb, ib);
}