List of usage examples for org.lwjgl.opengl GL11 glColor4ub
public static native void glColor4ub(@NativeType("GLubyte") byte red, @NativeType("GLubyte") byte green, @NativeType("GLubyte") byte blue, @NativeType("GLubyte") byte alpha);
From source file:appeng.client.render.items.PaintBallRender.java
License:Open Source License
@Override public void renderItem(final ItemRenderType type, final ItemStack item, final Object... data) { IIcon par2Icon = item.getIconIndex(); if (item.getItemDamage() >= 20) { par2Icon = ExtraItemTextures.ItemPaintBallShimmer.getIcon(); }//from w w w . ja v a2 s . c om final float f4 = par2Icon.getMinU(); final float f5 = par2Icon.getMaxU(); final float f6 = par2Icon.getMinV(); final float f7 = par2Icon.getMaxV(); final ItemPaintBall ipb = (ItemPaintBall) item.getItem(); final Tessellator tessellator = Tessellator.instance; GL11.glPushMatrix(); GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); final AEColor col = ipb.getColor(item); final int colorValue = item.getItemDamage() >= 20 ? col.mediumVariant : col.mediumVariant; final int r = (colorValue >> 16) & 0xff; final int g = (colorValue >> 8) & 0xff; final int b = (colorValue) & 0xff; if (item.getItemDamage() >= 20) { final float fail = 0.7f; final int full = (int) (255 * 0.3); GL11.glColor4ub((byte) (full + r * fail), (byte) (full + g * fail), (byte) (full + b * fail), (byte) 255); } else { GL11.glColor4ub((byte) r, (byte) g, (byte) b, (byte) 255); } if (type == ItemRenderType.INVENTORY) { GL11.glScalef(16F, 16F, 10F); GL11.glTranslatef(0.0F, 1.0F, 0.0F); GL11.glRotatef(180F, 1.0F, 0.0F, 0.0F); GL11.glEnable(GL11.GL_ALPHA_TEST); tessellator.startDrawingQuads(); tessellator.setNormal(0.0F, 1.0F, 0.0F); tessellator.addVertexWithUV(0, 0, 0, f4, f7); tessellator.addVertexWithUV(1, 0, 0, f5, f7); tessellator.addVertexWithUV(1, 1, 0, f5, f6); tessellator.addVertexWithUV(0, 1, 0, f4, f6); tessellator.draw(); } else { if (type == ItemRenderType.EQUIPPED_FIRST_PERSON) { GL11.glTranslatef(0.0F, 0.0F, 0.0F); } else { GL11.glTranslatef(-0.5F, -0.3F, 0.01F); } final float f12 = 0.0625F; ItemRenderer.renderItemIn2D(tessellator, f5, f6, f4, f7, par2Icon.getIconWidth(), par2Icon.getIconHeight(), f12); GL11.glDisable(GL11.GL_CULL_FACE); GL11.glColor4f(1, 1, 1, 1.0F); GL11.glScalef(1F, 1.1F, 1F); GL11.glTranslatef(0.0F, 1.07F, f12 / -2.0f); GL11.glRotatef(180F, 1.0F, 0.0F, 0.0F); } GL11.glColor4f(1, 1, 1, 1.0F); GL11.glPopAttrib(); GL11.glPopMatrix(); }
From source file:cn.liutils.util.RenderUtils.java
License:Open Source License
public static void bindColor(int r, int g, int b, int a) { GL11.glColor4ub((byte) r, (byte) g, (byte) b, (byte) a); }
From source file:cn.liutils.util.RenderUtils.java
License:Open Source License
public static void bindGray(int s, int alpha) { byte r = (byte) s; GL11.glColor4ub(r, r, r, (byte) alpha); }
From source file:com.gundogstudios.modules.DesktopGL11.java
License:Open Source License
public void glColor4ub(byte red, byte green, byte blue, byte alpha) { GL11.glColor4ub(red, green, blue, alpha); }
From source file:com.runescape.client.revised.editor.modelviewer.Model3D.java
License:Open Source License
public void render(final float x, final float y, final float z, final float rx, final float ry, final float rz, final float sx, final float sy, final float sz) { GL11.glLoadIdentity();/*from w w w. j av a2 s .com*/ GL11.glTranslatef(x, y, z); GL11.glRotatef(rx, 1.0F, 0.0F, 0.0F); GL11.glRotatef(ry, 0.0F, 1.0F, 0.0F); GL11.glRotatef(rz, 0.0F, 0.0F, 1.0F); GL11.glScalef(sx, sy, sz); final short[] tri_x = this.triangle_viewspace_x; final short[] tri_y = this.triangle_viewspace_y; final short[] tri_z = this.triangle_viewspace_z; // final short[] tex_map_x = this.texture_map_x; // final short[] tex_map_y = this.texture_map_y; // final short[] tex_map_z = this.texture_map_z; final short[] textures = this.textures; final int[] vertices_x = this.vertices_x; final int[] vertices_y = this.vertices_y; final int[] vertices_z = this.vertices_z; final short[] colors = this.colors; final float model_scale = 4.0F; final float texture_scale = 1.0F; if (this.pointers != null) { //glEnable(GL_DEPTH_TEST); GL11.glEnable(GL11.GL_TEXTURE_2D); //GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST); //GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); } Texture texture = null; for (int triangle = 0; triangle != this.triangle_count; ++triangle) { if ((this.alpha != null) && (this.alpha[triangle] == -1)) { continue; } final int point_a = tri_x[triangle]; final int point_b = tri_y[triangle]; final int point_c = tri_z[triangle]; final int color = Model.hsl2rgb[colors[triangle] & 0xffff]; int triangle_type; if (this.face_fill_attributes == null) { triangle_type = 0; } else { triangle_type = this.face_fill_attributes[triangle] & 3; } if ((textures != null) && (textures[triangle] != -1)) { final int id = textures[triangle] & 0xffff; if (ModelConstants.ENABLE_MODEL_TEXTURES && ((texture == null) && (id != -1))) { texture = TextureCache.get(id); } if (texture != null) { texture.bind(); } } final boolean textured = ModelConstants.ENABLE_MODEL_TEXTURES && (texture != null); GL11.glBegin(GL11.GL_TRIANGLES); GL11.glColor4ub((byte) (color >>> 16), (byte) (color >>> 8), (byte) color, (byte) (this.alpha == null ? 0xff : ~this.alpha[triangle])); switch (triangle_type) { case 0://shaded triangle case 1://flat triangle if (textured) { GL11.glTexCoord2f(0.0F, 0.0F); } GL11.glVertex3f(vertices_x[point_a] / model_scale, vertices_y[point_a] / model_scale, vertices_z[point_a] / model_scale); if (textured) { GL11.glTexCoord2f(0.0F, texture_scale / model_scale); } GL11.glVertex3f(vertices_x[point_b] / model_scale, vertices_y[point_b] / model_scale, vertices_z[point_b] / model_scale); if (textured) { GL11.glTexCoord2f(texture_scale / model_scale, texture_scale / model_scale); } GL11.glVertex3f(vertices_x[point_c] / model_scale, vertices_y[point_c] / model_scale, vertices_z[point_c] / model_scale); break; case 2://textured? case 3://textured? final int ptr = this.face_fill_attributes[triangle] >> 2; final int tex_point_a = this.texture_map_x[ptr]; final int tex_point_b = this.texture_map_y[ptr]; final int tex_point_c = this.texture_map_z[ptr]; GL11.glTexCoord2f(0.0F, 0.0F); GL11.glVertex3f(vertices_x[tex_point_a] / model_scale, vertices_y[tex_point_a] / model_scale, vertices_z[tex_point_a] / model_scale); GL11.glTexCoord2f(0.0F, texture_scale / model_scale); GL11.glVertex3f(vertices_x[tex_point_b] / model_scale, vertices_y[tex_point_b] / model_scale, vertices_z[tex_point_b] / model_scale); GL11.glTexCoord2f(texture_scale / model_scale, texture_scale / model_scale); GL11.glVertex3f(vertices_x[tex_point_c] / model_scale, vertices_y[tex_point_c] / model_scale, vertices_z[tex_point_c] / model_scale); break; } GL11.glEnd(); } if (texture != null) { GL11.glDisable(GL11.GL_TEXTURE_2D); } }
From source file:game.engine.core.CoreModule.java
License:Open Source License
/** * Constructor./*from w w w . java 2 s . c om*/ * * @param scriptEngine the Nashorn engine */ public CoreModule(ScriptEngine scriptEngine) { try { final EventListener positionTransformListener = new EventListener(null, "beforeDraw") { @Override public void handleEvent(GameObject gameObject, Object payload) { PositionData data = (PositionData) gameObject.get(CoreModule.this.position); GL11.glTranslatef(data.x, data.y, 0.0f); } }; position = new Behavior(new Applicator() { @Override public void apply(GameObject target, Object rawParameters, Behavior behavior) { PositionData data = new PositionData(); if (rawParameters != null) { JSObject parameters = (JSObject) jdk.nashorn.api.scripting.ScriptUtils.wrap(rawParameters); if (parameters.getMember("x") instanceof Number) { data.x = ((Number) parameters.getMember("x")).floatValue(); } if (parameters.getMember("y") instanceof Number) { data.y = ((Number) parameters.getMember("y")).floatValue(); } } target.set(CoreModule.this.position, data); target.addListener(positionTransformListener); } }); final EventListener drawRectangleListener = new EventListener(null, "draw") { @Override public void handleEvent(GameObject gameObject, Object payload) { GL11.glColor4ub((byte) 255, (byte) 255, (byte) 255, (byte) 255); GL11.glBegin(GL11.GL_QUADS); GL11.glVertex2f(1.0f, 1.0f); GL11.glVertex2f(1.0f, -1.0f); GL11.glVertex2f(-1.0f, -1.0f); GL11.glVertex2f(-1.0f, 1.0f); GL11.glEnd(); } }; rectangle = new Behavior(new Applicator() { @Override public void apply(GameObject target, Object parameters, Behavior behavior) { target.addListener(drawRectangleListener); } }); leftRight = new Behavior(new Applicator() { @Override public void apply(GameObject target, Object parameters, Behavior behavior) { target.set(leftRight, "left"); } }); final EventListener drawSpriteListener = new EventListener(null, "draw") { @Override public void handleEvent(GameObject gameObject, Object payload) { SpriteProvider spriteProvider = (SpriteProvider) gameObject.get(sprite); if (spriteProvider != null) { Sprite sprite = spriteProvider.provideSprite(gameObject); if (sprite != null) { sprite.draw(); } } } }; sprite = new Behavior(new Applicator() { @Override public void apply(GameObject target, Object parameters, Behavior behavior) { if (parameters instanceof SpriteProvider) { target.set(sprite, parameters); } else { throw new RuntimeException("invalid sprite provider"); } target.addListener(drawSpriteListener); } }); } catch (Exception e) { throw new RuntimeException(e); } }
From source file:game.engine.gfx.RgbaColor.java
License:Open Source License
/** * Configures this color using glColor(). *//*ww w.ja v a 2s. c o m*/ public void glColor() { GL11.glColor4ub((byte) r, (byte) g, (byte) b, (byte) a); }
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); }/* w w w . j a v a2 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:kuake2.render.lwjgl.Main.java
License:Open Source License
/** * GL_DrawParticles/*from w ww. j ava2 s.c om*/ */ void GL_DrawParticles(int num_particles) { float origin_x, origin_y, origin_z; Math3D.VectorScale(vup, 1.5f, up); Math3D.VectorScale(vright, 1.5f, right); GL_Bind(r_particletexture.texnum); GL11.glDepthMask(false); // no z buffering GL11.glEnable(GL11.GL_BLEND); GL_TexEnv(GL11.GL_MODULATE); GL11.glBegin(GL11.GL_TRIANGLES); FloatBuffer sourceVertices = particle_t.vertexArray; IntBuffer sourceColors = particle_t.colorArray; float scale; int color; for (int j = 0, i = 0; i < num_particles; i++) { origin_x = sourceVertices.get(j++); origin_y = sourceVertices.get(j++); origin_z = sourceVertices.get(j++); // hack a scale up to keep particles from disapearing scale = (origin_x - r_origin[0]) * vpn[0] + (origin_y - r_origin[1]) * vpn[1] + (origin_z - r_origin[2]) * vpn[2]; scale = (scale < 20) ? 1 : 1 + scale * 0.004f; color = sourceColors.get(i); GL11.glColor4ub((byte) ((color) & 0xFF), (byte) ((color >> 8) & 0xFF), (byte) ((color >> 16) & 0xFF), (byte) ((color >>> 24))); // first vertex GL11.glTexCoord2f(0.0625f, 0.0625f); GL11.glVertex3f(origin_x, origin_y, origin_z); // second vertex GL11.glTexCoord2f(1.0625f, 0.0625f); GL11.glVertex3f(origin_x + up[0] * scale, origin_y + up[1] * scale, origin_z + up[2] * scale); // third vertex GL11.glTexCoord2f(0.0625f, 1.0625f); GL11.glVertex3f(origin_x + right[0] * scale, origin_y + right[1] * scale, origin_z + right[2] * scale); } GL11.glEnd(); GL11.glDisable(GL11.GL_BLEND); GL11.glColor4f(1, 1, 1, 1); GL11.glDepthMask(true); // back to normal Z buffering GL_TexEnv(GL11.GL_REPLACE); }
From source file:name.martingeisse.stackd.client.gui.util.Color.java
License:Open Source License
/** * Sets this color as the current drawing color in OpenGL. *///from w w w . jav a2 s. c om public void glColor() { GL11.glColor4ub((byte) red, (byte) green, (byte) blue, (byte) alpha); }