org.lwjgl.opengl.GL32 Java Examples

The following examples show how to use org.lwjgl.opengl.GL32. 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: ShaderProgram.java    From LowPolyWater with The Unlicense 6 votes vote down vote up
public ShaderProgram(MyFile vertexFile, MyFile geometryFile, MyFile fragmentFile, String... inVariables) {
	int vertexShaderID = loadShader(vertexFile, GL20.GL_VERTEX_SHADER);
	int geometryShaderID = loadShader(geometryFile, GL32.GL_GEOMETRY_SHADER);
	int fragmentShaderID = loadShader(fragmentFile, GL20.GL_FRAGMENT_SHADER);
	programID = GL20.glCreateProgram();
	GL20.glAttachShader(programID, vertexShaderID);
	GL20.glAttachShader(programID, geometryShaderID);
	GL20.glAttachShader(programID, fragmentShaderID);
	bindAttributes(inVariables);
	GL20.glLinkProgram(programID);
	GL20.glDetachShader(programID, vertexShaderID);
	GL20.glDetachShader(programID, geometryShaderID);
	GL20.glDetachShader(programID, fragmentShaderID);
	GL20.glDeleteShader(vertexShaderID);
	GL20.glDeleteShader(geometryShaderID);
	GL20.glDeleteShader(fragmentShaderID);
}
 
Example #2
Source File: TextureGenerator.java    From LWJGL-OpenGL-Tutorials with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private static void throwIfLANotSupported() {
	if(!GLContext.getCapabilities().OpenGL30) {
		return;
	}
	
	if(!GLContext.getCapabilities().OpenGL32) {
		if(!GLContext.getCapabilities().GL_ARB_compatibility) {
			throw new ImageFormatUnsupportedException("Core OpenGL contexts cannot use Luminance/alpha.");
		}
	}
	else {
		int profileMask = glGetInteger(GL32.GL_CONTEXT_PROFILE_MASK);
		
		if((profileMask & GL32.GL_CONTEXT_CORE_PROFILE_BIT) != 0) {
			throw new ImageFormatUnsupportedException("Core OpenGL contexts cannot use Luminance/alpha.");
			
		}
	}
}
 
Example #3
Source File: RenderUtil.java    From seppuku with GNU General Public License v3.0 5 votes vote down vote up
public static void drawLine3D(float x, float y, float z, float x1, float y1, float z1, float thickness, int hex) {
    float red = (hex >> 16 & 0xFF) / 255.0F;
    float green = (hex >> 8 & 0xFF) / 255.0F;
    float blue = (hex & 0xFF) / 255.0F;
    float alpha = (hex >> 24 & 0xFF) / 255.0F;

    GlStateManager.pushMatrix();
    GlStateManager.disableTexture2D();
    GlStateManager.enableBlend();
    GlStateManager.disableAlpha();
    GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
    GlStateManager.shadeModel(GL_SMOOTH);
    glLineWidth(thickness);
    glEnable(GL_LINE_SMOOTH);
    glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
    GlStateManager.disableDepth();
    glEnable(GL32.GL_DEPTH_CLAMP);
    final Tessellator tessellator = Tessellator.getInstance();
    final BufferBuilder bufferbuilder = tessellator.getBuffer();
    bufferbuilder.begin(GL_LINES, DefaultVertexFormats.POSITION_COLOR);
    bufferbuilder.pos((double) x, (double) y, (double) z).color(red, green, blue, alpha).endVertex();
    bufferbuilder.pos((double) x1, (double) y1, (double) z1).color(red, green, blue, alpha).endVertex();
    tessellator.draw();
    GlStateManager.shadeModel(GL_FLAT);
    glDisable(GL_LINE_SMOOTH);
    GlStateManager.enableDepth();
    glDisable(GL32.GL_DEPTH_CLAMP);
    GlStateManager.disableBlend();
    GlStateManager.enableAlpha();
    GlStateManager.enableTexture2D();
    GlStateManager.popMatrix();
}
 
Example #4
Source File: RenderEngine.java    From LowPolyWater with The Unlicense 5 votes vote down vote up
/**
 * Prepares for a rendering pass. The depth and colour buffers of the
 * current framebuffer are cleared and a few other default settings are set.
 */
private void prepare() {
	GL11.glClearColor(1f, 1f, 1f, 1f);
	GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
	GL32.glProvokingVertex(GL32.GL_FIRST_VERTEX_CONVENTION);
	OpenGlUtils.cullBackFaces(true);
	OpenGlUtils.enableDepthTesting(true);
	OpenGlUtils.antialias(true);
}
 
Example #5
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 #6
Source File: ProjectilesModule.java    From seppuku with GNU General Public License v3.0 4 votes vote down vote up
@Listener
public void onRender(EventRender3D event) {
    final Minecraft mc = Minecraft.getMinecraft();

    ThrowableType throwingType = this.getTypeFromCurrentItem(mc.player);

    if (throwingType == ThrowableType.NONE) {
        return;
    }

    FlightPath flightPath = new FlightPath(mc.player, throwingType);

    while (!flightPath.isCollided()) {
        flightPath.onUpdate();

        flightPoint.offer(new Vec3d(flightPath.position.x - mc.getRenderManager().viewerPosX,
                flightPath.position.y - mc.getRenderManager().viewerPosY,
                flightPath.position.z - mc.getRenderManager().viewerPosZ));
    }

    final boolean bobbing = mc.gameSettings.viewBobbing;
    mc.gameSettings.viewBobbing = false;
    mc.entityRenderer.setupCameraTransform(event.getPartialTicks(), 0);
    GlStateManager.pushMatrix();
    GlStateManager.disableTexture2D();
    GlStateManager.enableBlend();
    GlStateManager.disableAlpha();
    GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
    GlStateManager.shadeModel(GL_SMOOTH);
    glLineWidth(width.getValue());
    glEnable(GL_LINE_SMOOTH);
    glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
    GlStateManager.disableDepth();
    glEnable(GL32.GL_DEPTH_CLAMP);
    final Tessellator tessellator = Tessellator.getInstance();
    final BufferBuilder bufferbuilder = tessellator.getBuffer();

    while (!flightPoint.isEmpty()) {
        bufferbuilder.begin(GL11.GL_LINE_STRIP, DefaultVertexFormats.POSITION_COLOR);
        Vec3d head = flightPoint.poll();
        bufferbuilder.pos(head.x, head.y, head.z).color(red.getValue() / 255.0f, green.getValue() / 255.0f, blue.getValue() / 255.0f, alpha.getValue() / 255.0f).endVertex();

        if (flightPoint.peek() != null) {
            Vec3d point = flightPoint.peek();
            bufferbuilder.pos(point.x, point.y, point.z).color(red.getValue() / 255.0f, green.getValue() / 255.0f, blue.getValue() / 255.0f, alpha.getValue() / 255.0f).endVertex();
        }

        tessellator.draw();
    }

    GlStateManager.shadeModel(GL_FLAT);
    glDisable(GL_LINE_SMOOTH);
    GlStateManager.enableDepth();
    glDisable(GL32.GL_DEPTH_CLAMP);
    GlStateManager.disableBlend();
    GlStateManager.enableAlpha();
    GlStateManager.enableTexture2D();
    GlStateManager.popMatrix();

    mc.gameSettings.viewBobbing = bobbing;
    mc.entityRenderer.setupCameraTransform(event.getPartialTicks(), 0);

    if (flightPath.collided) {
        final RayTraceResult hit = flightPath.target;
        AxisAlignedBB bb = null;

        if (hit.typeOfHit == RayTraceResult.Type.BLOCK) {
            final BlockPos blockpos = hit.getBlockPos();
            final IBlockState iblockstate = mc.world.getBlockState(blockpos);

            if (iblockstate.getMaterial() != Material.AIR && mc.world.getWorldBorder().contains(blockpos)) {
                final Vec3d interp = MathUtil.interpolateEntity(mc.player, mc.getRenderPartialTicks());
                bb = iblockstate.getSelectedBoundingBox(mc.world, blockpos).grow(0.0020000000949949026D).offset(-interp.x, -interp.y, -interp.z);
            }
        } else if (hit.typeOfHit == RayTraceResult.Type.ENTITY && hit.entityHit != null) {
            final AxisAlignedBB entityBB = hit.entityHit.getEntityBoundingBox();
            if (entityBB != null) {
                bb = new AxisAlignedBB(entityBB.minX - mc.getRenderManager().viewerPosX, entityBB.minY - mc.getRenderManager().viewerPosY, entityBB.minZ - mc.getRenderManager().viewerPosZ, entityBB.maxX - mc.getRenderManager().viewerPosX, entityBB.maxY - mc.getRenderManager().viewerPosY, entityBB.maxZ - mc.getRenderManager().viewerPosZ);
            }
        }

        if (bb != null) {
            RenderUtil.drawBoundingBox(bb, width.getValue(), red.getValue() / 255.0f, green.getValue() / 255.0f, blue.getValue() / 255.0f, alpha.getValue() / 255.0f);
        }
    }
}
 
Example #7
Source File: PlatformLinuxGLCanvas.java    From lwjgl3-awt with MIT License 4 votes vote down vote up
private static void populateEffectiveGLAttribs(GLData effective) throws AWTException {
	long glGetIntegerv = GL.getFunctionProvider().getFunctionAddress("glGetIntegerv");
	long glGetString = GL.getFunctionProvider().getFunctionAddress("glGetString");
	APIVersion version = APIUtil.apiParseVersion(getString(GL11.GL_VERSION, glGetString));

	effective.majorVersion = version.major;
	effective.minorVersion = version.minor;

	int profileFlags = getInteger(GL32.GL_CONTEXT_PROFILE_MASK, glGetIntegerv);

	if ((profileFlags & GLX_CONTEXT_ES_PROFILE_BIT_EXT) != 0) {
		effective.api = GLData.API.GLES;
	} else {
		effective.api = GLData.API.GL;
	}

	if (version.major >= 3) {
		if (version.major >= 4 || version.minor >= 2) {
			if ((profileFlags & GL32.GL_CONTEXT_CORE_PROFILE_BIT) != 0) {
				effective.profile = GLData.Profile.CORE;
			} else if ((profileFlags & GL32.GL_CONTEXT_COMPATIBILITY_PROFILE_BIT) != 0) {
				effective.profile = GLData.Profile.COMPATIBILITY;
			} else if (
					(profileFlags & GLX_CONTEXT_ES_PROFILE_BIT_EXT) != 0) {
				// OpenGL ES allows checking for profiles at versions below 3.2, so avoid branching into
				// the if and actually check later.
			} else if (profileFlags != 0) {
				throw new AWTException("Unknown profile " + profileFlags);
			}
		}

		int effectiveContextFlags = getInteger(GL30.GL_CONTEXT_FLAGS, glGetIntegerv);
		effective.debug = (effectiveContextFlags & GL43.GL_CONTEXT_FLAG_DEBUG_BIT) != 0;
		effective.forwardCompatible =
				(effectiveContextFlags & GL30.GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT) != 0;
		effective.robustness =
				(effectiveContextFlags & ARBRobustness.GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB) != 0;
		effective.contextResetIsolation =
				(effectiveContextFlags & GLX_CONTEXT_RESET_ISOLATION_BIT_ARB) != 0;
	}

	if (effective.robustness) {
		int effectiveNotificationStrategy = getInteger(ARBRobustness.GL_RESET_NOTIFICATION_STRATEGY_ARB, glGetIntegerv);
		effective.loseContextOnReset = (effectiveNotificationStrategy & ARBRobustness.GL_LOSE_CONTEXT_ON_RESET_ARB) != 0;
	}

	effective.samples = getInteger(GL13.GL_SAMPLES, glGetIntegerv);
}