List of usage examples for org.lwjgl.opengl GL11 glDrawArrays
public static void glDrawArrays(@NativeType("GLenum") int mode, @NativeType("GLint") int first, @NativeType("GLsizei") int count)
From source file:illarion.graphics.lwjgl.DrawerLWJGL.java
License:Open Source License
/** * Draw a triangle that is filled with the color that is set as parameter. * //from ww w.j ava2 s .c o m * @param x1 x coordinate of the first corner of the triangle * @param y1 y coordinate of the first corner of the triangle * @param x2 x coordinate of the second corner of the triangle * @param y2 y coordinate of the second corner of the triangle * @param x3 x coordinate of the third corner of the triangle * @param y3 y coordinate of the third corner of the triangle * @param color color the color the triangle is filled with * @see illarion.graphics.Drawer#drawTriangle(int, int, int, int, int, int, * SpriteColor) */ @Override public void drawTriangle(final int x1, final int y1, final int x2, final int y2, final int x3, final int y3, final SpriteColor color) { DriverSettingsLWJGL.getInstance().enableDrawOther(); color.setActiveColor(); buffer.clear(); buffer.put(x1).put(y1); buffer.put(x2).put(y2); buffer.put(x3).put(y3); buffer.flip(); GL11.glVertexPointer(2, 0, buffer); GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, 3); }
From source file:illarion.graphics.lwjgl.DrawerLWJGL.java
License:Open Source License
/** * Draw a triangle stripe using a set of coordinates from the buffer. * //from w w w . j av a 2 s .co m * @param coords the float buffer that contains the coordinates to draw * @param color the sprite color that is used to draw the triangle stripe */ @Override public void drawTriangles(final FloatBuffer coords, final SpriteColor color) { DriverSettingsLWJGL.getInstance().enableDrawOther(); color.setActiveColor(); GL11.glVertexPointer(2, 0, coords); GL11.glDrawArrays(GL11.GL_TRIANGLE_STRIP, 0, coords.remaining() >> 1); }
From source file:illarion.graphics.lwjgl.render.TextureRenderPointer.java
License:Open Source License
/** * Draw a texture using buffer pointers and draw arrays. * /* w w w . j av a 2 s .c o m*/ * @param x the x coordinate of the texture * @param y the y coordinate of the texture * @param z the z coordinate (so the layer) of the texture * @param width the width of the area the texture shall be rendered on * @param height the height of the area the texture shall be rendered on * @param texture the texture that shall be drawn * @param color the color that is supposed to be used with that texture * @param mirror mirror the texture horizontal * @param rotation the value the texture is rotated by */ @Override public void drawTexture(final float x, final float y, final float z, final float width, final float height, final TextureLWJGL texture, final SpriteColor color, final boolean mirror, final float rotation) { DriverSettingsLWJGL.getInstance().enableTexturePointer(texture.getTextureID()); color.setActiveColor(); GL11.glPushMatrix(); int xmod = 1; if (mirror) { xmod = -1; GL11.glTranslatef(x + width, y, z); } else { GL11.glTranslatef(x, y, z); } GL11.glScalef(width * xmod, height, 1.f); GL11.glTranslatef(0.5f, 0.5f, 0); if (rotation != 0.f) { GL11.glRotatef(rotation, 0, 0, 1); } textureBuffer.rewind(); textureBuffer.put(texture.getRelX1()).put(texture.getRelY2()); textureBuffer.put(texture.getRelX1()).put(texture.getRelY1()); textureBuffer.put(texture.getRelX2()).put(texture.getRelY2()); textureBuffer.put(texture.getRelX2()).put(texture.getRelY1()); textureBuffer.flip(); GL11.glTexCoordPointer(2, 0, textureBuffer); GL11.glVertexPointer(2, 0, vertexBuffer); GL11.glDrawArrays(GL11.GL_TRIANGLE_STRIP, 0, 4); GL11.glPopMatrix(); }
From source file:im.bci.jnuit.lwjgl.sprite.SpriteBatcher.java
License:Open Source License
private void flush() { if (currentSpriteInBatch > 0) { boolean hasAlpha = true; if (hasAlpha) { GL11.glEnable(GL11.GL_BLEND); }//from ww w .j a va2 s . c o m texCoords.flip(); vertices.flip(); GL11.glBindTexture(GL11.GL_TEXTURE_2D, (Integer) currentImage.getId()); GL11.glTexCoordPointer(2, 0, texCoords); GL11.glVertexPointer(2, 0, vertices); GL11.glColor4ub(currentColor.getRedByte(), currentColor.getGreenByte(), currentColor.getBlueByte(), currentColor.getAlphaByte()); GL11.glDrawArrays(GL11.GL_QUADS, 0, currentSpriteInBatch * 4); if (hasAlpha) { GL11.glDisable(GL11.GL_BLEND); } GL11.glColor3f(1f, 1f, 1f); texCoords.rewind(); texCoords.limit(texCoords.capacity()); vertices.rewind(); vertices.limit(texCoords.capacity()); currentSpriteInBatch = 0; } }
From source file:io.root.gfx.glutils.GL.java
License:Apache License
public static void glDrawArrays(int mode, int first, int count) { GL11.glDrawArrays(mode, first, count); }
From source file:ion2d.INSprite.java
License:Open Source License
/** * Draws the sprite//from w w w . ja va2s .co m * Only used if self rendering */ public void draw() { //If the sprite is using a sprite sheet then do not draw via //The sprite and let the sprite sheet handle the drawing instead if (this.useSpriteSheet) return; //This is pretty obvious, if the sprite isn't visible then //Do not draw the sprite! if (!this.visible) return; //If the sprites quad is off the screen there is no point in //Drawing the sprite if (this.isQuadOffScreen(this.quad)) return; boolean newBlend = false; if (this.blend.source != GL11.GL_SRC_ALPHA || this.blend.destination != GL11.GL_ONE_MINUS_SRC_ALPHA) { newBlend = true; GL11.glBlendFunc(this.blend.source, this.blend.destination); } this.texture.bind(); this.updateColorBuffer(); this.updateTextureBuffer(); this.updateVertexBuffer(); //Color GL11.glColorPointer(4, 0, this.colorBuffer); //Texture GL11.glTexCoordPointer(2, 0, this.textureBuffer); //Vertex GL11.glVertexPointer(3, 0, this.verticeBuffer); GL11.glDrawArrays(GL11.GL_QUADS, 0, 4); if (newBlend) { GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); } }
From source file:ion2d.INTextureAtlas.java
License:Open Source License
/** * Draws only the visible quads on screen *//*from ww w . ja va 2 s . c o m*/ public void drawQuads() { if (this.totalVisible == 0 || this.totalQuads == 0) return; //GL11.glDisableClientState(GL11.GL_COLOR_ARRAY); //GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY); this.texture.bind(); this.vertices.rewind(); this.colorCoordinates.rewind(); this.textureCoordinates.rewind(); GL11.glColorPointer(4, 0, this.colorCoordinates); GL11.glTexCoordPointer(2, 0, this.textureCoordinates); GL11.glVertexPointer(3, 0, this.vertices); GL11.glDrawArrays(GL11.GL_QUADS, 0, this.totalVisible * 4); //GL11.glEnableClientState(GL11.GL_COLOR_ARRAY); //GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY); }
From source file:itdelatrisu.opsu.render.CurveRenderState.java
License:Open Source License
/** * Do the actual drawing of the curve into the currently bound framebuffer. * @param color the color of the curve//from w ww. ja va 2 s.c o m * @param borderColor the curve border color * @param curve the points along the curve */ private void draw_curve(Color color, Color borderColor, Vec2f[] curve) { staticState.initGradient(); RenderState state = startRender(); int vtx_buf; // the size is: floatsize * (position + texture coordinates) * (number of cones) * (vertices in a cone) FloatBuffer buff = BufferUtils .createByteBuffer(4 * (4 + 2) * (2 * curve.length - 1) * (NewCurveStyleState.DIVIDES + 2)) .asFloatBuffer(); staticState.initShaderProgram(); vtx_buf = GL15.glGenBuffers(); for (int i = 0; i < curve.length; ++i) { float x = curve[i].x; float y = curve[i].y; //if (i == 0 || i == curve.length - 1){ fillCone(buff, x, y, NewCurveStyleState.DIVIDES); if (i != 0) { float last_x = curve[i - 1].x; float last_y = curve[i - 1].y; double diff_x = x - last_x; double diff_y = y - last_y; x = (float) (x - diff_x / 2); y = (float) (y - diff_y / 2); fillCone(buff, x, y, NewCurveStyleState.DIVIDES); } } buff.flip(); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vtx_buf); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, buff, GL15.GL_STATIC_DRAW); GL20.glUseProgram(staticState.program); GL20.glEnableVertexAttribArray(staticState.attribLoc); GL20.glEnableVertexAttribArray(staticState.texCoordLoc); GL20.glUniform1i(staticState.texLoc, 0); GL20.glUniform3f(staticState.colLoc, color.r, color.g, color.b); GL20.glUniform4f(staticState.colBorderLoc, borderColor.r, borderColor.g, borderColor.b, borderColor.a); //stride is 6*4 for the floats (4 bytes) (u,v)(x,y,z,w) //2*4 is for skipping the first 2 floats (u,v) GL20.glVertexAttribPointer(staticState.attribLoc, 4, GL11.GL_FLOAT, false, 6 * 4, 2 * 4); GL20.glVertexAttribPointer(staticState.texCoordLoc, 2, GL11.GL_FLOAT, false, 6 * 4, 0); for (int i = 0; i < curve.length * 2 - 1; ++i) GL11.glDrawArrays(GL11.GL_TRIANGLE_FAN, i * (NewCurveStyleState.DIVIDES + 2), NewCurveStyleState.DIVIDES + 2); GL20.glDisableVertexAttribArray(staticState.texCoordLoc); GL20.glDisableVertexAttribArray(staticState.attribLoc); GL15.glDeleteBuffers(vtx_buf); endRender(state); }
From source file:jpcsp.graphics.RE.RenderingEngineLwjgl.java
License:Open Source License
@Override public void drawArrays(int primitive, int first, int count) { GL11.glDrawArrays(primitiveToGL[primitive], first, count); }
From source file:kuake2.render.lwjgl.Main.java
License:Open Source License
/** * R_DrawParticles//from w w w .j ava 2 s. c o m */ void R_DrawParticles() { if (gl_ext_pointparameters.value != 0.0f && qglPointParameterfEXT) { //GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); GL11.glVertexPointer(3, 0, particle_t.vertexArray); GL11.glEnableClientState(GL11.GL_COLOR_ARRAY); GL11.glColorPointer(4, true, 0, particle_t.getColorAsByteBuffer()); GL11.glDepthMask(false); GL11.glEnable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glPointSize(gl_particle_size.value); GL11.glDrawArrays(GL11.GL_POINTS, 0, r_newrefdef.num_particles); GL11.glDisableClientState(GL11.GL_COLOR_ARRAY); //GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY); GL11.glDisable(GL11.GL_BLEND); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glDepthMask(true); GL11.glEnable(GL11.GL_TEXTURE_2D); } else { GL_DrawParticles(r_newrefdef.num_particles); } }