Professional Documents
Culture Documents
Ex1 Example
Ex1 Example
Ex1 Example
*/
import org.lwjgl.glfw.*;
import org.lwjgl.opengl.*;
import java.nio.ByteBuffer;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
// instance variables
/////////////////
///////////////////
1.0f, 1.0f, 0.0f, // Right of B
1.0f, 0.2f, 0.0f,
0.8f, 0.2f, 0.0f,
//////////////////
//////////////////
///////////////////
///////////////////
};
////////////////
// Red
1.0f, 0.0f, 0.0f, // Bottom of A
1.0f, 0.0f, 0.0f,
1.0f, 0.0f, 0.0f,
/////////////////
// Lime/Green
0.0f, 1.0f, 0.0f, // Right of B
0.0f, 1.0f, 0.0f,
0.0f, 1.0f, 0.0f,
/////////////////
// Cyan/Agua
0.0f, 1.0f, 1.0f, // Top of C
0.0f, 1.0f, 1.0f,
0.0f, 1.0f, 1.0f,
/////////////////
// Yellow
1.0f, 1.0f, 0.0f, // Bottom of D
1.0f, 1.0f, 0.0f,
1.0f, 1.0f, 0.0f,
/////////////////
// Fuchsia/Magenta
1.0f, 0.0f, 1.0f, // Top of E
1.0f, 0.0f, 1.0f,
1.0f, 0.0f, 1.0f,
/////////////////
// Blue
0.0f, 0.0f, 1.0f, // Bottom of F
0.0f, 0.0f, 1.0f,
0.0f, 0.0f, 1.0f,
/////////////////
};
// construct basic application with given title, pixel width and height
// of drawing area, and frames per second
public OneTri( String appTitle, int pw, int ph, int fps )
{
super( appTitle, pw, ph, (long) ((1.0/fps)*1000000000) );
}
String fragmentShaderCode =
"#version 330 core\n"+
"in vec3 color;\n"+
"layout (location = 0 ) out vec4 fragColor;\n"+
"void main(void)\n"+
"{\n"+
" fragColor = vec4(color, 1.0 );\n"+
"}\n";
hp1 = GL20.glCreateProgram();
Util.error("after create program");
System.out.println("program handle is " + hp1 );
GL20.glUseProgram( hp1 );
Util.error("after use program");
//GL15.drdrawRectangle();
// GL20.
}
// activate vao
GL30.glBindVertexArray( vao );
Util.error("after bind vao");
}// OneTri