org.lwjgl.opengl.GL13 Java Examples

The following examples show how to use org.lwjgl.opengl.GL13. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PaletteSwapper.java    From FEMultiplayer with GNU General Public License v3.0 6 votes vote down vote up
public static ShaderArgs setup(FightUnit u) {
	Unit unit = u.getUnit();
	ShaderArgs args = new ShaderArgs();
	if(unit.getTheClass().name.equals("Lord")) return args;
	String c = unit.functionalClassName();
	
	Texture t = palettes.get(c);
	if(t == null) return args;
	if(lookup.get(c) == null) return args;
	int offset = lookup.get(c).indexOf(unit.name);
	if(offset < 0) return args;
	args.programName = "paletteSwap";
	args.args = new float[] {t.getTextureWidth(), t.getTextureHeight(), offset, t.getImageWidth()};
	GL13.glActiveTexture(GL13.GL_TEXTURE8);
	t.bind();
	GL13.glActiveTexture(GL13.GL_TEXTURE0);
	return args;
}
 
Example #2
Source File: TexturedQuad.java    From LWJGUI with MIT License 6 votes vote down vote up
public void render() {
	GL11.glDisable(GL11.GL_CULL_FACE);
	
	// bind stuff
	GL30.glBindVertexArray(vaoId);
	if ( texId > -1 ) {
		GL13.glActiveTexture(GL13.GL_TEXTURE0);
		GL11.glBindTexture(GL11.GL_TEXTURE_2D, texId);
	}

	// draw it!
	glBindVertexArray(vaoId);
	glDrawArrays(GL_TRIANGLES, 0, 6);

	// unbind things
	GL30.glBindVertexArray(0);
	GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0);
}
 
Example #3
Source File: LegacyCurveRenderState.java    From opsu with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Restore the old OpenGL state that's backed up in {@code state}.
 * @param state the old state to restore
 */
private void restoreRenderState(RenderState state) {
	GL11.glMatrixMode(GL11.GL_PROJECTION);
	GL11.glPopMatrix();
	GL11.glMatrixMode(GL11.GL_MODELVIEW);
	GL11.glPopMatrix();
	GL11.glEnable(GL11.GL_BLEND);
	GL20.glUseProgram(state.oldProgram);
	GL13.glActiveTexture(state.texUnit);
	GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, state.oldArrayBuffer);
	if (!state.depthWriteEnabled)
		GL11.glDepthMask(false);
	if (!state.depthEnabled)
		GL11.glDisable(GL11.GL_DEPTH_TEST);
	if (state.texEnabled)
		GL11.glEnable(GL11.GL_TEXTURE_2D);
	if (state.smoothedPoly)
		GL11.glEnable(GL11.GL_POLYGON_SMOOTH);
	if (!state.blendEnabled)
		GL11.glDisable(GL11.GL_BLEND);
}
 
Example #4
Source File: LandscapeRenderer.java    From tribaltrouble with GNU General Public License v2.0 6 votes vote down vote up
private final void setupLandscape() {
	current_map_x = -1;
	current_map_y = -1;
	GL11.glEnable(GL11.GL_TEXTURE_GEN_S);
	GL11.glEnable(GL11.GL_TEXTURE_GEN_T);
	GLStateStack.switchState(GLState.VERTEX_ARRAY);
	if (Globals.draw_detail) {
		GLState.activeTexture(GL13.GL_TEXTURE1);
		GL11.glEnable(GL11.GL_TEXTURE_2D);
		bindDetail();
		GL11.glEnable(GL11.GL_TEXTURE_GEN_S);
		GL11.glEnable(GL11.GL_TEXTURE_GEN_T);
		GLUtils.setupTexGen(Globals.LANDSCAPE_DETAIL_REPEAT_RATE, Globals.LANDSCAPE_DETAIL_REPEAT_RATE, 0, 0);
		GLState.activeTexture(GL13.GL_TEXTURE0);
	}
	GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ZERO);
	GL11.glEnable(GL11.GL_BLEND);
}
 
Example #5
Source File: DisplayManager.java    From OpenGL-Animation with The Unlicense 6 votes vote down vote up
public static void createDisplay() {
	try {
		Display.setDisplayMode(new DisplayMode(WIDTH, HEIGHT));
		ContextAttribs attribs = new ContextAttribs(3, 2).withProfileCore(true).withForwardCompatible(true);
		Display.create(new PixelFormat().withDepthBits(24).withSamples(4), attribs);
		Display.setTitle(TITLE);
		Display.setInitialBackground(1, 1, 1);
		GL11.glEnable(GL13.GL_MULTISAMPLE);
	} catch (LWJGLException e) {
		e.printStackTrace();
		System.err.println("Couldn't create display!");
		System.exit(-1);
	}
	GL11.glViewport(0, 0, WIDTH, HEIGHT);
	lastFrameTime = getCurrentTime();
}
 
Example #6
Source File: PaletteSwapper.java    From FEMultiPlayer-V2 with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Setup.
 *
 * @param u the u
 * @return the shader args
 */
public static ShaderArgs setup(FightUnit u) {
	Unit unit = u.getUnit();
	ShaderArgs args = new ShaderArgs();
	if(unit.getTheClass().name.equals("Lord")) return args;
	String c = unit.functionalClassName();
	
	Texture t = palettes.get(c);
	if(t == null) return args;
	if(lookup.get(c) == null) return args;
	int offset = lookup.get(c).indexOf(unit.name);
	if(offset < 0) return args;
	args.programName = "paletteSwap";
	args.args = new float[] {t.getTextureWidth(), t.getTextureHeight(), offset, t.getImageWidth()};
	GL13.glActiveTexture(GL13.GL_TEXTURE8);
	t.bind();
	GL13.glActiveTexture(GL13.GL_TEXTURE0);
	return args;
}
 
Example #7
Source File: CurveRenderState.java    From opsu-dance with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Restore the old OpenGL state that's backed up in {@code state}.
 * @param state the old state to restore
 */
private void restoreRenderState(RenderState state) {
	GL11.glMatrixMode(GL11.GL_PROJECTION);
	GL11.glPopMatrix();
	GL11.glMatrixMode(GL11.GL_MODELVIEW);
	GL11.glPopMatrix();
	GL11.glEnable(GL11.GL_BLEND);
	GL20.glUseProgram(state.oldProgram);
	GL13.glActiveTexture(state.texUnit);
	GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, state.oldArrayBuffer);
	if (!state.depthWriteEnabled)
		GL11.glDepthMask(false);
	if (!state.depthEnabled)
		GL11.glDisable(GL11.GL_DEPTH_TEST);
	if (state.texEnabled)
		GL11.glEnable(GL11.GL_TEXTURE_2D);
	if (state.smoothedPoly)
		GL11.glEnable(GL11.GL_POLYGON_SMOOTH);
	if (!state.blendEnabled)
		GL11.glDisable(GL11.GL_BLEND);
}
 
Example #8
Source File: Sky.java    From tribaltrouble with GNU General Public License v2.0 5 votes vote down vote up
private final void resetSky() {
	GL11.glDisable(GL11.GL_TEXTURE_2D);
	GL11.glLoadIdentity();
	GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_DECAL);
	GLState.activeTexture(GL13.GL_TEXTURE0);
	GL11.glLoadIdentity();
	GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_REPLACE);
	GL11.glMatrixMode(GL11.GL_MODELVIEW);
}
 
Example #9
Source File: BlendLighting.java    From tribaltrouble with GNU General Public License v2.0 5 votes vote down vote up
public final void setup() {
	GLState.activeTexture(GL13.GL_TEXTURE1);
	GL11.glColor3f(r, b, g);
	GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_MODULATE);
	GL11.glEnable(GL11.GL_TEXTURE_2D);
	bindAlpha();
	GLState.activeTexture(GL13.GL_TEXTURE0);
	GL11.glDisable(GL11.GL_TEXTURE_2D);
	GL11.glBlendFunc(GL11.GL_DST_COLOR, GL11.GL_ONE);
}
 
Example #10
Source File: Renderer.java    From tribaltrouble with GNU General Public License v2.0 5 votes vote down vote up
public final static void initGL() {
		VBO.releaseAll();
		GL11.glFrontFace(GL11.GL_CCW);
		GL11.glCullFace(GL11.GL_BACK);
		GL11.glEnable(GL11.GL_CULL_FACE); 
		GL11.glPixelStorei(GL11.GL_PACK_ROW_LENGTH, 0);
		GL11.glPixelStorei(GL11.GL_PACK_SKIP_PIXELS, 0);
		GL11.glPixelStorei(GL11.GL_PACK_SKIP_ROWS, 0);
		GL11.glPixelStorei(GL11.GL_PACK_ALIGNMENT, 1);
		GL11.glPixelStorei(GL11.GL_PACK_SWAP_BYTES, 0);

		GL11.glPixelStorei(GL11.GL_UNPACK_ROW_LENGTH, 0);
		GL11.glPixelStorei(GL11.GL_UNPACK_SKIP_PIXELS, 0);
		GL11.glPixelStorei(GL11.GL_UNPACK_SKIP_ROWS, 0);
		GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1);
		GL11.glPixelStorei(GL11.GL_UNPACK_SWAP_BYTES, 0);
		GL11.glEnable(GL11.GL_DEPTH_TEST);
		GL11.glDepthFunc(GL11.GL_LEQUAL);
		GL11.glShadeModel(GL11.GL_SMOOTH);
//		GL11.glAlphaFunc(GL11.GL_GREATER, Globals.ALPHA_CUTOFF);
		// Setup landscape texture coordinate gen
		GL11.glTexGeni(GL11.GL_S, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_OBJECT_LINEAR);
		GL11.glTexGeni(GL11.GL_T, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_OBJECT_LINEAR);
		GL11.glEnable(GL11.GL_TEXTURE_2D);
		GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_REPLACE);
		GLState.activeTexture(GL13.GL_TEXTURE1);
		GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_DECAL);
		GL11.glTexGeni(GL11.GL_S, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_OBJECT_LINEAR);
		GL11.glTexGeni(GL11.GL_T, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_OBJECT_LINEAR);
		GLState.activeTexture(GL13.GL_TEXTURE0);
		GL11.glMatrixMode(GL11.GL_MODELVIEW);

		GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

		GL11.glPointSize(7.0f);
		clearScreen();
		GL11.glClearDepth(1.0);
	}
 
Example #11
Source File: LandscapeRenderer.java    From tribaltrouble with GNU General Public License v2.0 5 votes vote down vote up
private final static void disableLandscape() {
	GL11.glDisable(GL11.GL_BLEND);
	GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
	if (Globals.draw_detail) {
		GLState.activeTexture(GL13.GL_TEXTURE1);
		GL11.glDisable(GL11.GL_TEXTURE_GEN_S);
		GL11.glDisable(GL11.GL_TEXTURE_GEN_T);
		GL11.glDisable(GL11.GL_TEXTURE_2D);
		GLState.activeTexture(GL13.GL_TEXTURE0);
	}
	GL11.glDisable(GL11.GL_TEXTURE_GEN_S);
	GL11.glDisable(GL11.GL_TEXTURE_GEN_T);
}
 
Example #12
Source File: Sprite.java    From tribaltrouble with GNU General Public License v2.0 5 votes vote down vote up
private final void doSetup(FloatBuffer color, int tex_index, boolean respond, boolean modulate_color) {
	int gl_flags = setupBasic();
	GL11.glBindTexture(GL11.GL_TEXTURE_2D, textures[tex_index][TEXTURE_NORMAL].getHandle());
	if (modulate_color) {
		GL11.glAlphaFunc(GL11.GL_GREATER, 0f);
		GL11.glEnable(GL11.GL_BLEND);
		GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_MODULATE);
	} else if (Globals.draw_light && lighted) {
		gl_flags = gl_flags | GLState.NORMAL_ARRAY;
		GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_MODULATE);
		GL11.glEnable(GL11.GL_LIGHTING);
		GL11.glMaterial(GL11.GL_FRONT, GL11.GL_DIFFUSE, color);
	}
	GL11.glColor4f(color.get(0), color.get(1), color.get(2), color.get(3));
	if (!modulate_color && (hasTeamDecal() || respond)) {
		gl_flags = gl_flags | GLState.TEXCOORD1_ARRAY;
		setupTeamDecal();
		if (respond) {
			GL11.glBindTexture(GL11.GL_TEXTURE_2D, respond_texture.getHandle());
		} else {
			GL11.glBindTexture(GL11.GL_TEXTURE_2D, textures[tex_index][TEXTURE_TEAM].getHandle());
		}
		GLState.clientActiveTexture(GL13.GL_TEXTURE1);
		texcoords.texCoordPointer(2, 0, 0);
		GLState.clientActiveTexture(GL13.GL_TEXTURE0);
	}
	GLStateStack.switchState(gl_flags);
}
 
Example #13
Source File: Texture.java    From tribaltrouble with GNU General Public License v2.0 5 votes vote down vote up
private static int determineMipMapSize(int mipmap, int internal_format, int width, int height) {
	boolean compressed = false;
	if (Settings.getSettings().useTextureCompression()) {
		GL11.glGetTexLevelParameter(GL11.GL_TEXTURE_2D, mipmap, GL13.GL_TEXTURE_COMPRESSED, size_buffer);
		compressed = size_buffer.get(0) == GL11.GL_TRUE;
	}
	if (compressed) {
		GL11.glGetTexLevelParameter(GL11.GL_TEXTURE_2D, mipmap, GL13.GL_TEXTURE_COMPRESSED_IMAGE_SIZE, size_buffer);
		return size_buffer.get(0);
	} else {
		switch (internal_format) {
			case GL13.GL_COMPRESSED_RGB:
			case GL11.GL_RGB:
				return width*height*3;
			case GL13.GL_COMPRESSED_RGBA:
			case GL11.GL_RGBA:
				return width*height*4;
			case GL11.GL_LUMINANCE:
			case GL11.GL_ALPHA8:
			case GL11.GL_ALPHA:
			case GL13.GL_COMPRESSED_LUMINANCE:
			case GL13.GL_COMPRESSED_ALPHA:
				return width*height;
			default:
				throw new RuntimeException("0x" + Integer.toHexString(internal_format));
		}
	}
}
 
Example #14
Source File: Sky.java    From tribaltrouble with GNU General Public License v2.0 5 votes vote down vote up
private final void setupSky() {
	float time = LocalEventQueue.getQueue().getTime();
	float speed_scale = 0.01f;
	float outer_dx = SKYDOME_SPEED_OUTER[0] * time*speed_scale;
	float outer_dy = SKYDOME_SPEED_OUTER[1] * time*speed_scale;
	float inner_dx = SKYDOME_SPEED_INNER[0] * time*speed_scale;
	float inner_dy = SKYDOME_SPEED_INNER[1] * time*speed_scale;
	GL11.glBindTexture(GL11.GL_TEXTURE_2D, clouds[GeneratorClouds.INNER].getHandle());
	GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_BLEND);
	GL11.glTexEnv(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_COLOR, color);
	GL11.glMatrixMode(GL11.GL_TEXTURE);
	GL11.glTranslatef(outer_dx, outer_dy, 0);
	GLState.activeTexture(GL13.GL_TEXTURE1);
	GL11.glBindTexture(GL11.GL_TEXTURE_2D, clouds[GeneratorClouds.OUTER].getHandle());
	GL11.glEnable(GL11.GL_TEXTURE_2D);
	GL11.glTranslatef(inner_dx, inner_dy, 0);
	GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_BLEND);
	GL11.glTexEnv(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_COLOR, color);
	

	GLStateStack.switchState(GLState.VERTEX_ARRAY | GLState.COLOR_ARRAY | GLState.TEXCOORD0_ARRAY | GLState.TEXCOORD1_ARRAY);
	sky_vertices.vertexPointer(3, 0, 0);
	sky_tex0.texCoordPointer(2, 0, 0);
	sky_colors.colorPointer(3, 0, 0);
	GLState.clientActiveTexture(GL13.GL_TEXTURE1);
	sky_tex1.texCoordPointer(2, 0, 0);
	GLState.clientActiveTexture(GL13.GL_TEXTURE0);
}
 
Example #15
Source File: StructureBlend.java    From tribaltrouble with GNU General Public License v2.0 5 votes vote down vote up
public final void setup() {
	GLState.activeTexture(GL13.GL_TEXTURE1);
	GL11.glEnable(GL11.GL_TEXTURE_2D);
	bindAlpha();
	GLState.activeTexture(GL13.GL_TEXTURE0);
	GL11.glEnable(GL11.GL_TEXTURE_2D);
	bindStructure();
	GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
}
 
Example #16
Source File: Sky.java    From tribaltrouble with GNU General Public License v2.0 5 votes vote down vote up
public final void renderSeaBottom() {
	GL11.glDisable(GL11.GL_TEXTURE_2D);
	GL11.glColor3f(Globals.SEA_BOTTOM_COLOR[terrain_type][0], Globals.SEA_BOTTOM_COLOR[terrain_type][1], Globals.SEA_BOTTOM_COLOR[terrain_type][2]);

	GLStateStack.switchState(GLState.VERTEX_ARRAY);
	if (Globals.draw_detail) {
		GLState.activeTexture(GL13.GL_TEXTURE1);
		GL11.glEnable(GL11.GL_TEXTURE_2D);
		landscape_renderer.bindDetail();
		GL11.glMatrixMode(GL11.GL_TEXTURE);
		GL11.glLoadIdentity();
		GL11.glEnable(GL11.GL_TEXTURE_GEN_S);
		GL11.glEnable(GL11.GL_TEXTURE_GEN_T);
		GLUtils.setupTexGen(1, 1, 0, 0);
		GL11.glScalef(Globals.LANDSCAPE_DETAIL_REPEAT_RATE, Globals.LANDSCAPE_DETAIL_REPEAT_RATE, 1);
	}

	bottom_vertices.vertexPointer(3, 0, 0);
	water_indices.drawRangeElements(GL11.GL_TRIANGLES, 0, bottom_vertices.capacity()/3, water_indices.capacity(), 0);

	if (Globals.draw_detail) {
		GL11.glDisable(GL11.GL_TEXTURE_GEN_S);
		GL11.glDisable(GL11.GL_TEXTURE_GEN_T);
		GL11.glLoadIdentity();
		GL11.glMatrixMode(GL11.GL_MODELVIEW);
		GL11.glDisable(GL11.GL_TEXTURE_2D);
		GLState.activeTexture(GL13.GL_TEXTURE0);
	}

	GL11.glEnable(GL11.GL_TEXTURE_2D);
}
 
Example #17
Source File: GLState.java    From tribaltrouble with GNU General Public License v2.0 5 votes vote down vote up
public final void switchState(int client_flags) {
		boolean target_vertex_array = (client_flags & VERTEX_ARRAY) != 0;
//		assert GLUtils.getGLInteger(GL13.GL_CLIENT_ACTIVE_TEXTURE) == GL13.GL_TEXTURE0;
		if (target_vertex_array != vertex_array) {
			matchGLClientState(GL11.GL_VERTEX_ARRAY, target_vertex_array);
			vertex_array = target_vertex_array;
		}
		boolean target_normal_array = (client_flags & NORMAL_ARRAY) != 0;
		if (target_normal_array != normal_array) {
			matchGLClientState(GL11.GL_NORMAL_ARRAY, target_normal_array);
			normal_array = target_normal_array;
		}
		boolean target_texcoord0_array = (client_flags & TEXCOORD0_ARRAY) != 0;
		if (target_texcoord0_array != texcoord0_array) {
			matchGLClientState(GL11.GL_TEXTURE_COORD_ARRAY, target_texcoord0_array);
			texcoord0_array = target_texcoord0_array;
		}
		boolean target_texcoord1_array = (client_flags & TEXCOORD1_ARRAY) != 0;
		if (target_texcoord1_array != texcoord1_array) {
			clientActiveTexture(GL13.GL_TEXTURE1);
			matchGLClientState(GL11.GL_TEXTURE_COORD_ARRAY, target_texcoord1_array);
			clientActiveTexture(GL13.GL_TEXTURE0);
			texcoord1_array = target_texcoord1_array;
		}
		boolean target_color_array = (client_flags & COLOR_ARRAY) != 0;
		if (target_color_array != color_array) {
			matchGLClientState(GL11.GL_COLOR_ARRAY, target_color_array);
			color_array = target_color_array;
		}
	}
 
Example #18
Source File: LegacyCurveRenderState.java    From opsu with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Backup the current state of the relevant OpenGL state and change it to
 * what's needed to draw the curve.
 */
private RenderState saveRenderState() {
	RenderState state = new RenderState();
	state.smoothedPoly = GL11.glGetBoolean(GL11.GL_POLYGON_SMOOTH);
	state.blendEnabled = GL11.glGetBoolean(GL11.GL_BLEND);
	state.depthEnabled = GL11.glGetBoolean(GL11.GL_DEPTH_TEST);
	state.depthWriteEnabled = GL11.glGetBoolean(GL11.GL_DEPTH_WRITEMASK);
	state.texEnabled = GL11.glGetBoolean(GL11.GL_TEXTURE_2D);
	state.texUnit = GL11.glGetInteger(GL13.GL_ACTIVE_TEXTURE);
	state.oldProgram = GL11.glGetInteger(GL20.GL_CURRENT_PROGRAM);
	state.oldArrayBuffer = GL11.glGetInteger(GL15.GL_ARRAY_BUFFER_BINDING);
	GL11.glDisable(GL11.GL_POLYGON_SMOOTH);
	GL11.glDisable(GL11.GL_BLEND);
	GL11.glEnable(GL11.GL_DEPTH_TEST);
	GL11.glDepthMask(true);
	GL11.glDisable(GL11.GL_TEXTURE_2D);
	GL11.glEnable(GL11.GL_TEXTURE_1D);
	GL11.glBindTexture(GL11.GL_TEXTURE_1D, staticState.gradientTexture);
	GL11.glTexParameteri(GL11.GL_TEXTURE_1D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR_MIPMAP_LINEAR);
	GL11.glTexParameteri(GL11.GL_TEXTURE_1D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
	GL11.glTexParameteri(GL11.GL_TEXTURE_1D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP);

	GL20.glUseProgram(0);

	GL11.glMatrixMode(GL11.GL_PROJECTION);
	GL11.glPushMatrix();
	GL11.glLoadIdentity();
	GL11.glMatrixMode(GL11.GL_MODELVIEW);
	GL11.glPushMatrix();
	GL11.glLoadIdentity();

	return state;
}
 
Example #19
Source File: PaletteSwapper.java    From FEMultiplayer with GNU General Public License v3.0 5 votes vote down vote up
public static ShaderArgs setup(Unit u) {
	ShaderArgs args = new ShaderArgs();
	int offset = u.getPartyColor().equals(Party.TEAM_BLUE) ? 0 : 1;
	if(offset == 0) return args;
	
	Texture t = palettes.get("overworld");
	args.programName = "paletteSwap";
	args.args = new float[] {t.getTextureWidth(), t.getTextureHeight(), offset, t.getImageWidth()};
	GL13.glActiveTexture(GL13.GL_TEXTURE8);
	t.bind();
	GL13.glActiveTexture(GL13.GL_TEXTURE0);
	return args;
}
 
Example #20
Source File: OpenGlUtils.java    From LowPolyWater with The Unlicense 5 votes vote down vote up
public static void antialias(boolean enable) {
	if (enable && !antialiasing) {
		GL11.glEnable(GL13.GL_MULTISAMPLE);
		antialiasing = true;
	} else if (!enable && antialiasing) {
		GL11.glDisable(GL13.GL_MULTISAMPLE);
		antialiasing = false;
	}
}
 
Example #21
Source File: OpenGlUtils.java    From OpenGL-Animation with The Unlicense 5 votes vote down vote up
public static void antialias(boolean enable) {
	if (enable && !antialiasing) {
		GL11.glEnable(GL13.GL_MULTISAMPLE);
		antialiasing = true;
	} else if (!enable && antialiasing) {
		GL11.glDisable(GL13.GL_MULTISAMPLE);
		antialiasing = false;
	}
}
 
Example #22
Source File: Errors.java    From Visage with MIT License 5 votes vote down vote up
private static void buildMapping() {
	if (mapping != null) return;
	Multimap<Integer, String> map = HashMultimap.create();
	List<Class<?>> classes = ImmutableList.of(
			GL11.class, GL12.class, GL13.class, GL14.class, GL15.class,
			GL20.class, GL21.class, GL30.class, GL31.class, GL32.class,
			GL33.class, GL40.class, GL41.class, GL42.class, GL43.class,
			GL44.class, GL45.class, GLFW.class
			);
	for (Class<?> clazz : classes) {
		for (Field f : clazz.getDeclaredFields()) {
			if (f.getName().toUpperCase(Locale.ROOT).equals(f.getName()) &&
					f.getType() == int.class && Modifier.isPublic(f.getModifiers()) && Modifier.isStatic(f.getModifiers())) {
				List<String> li = Splitter.on('_').splitToList(f.getName());
				li = li.subList(1, li.size());
				String clean =
					Joiner.on(' ').join(
						li.stream()
							.map(Errors::toTitleCase)
							.iterator());
				try {
					map.put(f.getInt(null), clean);
				} catch (Throwable t) {
					t.printStackTrace();
				}
			}
		}
	}
	mapping = map;
}
 
Example #23
Source File: PaletteSwapper.java    From FEMultiPlayer-V2 with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Setup.
 *
 * @param u the u
 * @return the shader args
 */
public static ShaderArgs setup(Unit u) {
	ShaderArgs args = new ShaderArgs();
	int offset = u.getPartyColor().equals(Party.TEAM_BLUE) ? 0 : 1;
	if(offset == 0) return args;
	
	Texture t = palettes.get("overworld");
	args.programName = "paletteSwap";
	args.args = new float[] {t.getTextureWidth(), t.getTextureHeight(), offset, t.getImageWidth()};
	GL13.glActiveTexture(GL13.GL_TEXTURE8);
	t.bind();
	GL13.glActiveTexture(GL13.GL_TEXTURE0);
	return args;
}
 
Example #24
Source File: VBORenderType.java    From CodeChickenLib with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void setupRenderState() {
    super.setupRenderState();
    states.forEach(RenderState::setupRenderState);
    RenderSystem.pushMatrix();
    matrix.glApply();
    if (hasLightMap) {
        RenderSystem.glMultiTexCoord2f(GL13.GL_TEXTURE2, packedLight & 0xFFFF, packedLight >>> 16);
    }
}
 
Example #25
Source File: TextureUtils.java    From OpenGL-Animation with The Unlicense 5 votes vote down vote up
protected static int loadTextureToOpenGL(TextureData data, TextureBuilder builder) {
	int texID = GL11.glGenTextures();
	GL13.glActiveTexture(GL13.GL_TEXTURE0);
	GL11.glBindTexture(GL11.GL_TEXTURE_2D, texID);
	GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1);
	GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, data.getWidth(), data.getHeight(), 0, GL12.GL_BGRA,
			GL11.GL_UNSIGNED_BYTE, data.getBuffer());
	if (builder.isMipmap()) {
		GL30.glGenerateMipmap(GL11.GL_TEXTURE_2D);
		GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
		GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR_MIPMAP_LINEAR);
		if (builder.isAnisotropic() && GLContext.getCapabilities().GL_EXT_texture_filter_anisotropic) {
			GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL14.GL_TEXTURE_LOD_BIAS, 0);
			GL11.glTexParameterf(GL11.GL_TEXTURE_2D, EXTTextureFilterAnisotropic.GL_TEXTURE_MAX_ANISOTROPY_EXT,
					4.0f);
		}
	} else if (builder.isNearest()) {
		GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
		GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
	} else {
		GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
		GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
	}
	if (builder.isClampEdges()) {
		GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE);
		GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE);
	} else {
		GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT);
		GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_REPEAT);
	}
	GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0);
	return texID;
}
 
Example #26
Source File: CurveRenderState.java    From opsu-dance with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Backup the current state of the relevant OpenGL state and change it to
 * what's needed to draw the curve.
 */
private RenderState saveRenderState() {
	RenderState state = new RenderState();
	state.smoothedPoly = GL11.glGetBoolean(GL11.GL_POLYGON_SMOOTH);
	state.blendEnabled = GL11.glGetBoolean(GL11.GL_BLEND);
	state.depthEnabled = GL11.glGetBoolean(GL11.GL_DEPTH_TEST);
	state.depthWriteEnabled = GL11.glGetBoolean(GL11.GL_DEPTH_WRITEMASK);
	state.texEnabled = GL11.glGetBoolean(GL11.GL_TEXTURE_2D);
	state.texUnit = GL11.glGetInteger(GL13.GL_ACTIVE_TEXTURE);
	state.oldProgram = GL11.glGetInteger(GL20.GL_CURRENT_PROGRAM);
	state.oldArrayBuffer = GL11.glGetInteger(GL15.GL_ARRAY_BUFFER_BINDING);
	GL11.glDisable(GL11.GL_POLYGON_SMOOTH);
	GL11.glDisable(GL11.GL_BLEND);
	GL11.glEnable(GL11.GL_DEPTH_TEST);
	GL11.glDepthMask(true);
	GL11.glDisable(GL11.GL_TEXTURE_2D);
	GL11.glEnable(GL11.GL_TEXTURE_1D);
	GL11.glBindTexture(GL11.GL_TEXTURE_1D, staticState.gradientTexture);
	GL11.glTexParameteri(GL11.GL_TEXTURE_1D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR_MIPMAP_LINEAR);
	GL11.glTexParameteri(GL11.GL_TEXTURE_1D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
	GL11.glTexParameteri(GL11.GL_TEXTURE_1D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP);

	GL20.glUseProgram(0);

	GL11.glMatrixMode(GL11.GL_PROJECTION);
	GL11.glPushMatrix();
	GL11.glLoadIdentity();
	GL11.glMatrixMode(GL11.GL_MODELVIEW);
	GL11.glPushMatrix();
	GL11.glLoadIdentity();

	return state;
}
 
Example #27
Source File: Sprite.java    From tribaltrouble with GNU General Public License v2.0 4 votes vote down vote up
public final static void resetTeamDecal() {
	GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_DECAL);
	GL11.glDisable(GL11.GL_TEXTURE_2D);
	GLState.activeTexture(GL13.GL_TEXTURE0);
}
 
Example #28
Source File: GenericShader.java    From LWJGUI with MIT License 4 votes vote down vote up
public void bind() {
	GL20.glUseProgram(id);

	GL13.glActiveTexture(GL13.GL_TEXTURE0);
	GL11.glBindTexture(GL11.GL_TEXTURE_2D, texId);
}
 
Example #29
Source File: OffscreenBuffer.java    From LWJGUI with MIT License 4 votes vote down vote up
public void render(Context context, int x, int y, int w, int h) {
	if (quadShader == null) {
		quadShader = new GenericShader();
	}
	float pixelRatio = LWJGUI.getThreadWindow().getPixelRatio();
	x *= pixelRatio;
	y *= pixelRatio;
	GL11.glViewport(x, y,(int) (w*pixelRatio),(int) (h*pixelRatio));
	quadShader.bind();
	quadShader.projectOrtho(0, 0, w, h);
	
	if (quadDirty) {
		quadDirty = false;
		if (quad != null) {
			quad.cleanup();
		}
		quad = new TexturedQuad(0, 0, w, h, texId);
	}
	if ( context.isCoreOpenGL() ) {
		if ( quad != null ) {
			quad.render();
		}
	} else {

		GL13.glActiveTexture(GL13.GL_TEXTURE0);
		GL11.glBindTexture(GL11.GL_TEXTURE_2D, texId);
		
		GL11.glBegin(GL11.GL_QUADS);
			GL11.glColor3f(1.0f, 1.0f, 1.0f);
			GL11.glTexCoord2f(0, 0);
			GL11.glVertex2f(0, 0);

			GL11.glColor3f(1.0f, 1.0f, 1.0f);
			GL11.glTexCoord2f(1, 0);
			GL11.glVertex2f(w, 0);

			GL11.glColor3f(1.0f, 1.0f, 1.0f);
			GL11.glTexCoord2f(1, 1);
			GL11.glVertex2f(w, h);

			GL11.glColor3f(1.0f, 1.0f, 1.0f);
			GL11.glTexCoord2f(0, 1);
			GL11.glVertex2f(0, h);
		GL11.glEnd();
	}
}
 
Example #30
Source File: GLState.java    From tribaltrouble with GNU General Public License v2.0 4 votes vote down vote up
public final static void clientActiveTexture(int texture) {
	if (GLContext.getCapabilities().OpenGL13)
		GL13.glClientActiveTexture(texture);
	else
		ARBMultitexture.glClientActiveTextureARB(texture);
}