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:go.graphics.swing.opengl.LWJGLDrawContext.java
License:Open Source License
@Override public void drawTrianglesWithTextureColored(TextureHandle texture, GeometryHandle geometry, int triangleCount) throws IllegalBufferException { if (canUseVBOs) { bindTexture(texture);/*from ww w . j ava2 s . co m*/ bindArrayBuffer(geometry); GL11.glVertexPointer(3, GL11.GL_FLOAT, 6 * 4, 0); GL11.glTexCoordPointer(2, GL11.GL_FLOAT, 6 * 4, 3 * 4); GL11.glColorPointer(4, GL11.GL_UNSIGNED_BYTE, 6 * 4, 5 * 4); GL11.glEnableClientState(GL11.GL_COLOR_ARRAY); GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, triangleCount * 3); GL11.glDisableClientState(GL11.GL_COLOR_ARRAY); bindArrayBuffer(null); } else { ByteBuffer buffer = getGeometryBuffer(geometry); drawTrianglesWithTextureColored(texture, buffer, buffer.remaining() / 4 / 5); } }
From source file:gui.lwjgl.GUIRenderer.java
@Override public void render(GUIRenderable element) { GL30.glBindVertexArray(element.getGUIElement().getVaoID()); GL20.glEnableVertexAttribArray(VERTEX_POSITIONS); GL20.glEnableVertexAttribArray(TEXTURE_COORDS); Matrix4f transformationMatrix = Maths.createTransformationMatrix( new Vector2f(((2.0f * element.getGUIElement().getPosition().x) / Display.getWidth() - 1), -1 * ((2.0f * element.getGUIElement().getPosition().y) / Display.getHeight()) + 1f), element.getGUIElement().getRotation(), element.getGUIElement().getWidth() / (float) (Display.getWidth() / 2), element.getGUIElement().getHeight() / (float) (Display.getHeight() / 2)); this.loadUniformMatrix("transformationMatrix", transformationMatrix); GL13.glActiveTexture(GL13.GL_TEXTURE0); GL11.glBindTexture(GL11.GL_TEXTURE_2D, element.getGUIElement().getTexture().getTextureID()); GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, 6); GL20.glDisableVertexAttribArray(VERTEX_POSITIONS); GL20.glDisableVertexAttribArray(TEXTURE_COORDS); GL30.glBindVertexArray(0);/*from ww w. ja va 2 s . c o m*/ }
From source file:illarion.graphics.lwjgl.DrawerLWJGL.java
License:Open Source License
/** * Draw a simple dot at a specified location on the screen. * //from w w w. ja v a2 s . c o m * @param x x coordinate of the dot on the screen * @param y y coordinate of the dot on the screen * @param size size of the dot on the screen * @param color color of the dot on the screen */ @Override public void drawDot(final int x, final int y, final float size, final SpriteColor color) { DriverSettingsLWJGL.getInstance().enableDrawDot(); GL11.glPointSize(size / 2); color.setActiveColor(); buffer.clear(); buffer.put(x).put(y); buffer.flip(); GL11.glVertexPointer(2, 0, buffer); GL11.glDrawArrays(GL11.GL_POINTS, 0, 1); }
From source file:illarion.graphics.lwjgl.DrawerLWJGL.java
License:Open Source License
/** * Draw a line between two points with a specified width and color. * /*from ww w . java2s .c o m*/ * @param x1 the x coordinate of the first point on the screen * @param y1 the y coordinate of the first point on the screen * @param x2 the x coordinate of the second point on the screen * @param y2 the y coordinate of the second point on the screen * @param width the width of the line * @param color the color of the line */ @Override public void drawLine(final int x1, final int y1, final int x2, final int y2, final float width, final SpriteColor color) { DriverSettingsLWJGL.getInstance().enableDrawLine(); GL11.glLineWidth(width); color.setActiveColor(); buffer.clear(); buffer.put(x1).put(y1); buffer.put(x2).put(y2); buffer.flip(); GL11.glVertexPointer(2, 0, buffer); GL11.glDrawArrays(GL11.GL_LINES, 0, 2); }
From source file:illarion.graphics.lwjgl.DrawerLWJGL.java
License:Open Source License
/** * Draw a quadrangle that is filled with the color set with the parameter. * This function offers the possibility to create a irregular shaped * quadrangle since all 4 dots can be set separately. * /* w w w. j a v a2 s .c o m*/ * @param x1 the x coordinate of the first corner of the quadrangle * @param y1 the y coordinate of the first corner of the quadrangle * @param x2 the x coordinate of the second corner of the quadrangle * @param y2 the y coordinate of the second corner of the quadrangle * @param x3 the x coordinate of the third corner of the quadrangle * @param y3 the y coordinate of the third corner of the quadrangle * @param x4 the x coordinate of the fourth corner of the quadrangle * @param y4 the y coordinate of the fourth corner of the quadrangle * @param color color the color the quadrangle is filled with * @see illarion.graphics.Drawer#drawQuadrangle(int, int, int, int, int, * int, int, int, SpriteColor) */ @Override public void drawQuadrangle(final int x1, final int y1, final int x2, final int y2, final int x3, final int y3, final int x4, final int y4, final SpriteColor color) { DriverSettingsLWJGL.getInstance().enableDrawPoly(); color.setActiveColor(); buffer.clear(); buffer.put(x1).put(y1); buffer.put(x2).put(y2); buffer.put(x3).put(y3); buffer.put(x4).put(y4); buffer.flip(); GL11.glVertexPointer(2, 0, buffer); GL11.glDrawArrays(GL11.GL_QUADS, 0, 4); }
From source file:illarion.graphics.lwjgl.DrawerLWJGL.java
License:Open Source License
/** * Draw a quadrangle frame. This function offers the possibility to create a * irregular shaped quadrangle since all 4 dots can be set separately. * //from ww w . j a v a2 s . c o m * @param x1 the x coordinate of the first corner of the quadrangle * @param y1 the y coordinate of the first corner of the quadrangle * @param x2 the x coordinate of the second corner of the quadrangle * @param y2 the y coordinate of the second corner of the quadrangle * @param x3 the x coordinate of the third corner of the quadrangle * @param y3 the y coordinate of the third corner of the quadrangle * @param x4 the x coordinate of the fourth corner of the quadrangle * @param y4 the y coordinate of the fourth corner of the quadrangle * @param color color the color the quadrangle line is drawn iwth */ @Override public void drawQuadrangleFrame(final int x1, final int y1, final int x2, final int y2, final int x3, final int y3, final int x4, final int y4, final SpriteColor color) { DriverSettingsLWJGL.getInstance().enableDrawPoly(); color.setActiveColor(); buffer.clear(); buffer.put(x1).put(y1); buffer.put(x2).put(y2); buffer.put(x3).put(y3); buffer.put(x4).put(y4); buffer.flip(); GL11.glVertexPointer(2, 0, buffer); GL11.glDrawArrays(GL11.GL_LINE_LOOP, 0, 4); }
From source file:illarion.graphics.lwjgl.DrawerLWJGL.java
License:Open Source License
/** * Draw a rectangle that is filled with the color that is set as parameter. * // w ww .j a v a2 s. c o m * @param x1 x coordinate of the first corner of the rectangle * @param y1 y coordinate of the first corner of the rectangle * @param x2 x coordinate of the second corner of the rectangle * @param y2 y coordinate of the second corner of the rectangle * @param color the color the rectangle is filled with * @see illarion.graphics.Drawer#drawRectangle(int, int, int, int, * SpriteColor) */ @Override public void drawRectangle(final int x1, final int y1, final int x2, final int y2, final SpriteColor color) { DriverSettingsLWJGL.getInstance().enableDrawOther(); color.setActiveColor(); buffer.clear(); buffer.put(x1).put(y1); buffer.put(x1).put(y2); buffer.put(x2).put(y1); buffer.put(x2).put(y2); buffer.flip(); GL11.glVertexPointer(2, 0, buffer); GL11.glDrawArrays(GL11.GL_TRIANGLE_STRIP, 0, 4); }
From source file:illarion.graphics.lwjgl.DrawerLWJGL.java
License:Open Source License
/** * Draw a rectangle that is not filled and consists just of the border. * //from www. j av a2 s. c om * @param x1 x coordinate of the first corner of the rectangle * @param y1 y coordinate of the first corner of the rectangle * @param x2 x coordinate of the second corner of the rectangle * @param y2 y coordinate of the second corner of the rectangle * @param color the color of the rectangle border line * @see illarion.graphics.Drawer#drawRectangleFrame(int, int, int, int, * float, SpriteColor) */ @Override public void drawRectangleFrame(final int x1, final int y1, final int x2, final int y2, final float width, final SpriteColor color) { DriverSettingsLWJGL.getInstance().enableDrawOther(); color.setActiveColor(); GL11.glLineWidth(width); buffer.clear(); buffer.put(x1).put(y1); buffer.put(x1).put(y2); buffer.put(x2).put(y2); buffer.put(x2).put(y1); buffer.flip(); GL11.glVertexPointer(2, 0, buffer); GL11.glDrawArrays(GL11.GL_LINE_LOOP, 0, 4); }
From source file:illarion.graphics.lwjgl.DrawerLWJGL.java
License:Open Source License
/** * Draw a rounded rectangle. The size that is set by the parameters is the * inner rectangle that is not influenced by the rounded corners. The border * for the rounded edges is added to the size of the rectangle. So the * resulting object is slightly bigger then the size set here. * /*ww w . j a v a 2 s .c o m*/ * @param x1 x coordinate of the first corner of the rectangle * @param y1 y coordinate of the first corner of the rectangle * @param x2 x coordinate of the second corner of the rectangle * @param y2 y coordinate of the second corner of the rectangle * @param color the color the rectangle is filled with * @see illarion.graphics.Drawer#drawRoundedRectangle(int, int, int, int, * SpriteColor) */ @Override public void drawRoundedRectangle(final int x1, final int y1, final int x2, final int y2, final SpriteColor color) { final int quality = Graphics.getInstance().getQuality(); if (quality == Graphics.QUALITY_MIN) { drawRectangle(x1 - ROUNDED_BORDER_WIDTH, y1 - ROUNDED_BORDER_WIDTH, x2 + ROUNDED_BORDER_WIDTH, y2 + ROUNDED_BORDER_WIDTH, color); return; } DriverSettingsLWJGL.getInstance().enableDrawOther(); color.setActiveColor(); buffer.clear(); buffer.put(x1 - ROUNDED_BORDER_WIDTH).put(y1); buffer.put(x1 - ROUNDED_BORDER_WIDTH).put(y2); buffer.put(x1 - ROUNDED_BORDER_WIDTH_1).put(y1 - ROUNDED_BORDER_WIDTH_2); buffer.put(x1 - ROUNDED_BORDER_WIDTH_1).put(y2 + ROUNDED_BORDER_WIDTH_2); buffer.put(x1 - ROUNDED_BORDER_WIDTH_2).put(y1 - ROUNDED_BORDER_WIDTH_1); buffer.put(x1 - ROUNDED_BORDER_WIDTH_2).put(y2 + ROUNDED_BORDER_WIDTH_1); buffer.put(x1 - ROUNDED_BORDER_WIDTH_2).put(y1 - ROUNDED_BORDER_WIDTH); buffer.put(x1 - ROUNDED_BORDER_WIDTH_2).put(y2 + ROUNDED_BORDER_WIDTH); buffer.put(x2).put(y1 - ROUNDED_BORDER_WIDTH); buffer.put(x2).put(y2 + ROUNDED_BORDER_WIDTH); buffer.put(x2 + ROUNDED_BORDER_WIDTH_2).put(y1 - ROUNDED_BORDER_WIDTH_1); buffer.put(x2 + ROUNDED_BORDER_WIDTH_2).put(y2 + ROUNDED_BORDER_WIDTH_1); buffer.put(x2 + ROUNDED_BORDER_WIDTH_1).put(y1 - ROUNDED_BORDER_WIDTH_2); buffer.put(x2 + ROUNDED_BORDER_WIDTH_1).put(y2 + ROUNDED_BORDER_WIDTH_2); buffer.put(x2 + ROUNDED_BORDER_WIDTH).put(y1); buffer.put(x2 + ROUNDED_BORDER_WIDTH).put(y2); buffer.flip(); GL11.glVertexPointer(2, 0, buffer); GL11.glDrawArrays(GL11.GL_TRIANGLE_STRIP, 0, 16); }
From source file:illarion.graphics.lwjgl.DrawerLWJGL.java
License:Open Source License
@Override public void drawRoundedRectangleFrame(final int x1, final int y1, final int x2, final int y2, final float width, final SpriteColor color) { final int quality = Graphics.getInstance().getQuality(); if (quality == Graphics.QUALITY_MIN) { drawRectangleFrame(x1 - ROUNDED_BORDER_WIDTH, y1 - ROUNDED_BORDER_WIDTH, x2 + ROUNDED_BORDER_WIDTH, y2 + ROUNDED_BORDER_WIDTH, width, color); return;//from w ww. j a v a 2 s.c o m } DriverSettingsLWJGL.getInstance().enableDrawLine(); color.setActiveColor(); GL11.glLineWidth(width); buffer.clear(); buffer.put(x1 - ROUNDED_BORDER_WIDTH).put(y1); buffer.put(x1 - ROUNDED_BORDER_WIDTH).put(y2); buffer.put(x1 - ROUNDED_BORDER_WIDTH_1).put(y2 + ROUNDED_BORDER_WIDTH_2); buffer.put(x1 - ROUNDED_BORDER_WIDTH_2).put(y2 + ROUNDED_BORDER_WIDTH_1); buffer.put(x1).put(y2 + ROUNDED_BORDER_WIDTH); buffer.put(x2).put(y2 + ROUNDED_BORDER_WIDTH); buffer.put(x2 + ROUNDED_BORDER_WIDTH_2).put(y2 + ROUNDED_BORDER_WIDTH_1); buffer.put(x2 + ROUNDED_BORDER_WIDTH_1).put(y2 + ROUNDED_BORDER_WIDTH_2); buffer.put(x2 + ROUNDED_BORDER_WIDTH).put(y2); buffer.put(x2 + ROUNDED_BORDER_WIDTH).put(y1); buffer.put(x2 + ROUNDED_BORDER_WIDTH_1).put(y1 - ROUNDED_BORDER_WIDTH_2); buffer.put(x2 + ROUNDED_BORDER_WIDTH_2).put(y1 - ROUNDED_BORDER_WIDTH_1); buffer.put(x2).put(y1 - ROUNDED_BORDER_WIDTH); buffer.put(x1).put(y1 - ROUNDED_BORDER_WIDTH); buffer.put(x1 - ROUNDED_BORDER_WIDTH_2).put(y1 - ROUNDED_BORDER_WIDTH_1); buffer.put(x1 - ROUNDED_BORDER_WIDTH_1).put(y1 - ROUNDED_BORDER_WIDTH_2); buffer.flip(); GL11.glVertexPointer(2, 0, buffer); GL11.glDrawArrays(GL11.GL_LINE_LOOP, 0, 16); }