Example usage for org.lwjgl.opengl GL11 glColor3f

List of usage examples for org.lwjgl.opengl GL11 glColor3f

Introduction

In this page you can find the example usage for org.lwjgl.opengl GL11 glColor3f.

Prototype

public static native void glColor3f(@NativeType("GLfloat") float red, @NativeType("GLfloat") float green,
        @NativeType("GLfloat") float blue);

Source Link

Document

Float version of #glColor3b Color3b

Usage

From source file:game.level.map.TileDefinition.java

License:Open Source License

/**
 * @return the basicFloorColors//w w  w  .j  av  a  2s  .c o m
 */
private static void setBasicWallColor(int i) {
    Colour c = BasicWallColors[i - 1];
    GL11.glColor3f(c.getR(), c.getG(), c.getB());
}

From source file:glvis.renderers.DemandingLightningTriangleStrip.java

@Override
public void render() {
    if (initial) {
        GL11.glClear(16384);//from  w  w w  .  jav  a2  s  .c o  m
        initial = false;
    }

    int LIGHT_POINTS = 288; // 1152
    LIGHT_POINTS = 2;
    //        int LIGHT_POINTS = 1152; // 1152
    float LIGHT_POINT_SEPARATION = 4.42f;

    float LIGHT_Y = 256f;
    float LIGHT_X = 0f;

    short raw = 0;
    float fraw = 0;
    float calc = 0;

    float distx = 0;
    float disty = 0;
    boolean swch = false;
    int hak = 0;

    short rraw = 0;

    float vdist = 0f;

    boolean chswch = false;

    GL11.glEnable(GL11.GL_BLEND); //Enable blending.
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    if (initial) {
        initial = false;
        GL11.glColor4f(0f, 0f, 0f, 1f);
    } else
        GL11.glColor4f(0f, 0f, 0f, 0.01f);
    GL11.glBegin(GL11.GL_QUADS);
    GL11.glVertex2f(0, 0);
    GL11.glVertex2f(1280, 0);
    GL11.glVertex2f(1280, 720);
    GL11.glVertex2f(0, 720);
    short[] samp = provider.getCurrentSample();
    int samplen = provider.getCurrentSampleLength();
    GL11.glDisable(GL11.GL_BLEND); //Enable blending.
    GL11.glColor4f(1f, 1f, 1f, 1f);
    //        GL11.glPolygonMode( GL11.GL_FRONT_AND_BACK, GL11.GL_LINE );

    for (int ie = 0; ie < LIGHT_POINTS; ie++) {
        GL11.glBegin(GL11.GL_TRIANGLE_STRIP);
        //GL11.glColor4f(((float)ie)/LIGHT_POINTS,((float)ie)/LIGHT_POINTS,((float)ie)/LIGHT_POINTS,1f);

        itra++;
        itra %= samplen;
        raw = samp[itra];
        rraw = samp[samplen - (itra + 1)];

        phys_x[ie] /= 2f;
        phys_y[ie] /= 2f;

        distx = -loc_x[ie];
        disty = -loc_y[ie];
        //            phys_x[ie] += distx + raw/64f;
        //            phys_y[ie] += disty + rraw/64f;
        phys_x[ie] += distx + raw / 64f;
        phys_y[ie] += disty + rraw / 64f;

        loc_x[ie] += phys_x[ie] / 16f;
        loc_y[ie] += phys_y[ie] / 16f;

        LIGHT_X = loc_x[ie] * 4 + 1280 / 2;
        LIGHT_Y = loc_y[ie] * 4 + 720 / 2;

        vdist = Math.abs(distx) + Math.abs(disty);
        vdist /= 4f;

        R[ie] /= 1.08;
        G[ie] /= 1.08;
        B[ie] /= 1.08;
        R[ie] += ((Math.abs(loc_y[ie] % 2f) + Math.abs(loc_x[ie] % 2f)) * vdist) / 1024f;
        G[ie] += ((loc_x[ie] % 2f + Math.abs(loc_y[ie] % 2f)) * vdist) / 512f;
        B[ie] += ((Math.abs(loc_x[ie] % 2f) + loc_y[ie] % 2f) * vdist) / 512f;
        LIGHT_X = loc_x[ie] * 2 + 1280 / 2;
        LIGHT_Y = loc_y[ie] * 2 + 720 / 2;
        //            GL11.glColor3f(lR9[ie], lG9[ie], lB9[ie]);
        //            GL11.glVertex2f(lastx9[ie], lasty9[ie]);
        //            GL11.glColor3f(lR8[ie], lG8[ie], lB8[ie]);
        //            GL11.glVertex2f(lastx8[ie], lasty8[ie]);
        //            GL11.glColor3f(lR7[ie], lG7[ie], lB7[ie]);
        //            GL11.glVertex2f(lastx7[ie], lasty7[ie]);

        GL11.glColor3f(lR6[ie], lG6[ie], lB6[ie]);
        GL11.glVertex2f(lastx6[ie], lasty6[ie]);
        GL11.glColor3f(lR5[ie], lG5[ie], lB5[ie]);
        GL11.glVertex2f(lastx5[ie], lasty5[ie]);
        GL11.glColor3f(lR4[ie], lG4[ie], lB4[ie]);
        GL11.glVertex2f(lastx4[ie], lasty4[ie]);
        GL11.glColor3f(lR3[ie], lG3[ie], lB3[ie]);
        GL11.glVertex2f(lastx3[ie], lasty3[ie]);
        GL11.glColor3f(lR2[ie], lG2[ie], lB2[ie]);
        GL11.glVertex2f(lastx2[ie], lasty2[ie]);
        GL11.glColor3f(lR[ie], lG[ie], lB[ie]);
        GL11.glVertex2f(lastx[ie], lasty[ie]);
        GL11.glColor3f(R[ie] * 2, G[ie] * 2, B[ie] * 2);
        GL11.glVertex2f(LIGHT_X, LIGHT_Y);

        lastx9[ie] = lastx8[ie];
        lasty9[ie] = lasty8[ie];
        lastx8[ie] = lastx7[ie];
        lasty8[ie] = lasty7[ie];
        lastx7[ie] = lastx6[ie];
        lasty7[ie] = lasty6[ie];

        lastx6[ie] = lastx5[ie];
        lasty6[ie] = lasty5[ie];
        lastx5[ie] = lastx4[ie];
        lasty5[ie] = lasty4[ie];
        lastx4[ie] = lastx3[ie];
        lasty4[ie] = lasty3[ie];
        lastx3[ie] = lastx2[ie];
        lasty3[ie] = lasty2[ie];
        lastx2[ie] = lastx[ie];
        lasty2[ie] = lasty[ie];
        //            lastx[ie] = LIGHT_X;
        //            lasty[ie] = LIGHT_Y;
        lastx[ie] = LIGHT_X;
        lasty[ie] = LIGHT_Y;

        lR9[ie] = lR8[ie];
        lG9[ie] = lG8[ie];
        lB9[ie] = lB8[ie];
        lR8[ie] = lR7[ie];
        lG8[ie] = lG7[ie];
        lB8[ie] = lB7[ie];
        lR7[ie] = lR6[ie];
        lG7[ie] = lG6[ie];
        lB7[ie] = lB6[ie];

        lR6[ie] = lR5[ie] / 1.2f;
        lG6[ie] = lG5[ie] / 1.2f;
        lB6[ie] = lB5[ie] / 1.2f;
        lR5[ie] = lR4[ie] / 1.2f;
        lG5[ie] = lG4[ie] / 1.2f;
        lB5[ie] = lB4[ie] / 1.2f;
        lR4[ie] = lR3[ie] / 1.2f;
        lG4[ie] = lG3[ie] / 1.2f;
        lB4[ie] = lB3[ie] / 1.2f;
        lR3[ie] = lR2[ie] / 1.2f;
        lG3[ie] = lG2[ie] / 1.2f;
        lB3[ie] = lB2[ie] / 1.2f;
        lR2[ie] = lR[ie] / 1.2f;
        lG2[ie] = lG[ie] / 1.2f;
        lB2[ie] = lB[ie] / 1.2f;
        lR[ie] = R[ie] * 2;
        lG[ie] = G[ie] * 2;
        lB[ie] = B[ie] * 2;
        GL11.glEnd();
    }

    for (int ie = 0; ie < LIGHT_POINTS; ie++) {
        LIGHT_X = loc_x[ie] * 2 + 1280 / 2;
        LIGHT_Y = loc_y[ie] * 2 + 720 / 2;

        GL11.glColorMask(true, true, true, true);
        GL20.glUseProgram(this.shaderProgram);
        GL20.glUniform2f(GL20.glGetUniformLocation(this.shaderProgram, (CharSequence) "location"), LIGHT_X,
                720.0F - LIGHT_Y);
        GL20.glUniform3f(GL20.glGetUniformLocation(this.shaderProgram, (CharSequence) "colour"), R[ie] / 2,
                G[ie] / 2, B[ie] / 2);
        GL11.glEnable(3042);
        GL11.glBlendFunc(1, 1);
        GL11.glBegin(7);
        GL11.glVertex2f(0.0F, 0.0F);
        GL11.glVertex2f(0.0F, 720.0F);
        GL11.glVertex2f(1280.0F, 720.0F);
        GL11.glVertex2f(1280.0F, 0.0F);
        GL11.glEnd();
        GL11.glDisable(3042);
        GL20.glUseProgram(0);

    }
    //
    Display.sync(600);
}

From source file:glvis.renderers.HighIntensityTriangleStrip.java

@Override
public void render() {

    GL11.glClear(16384);/*  w  w  w . java 2s. co m*/

    int LIGHT_POINTS = 288; // 1152
    //        int LIGHT_POINTS = 1152; // 1152
    float LIGHT_POINT_SEPARATION = 4.42f;

    float LIGHT_Y = 256f;
    float LIGHT_X = 0f;

    short raw = 0;
    float fraw = 0;
    float calc = 0;

    float distx = 0;
    float disty = 0;
    boolean swch = false;
    int hak = 0;

    short rraw = 0;

    float vdist = 0f;

    boolean chswch = false;

    //        GL11.glEnable(GL11.GL_BLEND); //Enable blending.
    //        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); 
    GL11.glColor4f(1f, 1f, 1f, 1f);
    //        GL11.glPolygonMode( GL11.GL_FRONT_AND_BACK, GL11.GL_LINE );
    short[] samp = provider.getCurrentSample();
    int samplen = provider.getCurrentSampleLength();
    for (int ie = 0; ie < LIGHT_POINTS; ie++) {
        GL11.glBegin(GL11.GL_TRIANGLE_STRIP);
        //GL11.glColor4f(((float)ie)/LIGHT_POINTS,((float)ie)/LIGHT_POINTS,((float)ie)/LIGHT_POINTS,1f);

        itra++;
        itra %= samplen;
        raw = samp[itra];
        rraw = samp[samplen - (itra + 1)];

        phys_x[ie] /= 2f;
        phys_y[ie] /= 2f;

        distx = -loc_x[ie];
        disty = -loc_y[ie];
        //            phys_x[ie] += distx + raw/64f;
        //            phys_y[ie] += disty + rraw/64f;
        phys_x[ie] += distx + raw / 64f;
        phys_y[ie] += disty + rraw / 64f;

        loc_x[ie] += phys_x[ie] / 16f;
        loc_y[ie] += phys_y[ie] / 16f;

        LIGHT_X = loc_x[ie] * 4 + 1280 / 2;
        LIGHT_Y = loc_y[ie] * 4 + 720 / 2;

        vdist = Math.abs(distx) + Math.abs(disty);
        vdist /= 4f;

        R[ie] /= 1.08;
        G[ie] /= 1.08;
        B[ie] /= 1.08;
        R[ie] += ((Math.abs(loc_y[ie] % 2f) + Math.abs(loc_x[ie] % 2f)) * vdist) / 1024f;
        G[ie] += ((loc_x[ie] % 2f + Math.abs(loc_y[ie] % 2f)) * vdist) / 512f;
        B[ie] += ((Math.abs(loc_x[ie] % 2f) + loc_y[ie] % 2f) * vdist) / 512f;
        LIGHT_X = loc_x[ie] * 4 + 1280 / 2;
        LIGHT_Y = loc_y[ie] * 4 + 720 / 2;
        //            GL11.glColor3f(lR9[ie], lG9[ie], lB9[ie]);
        //            GL11.glVertex2f(lastx9[ie], lasty9[ie]);
        //            GL11.glColor3f(lR8[ie], lG8[ie], lB8[ie]);
        //            GL11.glVertex2f(lastx8[ie], lasty8[ie]);
        //            GL11.glColor3f(lR7[ie], lG7[ie], lB7[ie]);
        //            GL11.glVertex2f(lastx7[ie], lasty7[ie]);

        GL11.glColor3f(lR6[ie], lG6[ie], lB6[ie]);
        GL11.glVertex2f(lastx6[ie], lasty6[ie]);
        GL11.glColor3f(lR5[ie], lG5[ie], lB5[ie]);
        GL11.glVertex2f(lastx5[ie], lasty5[ie]);
        GL11.glColor3f(lR4[ie], lG4[ie], lB4[ie]);
        GL11.glVertex2f(lastx4[ie], lasty4[ie]);
        GL11.glColor3f(lR3[ie], lG3[ie], lB3[ie]);
        GL11.glVertex2f(lastx3[ie], lasty3[ie]);
        GL11.glColor3f(lR2[ie], lG2[ie], lB2[ie]);
        GL11.glVertex2f(lastx2[ie], lasty2[ie]);
        GL11.glColor3f(lR[ie], lG[ie], lB[ie]);
        GL11.glVertex2f(lastx[ie], lasty[ie]);
        GL11.glColor3f(R[ie] * 2, G[ie] * 2, B[ie] * 2);
        GL11.glVertex2f(LIGHT_X, LIGHT_Y);

        lastx9[ie] = lastx8[ie];
        lasty9[ie] = lasty8[ie];
        lastx8[ie] = lastx7[ie];
        lasty8[ie] = lasty7[ie];
        lastx7[ie] = lastx6[ie];
        lasty7[ie] = lasty6[ie];

        lastx6[ie] = lastx5[ie];
        lasty6[ie] = lasty5[ie];
        lastx5[ie] = lastx4[ie];
        lasty5[ie] = lasty4[ie];
        lastx4[ie] = lastx3[ie];
        lasty4[ie] = lasty3[ie];
        lastx3[ie] = lastx2[ie];
        lasty3[ie] = lasty2[ie];
        lastx2[ie] = lastx[ie];
        lasty2[ie] = lasty[ie];
        //            lastx[ie] = LIGHT_X;
        //            lasty[ie] = LIGHT_Y;
        lastx[ie] = LIGHT_X;
        lasty[ie] = LIGHT_Y;

        lR9[ie] = lR8[ie];
        lG9[ie] = lG8[ie];
        lB9[ie] = lB8[ie];
        lR8[ie] = lR7[ie];
        lG8[ie] = lG7[ie];
        lB8[ie] = lB7[ie];
        lR7[ie] = lR6[ie];
        lG7[ie] = lG6[ie];
        lB7[ie] = lB6[ie];

        lR6[ie] = lR5[ie] / 1.2f;
        lG6[ie] = lG5[ie] / 1.2f;
        lB6[ie] = lB5[ie] / 1.2f;
        lR5[ie] = lR4[ie] / 1.2f;
        lG5[ie] = lG4[ie] / 1.2f;
        lB5[ie] = lB4[ie] / 1.2f;
        lR4[ie] = lR3[ie] / 1.2f;
        lG4[ie] = lG3[ie] / 1.2f;
        lB4[ie] = lB3[ie] / 1.2f;
        lR3[ie] = lR2[ie] / 1.2f;
        lG3[ie] = lG2[ie] / 1.2f;
        lB3[ie] = lB2[ie] / 1.2f;
        lR2[ie] = lR[ie] / 1.2f;
        lG2[ie] = lG[ie] / 1.2f;
        lB2[ie] = lB[ie] / 1.2f;
        lR[ie] = R[ie] * 2;
        lG[ie] = G[ie] * 2;
        lB[ie] = B[ie] * 2;
        GL11.glEnd();
    }

    for (int ie = 0; ie < LIGHT_POINTS; ie++) {
        LIGHT_X = loc_x[ie] * 4 + 1280 / 2;
        LIGHT_Y = loc_y[ie] * 4 + 720 / 2;

        GL11.glColorMask(true, true, true, true);
        GL20.glUseProgram(this.shaderProgram);
        GL20.glUniform2f(GL20.glGetUniformLocation(this.shaderProgram, (CharSequence) "location"), LIGHT_X,
                720.0F - LIGHT_Y);
        GL20.glUniform3f(GL20.glGetUniformLocation(this.shaderProgram, (CharSequence) "colour"), R[ie], G[ie],
                B[ie]);
        GL11.glEnable(3042);
        GL11.glBlendFunc(1, 1);
        GL11.glBegin(7);
        GL11.glVertex2f(0.0F, 0.0F);
        GL11.glVertex2f(0.0F, 720.0F);
        GL11.glVertex2f(1280.0F, 720.0F);
        GL11.glVertex2f(1280.0F, 0.0F);
        GL11.glEnd();
        GL11.glDisable(3042);
        GL20.glUseProgram(0);

    }
}

From source file:glvis.renderers.HighIntensityTriangleStripEarly.java

@Override
public void render() {

    GL11.glClear(16384);/*from ww  w  .  j  av  a  2s.  com*/

    int LIGHT_POINTS = 288; // 1152
    float LIGHT_POINT_SEPARATION = 4.42f;

    float LIGHT_Y = 256f;
    float LIGHT_X = 0f;

    short raw = 0;
    float fraw = 0;
    float calc = 0;

    float distx = 0;
    float disty = 0;
    boolean swch = false;
    int hak = 0;

    short rraw = 0;

    float vdist = 0f;

    boolean chswch = false;

    //        GL11.glEnable(GL11.GL_BLEND); //Enable blending.
    //        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); 
    GL11.glColor4f(1f, 1f, 1f, 1f);
    //        GL11.glPolygonMode( GL11.GL_FRONT_AND_BACK, GL11.GL_LINE );
    short[] samp = provider.getCurrentSample();
    int samplen = provider.getCurrentSampleLength();
    for (int ie = 0; ie < LIGHT_POINTS; ie++) {
        GL11.glBegin(GL11.GL_TRIANGLE_STRIP);
        //GL11.glColor4f(((float)ie)/LIGHT_POINTS,((float)ie)/LIGHT_POINTS,((float)ie)/LIGHT_POINTS,1f);

        itra++;
        itra %= samplen;
        raw = samp[itra];
        rraw = samp[samplen - (itra + 1)];

        phys_x[ie] /= 2f;
        phys_y[ie] /= 2f;

        distx = -loc_x[ie];
        disty = -loc_y[ie];
        phys_x[ie] += distx + raw / 64f;
        phys_y[ie] += disty + rraw / 64f;

        loc_x[ie] += phys_x[ie] / 16f;
        loc_y[ie] += phys_y[ie] / 16f;

        LIGHT_X = loc_x[ie] * 4 + 1280 / 2;
        LIGHT_Y = loc_y[ie] * 4 + 720 / 2;

        vdist = Math.abs(distx) + Math.abs(disty);
        vdist /= 4f;

        R[ie] /= 1.08;
        G[ie] /= 1.08;
        B[ie] /= 1.08;
        R[ie] += ((Math.abs(loc_y[ie] % 2f) + Math.abs(loc_x[ie] % 2f)) * vdist) / 1024f;
        G[ie] += ((loc_x[ie] % 2f + Math.abs(loc_y[ie] % 2f)) * vdist) / 512f;
        B[ie] += ((Math.abs(loc_x[ie] % 2f) + loc_y[ie] % 2f) * vdist) / 512f;
        LIGHT_X = loc_x[ie] * 4 + 1280 / 2;
        LIGHT_Y = loc_y[ie] * 4 + 720 / 2;
        GL11.glColor3f(lR6[ie], lG6[ie], lB6[ie]);
        GL11.glVertex2f(lastx6[ie], lasty6[ie]);
        GL11.glColor3f(lR5[ie], lG5[ie], lB5[ie]);
        GL11.glVertex2f(lastx5[ie], lasty5[ie]);
        GL11.glColor3f(lR4[ie], lG4[ie], lB4[ie]);
        GL11.glVertex2f(lastx4[ie], lasty4[ie]);
        GL11.glColor3f(lR3[ie], lG3[ie], lB3[ie]);
        GL11.glVertex2f(lastx3[ie], lasty3[ie]);
        GL11.glColor3f(lR2[ie], lG2[ie], lB2[ie]);
        GL11.glVertex2f(lastx2[ie], lasty2[ie]);
        GL11.glColor3f(lR[ie], lG[ie], lB[ie]);
        GL11.glVertex2f(lastx[ie], lasty[ie]);
        GL11.glColor3f(R[ie] * 2, G[ie] * 2, B[ie] * 2);
        GL11.glVertex2f(LIGHT_X, LIGHT_Y);

        lastx6[ie] = lastx5[ie];
        lasty6[ie] = lasty5[ie];
        lastx5[ie] = lastx4[ie];
        lasty5[ie] = lasty4[ie];
        lastx4[ie] = lastx3[ie];
        lasty4[ie] = lasty3[ie];
        lastx3[ie] = lastx2[ie];
        lasty3[ie] = lasty2[ie];
        lastx2[ie] = lastx[ie];
        lasty2[ie] = lasty[ie];
        lastx[ie] = LIGHT_X;
        lasty[ie] = LIGHT_Y;
        lR6[ie] = lR5[ie];
        lG6[ie] = lG5[ie];
        lB6[ie] = lB5[ie];
        lR5[ie] = lR4[ie];
        lG5[ie] = lG4[ie];
        lB5[ie] = lB4[ie];
        lR4[ie] = lR3[ie];
        lG4[ie] = lG3[ie];
        lB4[ie] = lB3[ie];
        lR3[ie] = lR2[ie];
        lG3[ie] = lG2[ie];
        lB3[ie] = lB2[ie];
        lR2[ie] = lR[ie];
        lG2[ie] = lG[ie];
        lB2[ie] = lB[ie];
        lR[ie] = R[ie] * 2;
        lG[ie] = G[ie] * 2;
        lB[ie] = B[ie] * 2;
        GL11.glEnd();
    }

    for (int ie = 0; ie < LIGHT_POINTS; ie++) {
        LIGHT_X = loc_x[ie] * 4 + 1280 / 2;
        LIGHT_Y = loc_y[ie] * 4 + 720 / 2;

        GL11.glColorMask(true, true, true, true);
        GL20.glUseProgram(this.shaderProgram);
        GL20.glUniform2f(GL20.glGetUniformLocation(this.shaderProgram, (CharSequence) "location"), LIGHT_X,
                720.0F - LIGHT_Y);
        GL20.glUniform3f(GL20.glGetUniformLocation(this.shaderProgram, (CharSequence) "colour"), R[ie], G[ie],
                B[ie]);
        GL11.glEnable(3042);
        GL11.glBlendFunc(1, 1);
        GL11.glBegin(7);
        GL11.glVertex2f(0.0F, 0.0F);
        GL11.glVertex2f(0.0F, 720.0F);
        GL11.glVertex2f(1280.0F, 720.0F);
        GL11.glVertex2f(1280.0F, 0.0F);
        GL11.glEnd();
        GL11.glDisable(3042);
        GL20.glUseProgram(0);

    }
}

From source file:glvis.renderers.LineTestNoLight.java

@Override
public void render() {

    GL11.glClear(16384);/*  w w  w .j a  va 2 s .co  m*/

    int LIGHT_POINTS = 288; // 1152
    float LIGHT_POINT_SEPARATION = 4.42f;

    float LIGHT_Y = 256f;
    float LIGHT_X = 0f;

    short raw = 0;
    float fraw = 0;
    float calc = 0;

    float distx = 0;
    float disty = 0;
    boolean swch = false;
    int hak = 0;

    short rraw = 0;

    float vdist = 0f;
    short[] samp = provider.getCurrentSample();
    int samplen = provider.getCurrentSampleLength();
    boolean chswch = false;
    for (int ie = 0; ie < LIGHT_POINTS; ie++) {

        itra++;
        itra %= samplen;
        raw = samp[itra];
        rraw = samp[samplen - (itra + 1)];

        phys_x[ie] /= 2f;
        phys_y[ie] /= 2f;

        distx = -loc_x[ie];
        disty = -loc_y[ie];
        phys_x[ie] += distx + raw / 64f;
        phys_y[ie] += disty + rraw / 64f;

        loc_x[ie] += phys_x[ie] / 16f;
        loc_y[ie] += phys_y[ie] / 16f;

        LIGHT_X = loc_x[ie] * 4 + 1280 / 2;
        LIGHT_Y = loc_y[ie] * 4 + 720 / 2;

        vdist = Math.abs(distx) + Math.abs(disty);
        vdist /= 4f;

        R[ie] /= 1.08;
        G[ie] /= 1.08;
        B[ie] /= 1.08;
        R[ie] += ((Math.abs(loc_y[ie] % 2f) + Math.abs(loc_x[ie] % 2f)) * vdist) / 1024f;
        G[ie] += ((loc_x[ie] % 2f + Math.abs(loc_y[ie] % 2f)) * vdist) / 512f;
        B[ie] += ((Math.abs(loc_x[ie] % 2f) + loc_y[ie] % 2f) * vdist) / 512f;

    }
    GL11.glColor3f(1f, 1f, 1f);
    ;
    GL11.glBegin(GL11.GL_LINES);
    for (int ie = 0; ie < LIGHT_POINTS; ie++) {
        LIGHT_X = loc_x[ie] * 4 + 1280 / 2;
        LIGHT_Y = loc_y[ie] * 4 + 720 / 2;
        GL11.glVertex2f(LIGHT_X, LIGHT_Y);
    }
    GL11.glEnd();

}

From source file:glvis.renderers.NeatSymmetrical.java

@Override
public void render() {
    if (initial) {
        GL11.glClear(16384);//from   w ww .j a va2s.co  m
        initial = false;
    }

    int LIGHT_POINTS = 288 * 2; // 1152
    //        LIGHT_POINTS = 2;
    //        int LIGHT_POINTS = 1152; // 1152
    float LIGHT_POINT_SEPARATION = 4.42f;

    float LIGHT_Y = 256f;
    float LIGHT_X = 0f;

    short raw = 0;
    float fraw = 0;
    float calc = 0;

    float distx = 0;
    float disty = 0;
    boolean swch = false;
    int hak = 0;

    short rraw = 0;

    float vdist = 0f;

    boolean chswch = false;

    GL11.glEnable(GL11.GL_BLEND); //Enable blending.
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    if (initial) {
        initial = false;
        GL11.glColor4f(0f, 0f, 0f, 1f);
    } else
        GL11.glColor4f(0f, 0f, 0f, 0.1f);
    GL11.glBegin(GL11.GL_QUADS);
    GL11.glVertex2f(0, 0);
    GL11.glVertex2f(1280, 0);
    GL11.glVertex2f(1280, 720);
    GL11.glVertex2f(0, 720);
    GL11.glEnd();
    GL11.glDisable(GL11.GL_BLEND); //Enable blending.
    GL11.glColor4f(1f, 1f, 1f, 1f);
    //        GL11.glPolygonMode( GL11.GL_FRONT_AND_BACK, GL11.GL_LINE );
    short[] samp = provider.getCurrentSample();
    int samplen = provider.getCurrentSampleLength();

    for (int ie = 0; ie < LIGHT_POINTS; ie++) {
        //GL11.glColor4f(((float)ie)/LIGHT_POINTS,((float)ie)/LIGHT_POINTS,((float)ie)/LIGHT_POINTS,1f);

        //            itra ++;
        //            itra %= Player.samplen;
        //            raw = Player.samp[itra];
        //            rraw = Player.samp[Player.samplen-(itra+1)];

        itra++;
        itra %= samplen;
        raw = samp[itra];
        rraw = samp[samplen - (itra + 1)];
        itra++;
        itra %= samplen;
        raw += samp[itra];
        rraw += samp[samplen - (itra + 1)];
        raw /= 2;
        rraw /= 2;

        //            
        phys_x[ie] /= 2f;
        phys_y[ie] /= 2f;

        distx = -loc_x[ie];
        disty = -loc_y[ie];
        //            phys_x[ie] += distx + raw/64f;
        //            phys_y[ie] += disty + rraw/64f;
        phys_x[ie] += distx + raw / 64f;
        phys_y[ie] += disty + rraw / 64f;

        loc_x[ie] += phys_x[ie] / 16f;
        loc_y[ie] += phys_y[ie] / 16f;
        LIGHT_X = loc_x[ie] * 2 + 1280 / 2;
        LIGHT_Y = loc_y[ie] * 2 + 720 / 2;

        GL11.glColorMask(true, true, true, true);
        GL20.glUseProgram(this.shaderProgram);
        GL20.glUniform2f(GL20.glGetUniformLocation(this.shaderProgram, (CharSequence) "location"), LIGHT_X,
                720.0F - LIGHT_Y);
        GL20.glUniform3f(GL20.glGetUniformLocation(this.shaderProgram, (CharSequence) "colour"), R[ie] / 14,
                G[ie] / 14, B[ie] / 14);
        GL11.glEnable(3042);
        GL11.glBlendFunc(1, 1);
        GL11.glBegin(7);
        GL11.glVertex2f(0.0F, 0.0F);
        GL11.glVertex2f(0.0F, 720.0F);
        GL11.glVertex2f(1280.0F, 720.0F);
        GL11.glVertex2f(1280.0F, 0.0F);
        GL11.glEnd();
        GL11.glDisable(3042);
        GL20.glUseProgram(0);

    }

    for (int ie = 0; ie < LIGHT_POINTS; ie++) {
        LIGHT_X = loc_x[ie] * 4 + 1280 / 2;
        LIGHT_Y = loc_y[ie] * 4 + 720 / 2;

        vdist = Math.abs(distx) + Math.abs(disty);
        vdist /= 4f;

        R[ie] /= 1.08;
        G[ie] /= 1.08;
        B[ie] /= 1.08;
        R[ie] += ((Math.abs(loc_y[ie] % 2f) + Math.abs(loc_x[ie] % 2f)) * vdist) / 512f;
        G[ie] += ((loc_x[ie] % 2f + Math.abs(loc_y[ie] % 2f)) * vdist) / 256f;
        B[ie] += ((Math.abs(loc_x[ie] % 2f) + loc_y[ie] % 2f) * vdist) / 256f;
        LIGHT_X = loc_x[ie] * 2 + 1280 / 2;
        LIGHT_Y = loc_y[ie] * 2 + 720 / 2;
        //            GL11.glColor3f(lR9[ie], lG9[ie], lB9[ie]);
        //            GL11.glVertex2f(lastx9[ie], lasty9[ie]);
        //            GL11.glColor3f(lR8[ie], lG8[ie], lB8[ie]);
        //            GL11.glVertex2f(lastx8[ie], lasty8[ie]);
        //            GL11.glColor3f(lR7[ie], lG7[ie], lB7[ie]);
        //            GL11.glVertex2f(lastx7[ie], lasty7[ie]);
        GL11.glBegin(GL11.GL_TRIANGLE_STRIP);

        GL11.glColor3f(lR6[ie], lG6[ie], lB6[ie]);
        GL11.glVertex2f(lastx6[ie], lasty6[ie]);
        GL11.glColor3f(lR5[ie], lG5[ie], lB5[ie]);
        GL11.glVertex2f(lastx5[ie], lasty5[ie]);
        GL11.glColor3f(lR4[ie], lG4[ie], lB4[ie]);
        GL11.glVertex2f(lastx4[ie], lasty4[ie]);
        GL11.glColor3f(lR3[ie], lG3[ie], lB3[ie]);
        GL11.glVertex2f(lastx3[ie], lasty3[ie]);
        GL11.glColor3f(lR2[ie], lG2[ie], lB2[ie]);
        GL11.glVertex2f(lastx2[ie], lasty2[ie]);
        GL11.glColor3f(lR[ie], lG[ie], lB[ie]);
        GL11.glVertex2f(lastx[ie], lasty[ie]);
        GL11.glColor3f(R[ie] * 2, G[ie] * 2, B[ie] * 2);
        GL11.glVertex2f(LIGHT_X, LIGHT_Y);

        lastx9[ie] = lastx8[ie];
        lasty9[ie] = lasty8[ie];
        lastx8[ie] = lastx7[ie];
        lasty8[ie] = lasty7[ie];
        lastx7[ie] = lastx6[ie];
        lasty7[ie] = lasty6[ie];

        lastx6[ie] = lastx5[ie];
        lasty6[ie] = lasty5[ie];
        lastx5[ie] = lastx4[ie];
        lasty5[ie] = lasty4[ie];
        lastx4[ie] = lastx3[ie];
        lasty4[ie] = lasty3[ie];
        lastx3[ie] = lastx2[ie];
        lasty3[ie] = lasty2[ie];
        lastx2[ie] = lastx[ie];
        lasty2[ie] = lasty[ie];
        //            lastx[ie] = LIGHT_X;
        //            lasty[ie] = LIGHT_Y;
        lastx[ie] = LIGHT_X;
        lasty[ie] = LIGHT_Y;

        lR9[ie] = lR8[ie];
        lG9[ie] = lG8[ie];
        lB9[ie] = lB8[ie];
        lR8[ie] = lR7[ie];
        lG8[ie] = lG7[ie];
        lB8[ie] = lB7[ie];
        lR7[ie] = lR6[ie];
        lG7[ie] = lG6[ie];
        lB7[ie] = lB6[ie];

        lR6[ie] = lR5[ie] / 1.2f;
        lG6[ie] = lG5[ie] / 1.2f;
        lB6[ie] = lB5[ie] / 1.2f;
        lR5[ie] = lR4[ie] / 1.2f;
        lG5[ie] = lG4[ie] / 1.2f;
        lB5[ie] = lB4[ie] / 1.2f;
        lR4[ie] = lR3[ie] / 1.2f;
        lG4[ie] = lG3[ie] / 1.2f;
        lB4[ie] = lB3[ie] / 1.2f;
        lR3[ie] = lR2[ie] / 1.2f;
        lG3[ie] = lG2[ie] / 1.2f;
        lB3[ie] = lB2[ie] / 1.2f;
        lR2[ie] = lR[ie] / 1.2f;
        lG2[ie] = lG[ie] / 1.2f;
        lB2[ie] = lB[ie] / 1.2f;
        lR[ie] = R[ie] * 2;
        lG[ie] = G[ie] * 2;
        lB[ie] = B[ie] * 2;
        GL11.glEnd();

    }
    //
}

From source file:graphics.Graph.java

@Override
public void draw() {
    //if (this.changed) {
    setMinMax();//  w  ww. j av a2s . c  o m
    float margin = 20;
    // White backdrop...
    GL11.glColor3f(1, 1, 1);
    GL11.glBegin(GL11.GL_POLYGON);
    GL11.glVertex2f(this.xPos, this.yPos);
    GL11.glVertex2f(this.xPos + this.sizeX, this.yPos);
    GL11.glVertex2f(this.xPos + this.sizeX, this.yPos + this.sizeY);
    GL11.glVertex2f(this.xPos, this.yPos + this.sizeY);
    GL11.glEnd();

    // Black lines around...
    GL11.glColor3f(0, 0, 0);
    GL11.glBegin(GL11.GL_LINE_LOOP);
    GL11.glVertex2f(this.xPos, this.yPos);
    GL11.glVertex2f(this.xPos + this.sizeX, this.yPos);
    GL11.glVertex2f(this.xPos + this.sizeX, this.yPos + this.sizeY);
    GL11.glVertex2f(this.xPos, this.yPos + this.sizeY);
    GL11.glEnd();

    // Moves origo where it should be, based on the dataset...
    GL11.glColor4f(0, 0, 0, 0.25f);
    float origo = this.yPos + 2 * margin;
    if (maxValue == 0 && minValue == 0) {
        origo += (this.sizeY - 3 * margin) / 2;
    } else if (maxValue <= 0 && minValue < 0) {
        origo += this.sizeY - 3 * margin;
    } else if (maxValue > 0 && minValue < 0) {
        origo += ((minValue * -1) / (maxValue + (minValue * -1))) * (this.sizeY - 3 * margin);
    }
    GL11.glBegin(GL11.GL_LINES);
    GL11.glVertex2f(this.xPos + margin, origo);
    GL11.glVertex2f(this.xPos + this.sizeX - margin, origo);
    GL11.glEnd();

    // draws tabs on the origo-line where the values should be put...
    float tabs = 5;
    for (int i = 0; i < dataValues.length; i++) {
        GL11.glBegin(GL11.GL_LINES);
        GL11.glVertex2f(this.xPos + margin + (i * (this.sizeX - 2 * margin) / (this.dataValues.length - 1)),
                origo + tabs);
        GL11.glVertex2f(this.xPos + margin + (i * (this.sizeX - 2 * margin) / (this.dataValues.length - 1)),
                origo - tabs);
        GL11.glEnd();
    }
    Line2D.Double[] lines = new Line2D.Double[dataValues.length - 1];
    for (int i = 0; i < lines.length; i++) {
        if (dataValues[i] == null) {
            continue;
        }
        float x = this.xPos + margin + (i * (this.sizeX - 2 * margin) / (this.dataValues.length - 1));
        float y = (this.yPos + 2 * margin) + ((this.sizeY - 3 * margin)
                * ((this.dataValues[i].getValue() + Math.abs(minValue)) / (maxValue + Math.abs(minValue))));
        float x2 = this.xPos + margin + ((i + 1) * (this.sizeX - 2 * margin) / (this.dataValues.length - 1));
        float y2 = (this.yPos + 2 * margin) + ((this.sizeY - 3 * margin)
                * ((this.dataValues[i + 1].getValue() + Math.abs(minValue)) / (maxValue + Math.abs(minValue))));
        lines[i] = new Line2D.Double(x, y, x2, y2);
    }

    // Draws the value-lines on the graph...
    Line2D.Double origLine = new Line2D.Double(this.xPos + margin, origo,
            this.xPos + margin + (this.sizeX - 2 * margin), origo);
    GL11.glLineWidth(2);
    GL11.glShadeModel(GL11.GL_FLAT);
    GL11.glBegin(GL11.GL_LINE_STRIP);
    for (Line2D.Double line : lines) {
        if (line == null) {
            continue;
        }
        if (line.intersectsLine(origLine)) {
            Point2D interSect = getIntersection(line, origLine);
            if (line.y1 > origo) {
                GL11.glColor4f(0, 1, 0, 1);
                GL11.glVertex2d(line.x1, line.y1);
                GL11.glVertex2d(interSect.getX(), interSect.getY());
                GL11.glColor4f(1, 0, 0, 1);
                GL11.glVertex2d(line.x2, line.y2);
            } else {
                GL11.glColor4f(1, 0, 0, 1);
                GL11.glVertex2d(line.x1, line.y1);
                GL11.glVertex2d(interSect.getX(), interSect.getY());
                GL11.glColor4f(0, 1, 0, 1);
                GL11.glVertex2d(line.x2, line.y2);
            }
        } else {
            if (line.y1 > origo) {
                GL11.glColor4f(0, 1, 0, 1);
                GL11.glVertex2d(line.x1, line.y1);
                GL11.glVertex2d(line.x2, line.y2);
            } else {
                GL11.glColor4f(1, 0, 0, 1);
                GL11.glVertex2d(line.x1, line.y1);
                GL11.glVertex2d(line.x2, line.y2);
            }
        }
    }
    GL11.glEnd();
    GL11.glLineWidth(1);
    GL11.glShadeModel(GL11.GL_SMOOTH);

    // Black lines around box inside the graph...
    GL11.glColor4f(0, 0, 0, 1);
    GL11.glBegin(GL11.GL_LINE_LOOP);
    GL11.glVertex2f(this.xPos + margin, this.yPos + 2 * margin);
    GL11.glVertex2f(this.xPos + this.sizeX - margin, this.yPos + 2 * margin);
    GL11.glVertex2f(this.xPos + this.sizeX - margin, this.yPos + this.sizeY - margin);
    GL11.glVertex2f(this.xPos + margin, this.yPos + this.sizeY - margin);
    GL11.glEnd();

    //this.changed = false;
    origLine = null;
    //}
}

From source file:group.project.unknown.level.entities.Particle.java

License:Apache License

public void render() {
    GL11.glBegin(GL11.GL_QUADS);//from w  w  w .j  a v a 2s  .  c  o m
    {
        GL11.glColor3f(color.x, color.y, color.z);
        GL11.glVertex2f(position.x - cwidth / 2 + cwidth, position.y - cheight / 2);
        GL11.glVertex2f(position.x - cwidth / 2 + cwidth, position.y - cheight / 2 + cheight);
        GL11.glVertex2f(position.x - cwidth / 2, position.y - cheight / 2 + cheight);
        GL11.glVertex2f(position.x - cwidth / 2, position.y - cheight / 2);
    }
    GL11.glEnd();
}

From source file:herzog3d.Game.java

License:Open Source License

/**
 * All rendering is done in here/*from   www.  j ava 2  s . c  om*/
 */
public void draw() {
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
    cam.transform();
    GLUtils.glLightPos(1.0f, 1.0f, 1.0f);
    GL11.glColor3f(1.0f, 1.0f, 1.0f);
    getMap().draw(cam);

    for (Unit unit : units) {
        if (unit.isActive()) {
            unit.draw();
        }
    }

    for (Base base : bases) {
        base.draw(map);
    }
    for (Effect effect : effects) {
        effect.draw();
    }

    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    GL11.glOrtho(0, 800, 600, 0, 0, 1);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    GL11.glDisable(GL11.GL_LIGHTING);
    Material.DEFAULT_WHITE.bind();
    for (HZWidget overlay : overlays) {
        if (overlay.isVisible()) {
            overlay.draw();
        }
    }
    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glEnable(GL11.GL_DEPTH_TEST);

}

From source file:im.bci.jnuit.lwjgl.LwjglNuitRenderer.java

License:Open Source License

private void drawString(Widget widget, String text, LwjglNuitFont.Align align) {
    TextColor c;/*  w  ww  . j  a v a2 s .  c om*/
    if (null == textColor) {
        c = widget.getTextColor();
    } else {
        c = textColor;
    }
    GL11.glColor4f(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha());
    font.drawString(text, align);
    GL11.glColor3f(1f, 1f, 1f);
}