use of org.lwjgl.util.glu.Sphere in project lwjgl by LWJGL.
the class BackgroundLoadTest method initialize.
private static void initialize(String[] args) {
if (args.length != 1)
argsError();
DisplayMode displayMode = null;
try {
DisplayMode[] modes = Display.getAvailableDisplayModes();
displayMode = chooseMode(modes, 1024, 768);
if (displayMode == null)
displayMode = chooseMode(modes, 800, 600);
if (displayMode == null)
displayMode = chooseMode(modes, 640, 480);
if (displayMode == null)
kill("Failed to set an appropriate display mode.");
System.out.println("Setting display mode to: " + displayMode);
Display.setDisplayMode(displayMode);
Display.setTitle("Background Loading Test");
Display.create(new PixelFormat(8, 24, 0));
} catch (LWJGLException e) {
kill(e.getMessage());
}
glViewport(0, 0, displayMode.getWidth(), displayMode.getHeight());
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45, displayMode.getWidth() / (float) displayMode.getHeight(), 1.0f, 10.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
// Setup camera position.
glTranslatef(0.0f, 0.0f, -4.0f);
glRotatef(90.0f, 1.0f, 0.0f, 0.0f);
glPushMatrix();
glClearDepth(1.0f);
glDepthFunc(GL_LEQUAL);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
glFrontFace(GL_CCW);
glPolygonMode(GL_FRONT, GL_FILL);
glCullFace(GL_BACK);
glEnable(GL_CULL_FACE);
glAlphaFunc(GL_GREATER, 0.0f);
glEnable(GL_ALPHA_TEST);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDisable(GL_BLEND);
glShadeModel(GL_SMOOTH);
final FloatBuffer vectorBuffer = BufferUtils.createFloatBuffer(4);
vectorBuffer.clear();
vectorBuffer.put(0, 1.0f).put(1, 1.0f).put(2, 1.0f).put(3, 1.0f);
glLight(GL_LIGHT0, GL_DIFFUSE, vectorBuffer);
vectorBuffer.put(0, 1.0f).put(1, 1.0f).put(2, 1.0f).put(3, 1.0f);
glLight(GL_LIGHT0, GL_AMBIENT, vectorBuffer);
vectorBuffer.put(0, 1.0f).put(1, 1.0f).put(2, 0.5f).put(3, 1.0f);
glLight(GL_LIGHT0, GL_SPECULAR, vectorBuffer);
// Infinite
vectorBuffer.put(0, -1.0f / 3.0f).put(1, 1.0f / 3.0f).put(2, 1.0f / 3.0f).put(3, 0.0f);
glLight(GL_LIGHT0, GL_POSITION, vectorBuffer);
vectorBuffer.put(0, 0.2f).put(1, 0.2f).put(2, 0.2f).put(3, 1.0f);
glLightModel(GL_LIGHT_MODEL_AMBIENT, vectorBuffer);
glEnable(GL_LIGHT0);
glEnable(GL_LIGHTING);
sphere = new Sphere();
if ("PB".equalsIgnoreCase(args[0])) {
backgroundLoader = new BackgroundLoader() {
Drawable getDrawable() throws LWJGLException {
return new Pbuffer(2, 2, new PixelFormat(8, 24, 0), Display.getDrawable());
}
};
} else if ("SD".equalsIgnoreCase(args[0])) {
backgroundLoader = new BackgroundLoader() {
Drawable getDrawable() throws LWJGLException {
return new SharedDrawable(Display.getDrawable());
}
};
} else {
argsError();
}
}
use of org.lwjgl.util.glu.Sphere in project lwjgl by LWJGL.
the class ShadersTest method initialize.
private static void initialize(String[] args) {
if (args.length != 1)
argsError();
try {
DisplayMode[] modes = Display.getAvailableDisplayModes();
DisplayMode displayMode;
displayMode = chooseMode(modes, 1024, 768);
if (displayMode == null)
displayMode = chooseMode(modes, 800, 600);
if (displayMode == null)
displayMode = chooseMode(modes, 640, 480);
if (displayMode == null)
kill("Failed to set an appropriate display mode.");
System.out.println("Setting display mode to: " + displayMode);
Display.setDisplayMode(displayMode);
Display.create(new PixelFormat(8, 24, 0));
ShadersTest.displayMode = displayMode;
} catch (LWJGLException e) {
kill(e.getMessage());
}
final ContextCapabilities caps = GLContext.getCapabilities();
if ("NONE".equalsIgnoreCase(args[0])) {
shader = null;
} else if ("VP".equalsIgnoreCase(args[0])) {
if (!caps.GL_ARB_vertex_program)
kill("The ARB_vertex_program extension is not supported.");
shader = new ShaderVP("shaderVP.vp");
} else if ("FP".equalsIgnoreCase(args[0])) {
if (!caps.GL_ARB_vertex_program)
kill("The ARB_vertex_program extension is not supported.");
if (!caps.GL_ARB_fragment_program)
kill("The ARB_fragment_program extension is not supported.");
shader = new ShaderFP("shaderFP.vp", "shaderFP.fp");
} else if ("VSH".equalsIgnoreCase(args[0])) {
if (!caps.GL_ARB_vertex_shader)
kill("The ARB_vertex_shader extension is not supported.");
shader = new ShaderVSH("shaderVSH.vsh");
} else if ("FSH".equalsIgnoreCase(args[0])) {
if (!caps.GL_ARB_vertex_shader)
kill("The ARB_vertex_shader extension is not supported.");
if (!caps.GL_ARB_fragment_shader)
kill("The ARB_fragment_shader extension is not supported.");
shader = new ShaderFSH("shaderFSH.vsh", "shaderFSH.fsh");
} else if ("UNI".equalsIgnoreCase(args[0])) {
if (!(caps.OpenGL31 || caps.GL_ARB_uniform_buffer_object))
kill("Neither OpenGL version 3.1 nor ARB_uniform_buffer_object are supported.");
shader = new ShaderUNI("shaderUNI.vsh");
} else {
argsError();
}
glViewport(0, 0, displayMode.getWidth(), displayMode.getHeight());
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45, displayMode.getWidth() / (float) displayMode.getHeight(), 1.0f, 10.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
// Setup camera position.
glTranslatef(0.0f, 0.0f, -4.0f);
glRotatef(15.0f, 1.0f, 0.0f, 0.0f);
glPushMatrix();
glClearDepth(1.0f);
glDepthFunc(GL_LEQUAL);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
glFrontFace(GL_CCW);
glPolygonMode(GL_FRONT, GL_FILL);
glCullFace(GL_BACK);
glEnable(GL_CULL_FACE);
glAlphaFunc(GL_NOTEQUAL, 0.0f);
glEnable(GL_ALPHA_TEST);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
// Setup lighting for when we have fixed function fragment rendering.
glShadeModel(GL_SMOOTH);
if (shader == null) {
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
}
vectorBuffer.clear();
vectorBuffer.put(1.0f).put(1.0f).put(1.0f).put(1.0f);
vectorBuffer.clear();
glLight(GL_LIGHT0, GL_DIFFUSE, vectorBuffer);
vectorBuffer.put(1.0f).put(1.0f).put(1.0f).put(1.0f);
vectorBuffer.clear();
glLight(GL_LIGHT0, GL_AMBIENT, vectorBuffer);
vectorBuffer.put(1.0f).put(1.0f).put(0.5f).put(1.0f);
vectorBuffer.clear();
glLight(GL_LIGHT0, GL_SPECULAR, vectorBuffer);
// Infinite
vectorBuffer.put(-1.0f / 3.0f).put(1.0f / 3.0f).put(1.0f / 3.0f).put(0.0f);
vectorBuffer.clear();
glLight(GL_LIGHT0, GL_POSITION, vectorBuffer);
vectorBuffer.put(0.2f).put(0.2f).put(0.2f).put(1.0f);
vectorBuffer.clear();
glLightModel(GL_LIGHT_MODEL_AMBIENT, vectorBuffer);
sphere = new Sphere();
}
use of org.lwjgl.util.glu.Sphere in project ICBM-Classic by BuiltBrokenModding.
the class RenderExplosion method doRender.
@Override
public void doRender(Entity entity, double x, double y, double z, float par8, float par9) {
EntityExplosion entityExplosion = (EntityExplosion) entity;
if (entityExplosion.getBlast() != null) {
// RedM atter Render
if (entityExplosion.getBlast() instanceof BlastRedmatter) {
Tessellator tessellator = Tessellator.instance;
/** Draw Sphere */
GL11.glPushMatrix();
GL11.glTranslatef((float) x, (float) y + entityExplosion.yOffset, (float) z);
RenderUtility.enableBlending();
RenderUtility.disableLighting();
GL11.glColor4f(0.0F, 0.0F, 0.0F, 0.9f);
bindTexture(SharedAssets.GREY_TEXTURE);
Sphere sphere = new Sphere();
float radius = Math.max((BlastRedmatter.ENTITY_DESTROY_RADIUS * (entityExplosion.getBlast().getRadius() / BlastRedmatter.NORMAL_RADIUS)), 6);
sphere.draw(radius, 32, 32);
// Enable Lighting/Glow Off
RenderUtility.enableLighting();
// Disable Blending
RenderUtility.disableBlending();
GL11.glPopMatrix();
/** Draw Vortex
*
* GL11.glPushMatrix(); GL11.glDepthMask(false);
*
* CalclaviaRenderHelper.enableBlending(); CalclaviaRenderHelper.disableLighting();
*
* GL11.glTranslated(x, y, z); GL11.glRotatef(-entity.ticksExisted, 0, 1, 0);
*
* float size = 10; float f10 = 1.0F;
*
* int textureSize = 50; float size4 = size * 5; float float_sizeMinus0_01 =
* textureSize - 0.01F;
*
* float x0 = (textureSize + 0.0F) / size4; float x1 = (textureSize +
* float_sizeMinus0_01) / size4; float x2 = (textureSize + 0.0F) / size4; float x3 =
* (textureSize + float_sizeMinus0_01) / size4;
*
* float renderX = (float) x; float renderY = (float) y; float renderZ = (float) z;
*
* this.bindTexture(TEXTURE_FILE); tessellator.startDrawingQuads();
* tessellator.setBrightness(240); tessellator.setColorRGBA_F(1.0F, 1.0F, 1.0F, 1F);
* tessellator.addVertexWithUV(-size, 0, -size, x1, x3);
* tessellator.addVertexWithUV(-size, 0, +size, x1, x2);
* tessellator.addVertexWithUV(+size, 0, +size, x0, x2);
* tessellator.addVertexWithUV(+size, 0, -size, x0, x3); tessellator.draw();
*
* // Enable Lighting/Glow Off CalclaviaRenderHelper.enableLighting();
*
* // Disable Blending CalclaviaRenderHelper.disableBlending();
*
* GL11.glDepthMask(true); GL11.glPopMatrix(); */
/** Enderdragon Light */
float par2 = (entity.ticksExisted);
while (par2 > 200) par2 -= 100;
RenderHelper.disableStandardItemLighting();
float var41 = (5 + par2) / 200.0F;
float var51 = 0.0F;
if (var41 > 0.8F) {
var51 = (var41 - 0.8F) / 0.2F;
}
Random rand = new Random(432L);
GL11.glPushMatrix();
GL11.glTranslatef((float) x, (float) y, (float) z);
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glShadeModel(GL11.GL_SMOOTH);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
GL11.glDisable(GL11.GL_ALPHA_TEST);
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glDepthMask(false);
GL11.glPushMatrix();
GL11.glTranslatef(0.0F, -1.0F, -2.0F);
for (int i1 = 0; i1 < (var41 + var41 * var41) / 2.0F * 60.0F; ++i1) {
GL11.glRotatef(rand.nextFloat() * 360.0F, 1.0F, 0.0F, 0.0F);
GL11.glRotatef(rand.nextFloat() * 360.0F, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(rand.nextFloat() * 360.0F, 0.0F, 0.0F, 1.0F);
GL11.glRotatef(rand.nextFloat() * 360.0F, 1.0F, 0.0F, 0.0F);
GL11.glRotatef(rand.nextFloat() * 360.0F, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(rand.nextFloat() * 360.0F + var41 * 90.0F, 0.0F, 0.0F, 1.0F);
tessellator.startDrawing(6);
float var81 = rand.nextFloat() * 20.0F + 5.0F + var51 * 10.0F;
float var91 = rand.nextFloat() * 2.0F + 1.0F + var51 * 2.0F;
tessellator.setColorRGBA_I(16777215, (int) (255.0F * (1.0F - var51)));
tessellator.addVertex(0.0D, 0.0D, 0.0D);
tessellator.setColorRGBA_I(0, 0);
tessellator.addVertex(-0.866D * var91, var81, -0.5F * var91);
tessellator.addVertex(0.866D * var91, var81, -0.5F * var91);
tessellator.addVertex(0.0D, var81, 1.0F * var91);
tessellator.addVertex(-0.866D * var91, var81, -0.5F * var91);
tessellator.draw();
}
GL11.glPopMatrix();
GL11.glDepthMask(true);
GL11.glDisable(GL11.GL_CULL_FACE);
GL11.glDisable(GL11.GL_BLEND);
GL11.glShadeModel(GL11.GL_FLAT);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glEnable(GL11.GL_ALPHA_TEST);
RenderHelper.enableStandardItemLighting();
GL11.glPopMatrix();
} else {
if (entityExplosion.getBlast().getRenderModel() != null && entityExplosion.getBlast().getRenderResource() != null) {
GL11.glPushMatrix();
GL11.glTranslatef((float) x, (float) y + 1F, (float) z);
GL11.glRotatef(entityExplosion.rotationPitch, 0.0F, 0.0F, 1.0F);
this.bindTexture(entityExplosion.getBlast().getRenderResource());
entityExplosion.getBlast().getRenderModel().render(entityExplosion, (float) x, (float) y, (float) z, par8, par9, 0.0625F);
GL11.glPopMatrix();
}
}
}
}
use of org.lwjgl.util.glu.Sphere in project Engine by VoltzEngine-Project.
the class FXShockWave method renderParticle.
@Override
public void renderParticle(Tessellator tessellator, float partialTickRate, float par3, float par4, float par5, float par6, float par7) {
GL11.glPushMatrix();
float f11 = (float) (this.prevPosX + (this.posX - this.prevPosX) * (double) partialTickRate - interpPosX);
float f12 = (float) (this.prevPosY + (this.posY - this.prevPosY) * (double) partialTickRate - interpPosY);
float f13 = (float) (this.prevPosZ + (this.posZ - this.prevPosZ) * (double) partialTickRate - interpPosZ);
GL11.glTranslated(f11, f12, f13);
FMLClientHandler.instance().getClient().renderEngine.bindTexture(texture != null ? texture : SharedAssets.FADED_SPHERE_TEXTURE);
RenderUtility.enableBlending();
RenderUtility.disableLighting();
GL11.glColor4f(this.particleRed / 255, this.particleGreen / 255, this.particleBlue / 255, 0.5f);
Sphere sphere = new Sphere();
sphere.draw(this.particleScale, 32, 32);
// Enable Lighting/Glow Off
RenderUtility.enableLighting();
// Disable Blending
RenderUtility.disableBlending();
GL11.glPopMatrix();
}
Aggregations