Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package blocks;
- import org.lwjgl.LWJGLException;
- import org.lwjgl.opengl.Display;
- import org.lwjgl.opengl.DisplayMode;
- import org.lwjgl.opengl.GL11;
- public class main {
- static int particleSize = 2;
- public void start() {
- try {
- Display.setDisplayMode(new DisplayMode(800,600));
- Display.create();
- } catch (LWJGLException e) {
- e.printStackTrace();
- System.exit(0);
- }
- // init OpenGL
- GL11.glMatrixMode(GL11.GL_PROJECTION);
- GL11.glLoadIdentity();
- GL11.glOrtho(0, 800, 0, 600, 1, -1);
- GL11.glMatrixMode(GL11.GL_MODELVIEW);
- while (!Display.isCloseRequested()) {
- // Clear the screen and depth buffer
- GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
- // set the color of the quad (R,G,B,A)
- // draw quad
- for (int i = 0; i <= 200; i += 2 ){
- for (int j = 0; j <= 200; j += 2 ){
- particle(i, j, 0.5f, 0.0f, 0.5f);
- }
- }
- Display.update();
- }
- Display.destroy();
- }
- // renders a square or 'particle' of the color specified at the coordinated provided
- public static void particle(int x, int y, float r, float g, float b) {
- GL11.glColor3f(r,g,b);
- GL11.glBegin(GL11.GL_QUADS);
- GL11.glVertex2f(x*particleSize,y*particleSize);
- GL11.glVertex2f(x*particleSize+particleSize,y*particleSize);
- GL11.glVertex2f(x*particleSize+particleSize,y*particleSize+particleSize);
- GL11.glVertex2f(x*particleSize,y*particleSize+particleSize);
- GL11.glEnd();
- }
- public static void main(String[] argv) {
- main quadExample = new main();
- quadExample.start();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement