本文整理汇总了Java中com.ra4king.opengl.util.ShaderProgram类的典型用法代码示例。如果您正苦于以下问题:Java ShaderProgram类的具体用法?Java ShaderProgram怎么用?Java ShaderProgram使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ShaderProgram类属于com.ra4king.opengl.util包,在下文中一共展示了ShaderProgram类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadLitProgram
import com.ra4king.opengl.util.ShaderProgram; //导入依赖的package包/类
private ProgramData loadLitProgram(String vertexShader, String fragmentShader) {
ProgramData data = new ProgramData(new ShaderProgram(readFromFile(vertexShader), readFromFile(fragmentShader)));
data.modelToCameraMatrixUniform = data.program.getUniformLocation("modelToCameraMatrix");
data.normalModelTocameraMatrixUniform = data.program.getUniformLocation("normalModelToCameraMatrix");
int materialBlock = data.program.getUniformBlockIndex("Material");
int lightBlock = data.program.getUniformBlockIndex("Light");
int projectionBlock = data.program.getUniformBlockIndex("Projection");
if(materialBlock != GL_INVALID_INDEX)
glUniformBlockBinding(data.program.getProgram(), materialBlock, materialBlockIndex);
glUniformBlockBinding(data.program.getProgram(), lightBlock, lightBlockIndex);
glUniformBlockBinding(data.program.getProgram(), projectionBlock, projectionBlockIndex);
return data;
}
示例2: init
import com.ra4king.opengl.util.ShaderProgram; //导入依赖的package包/类
@Override
public void init() {
glClearColor(0, 0, 0, 0);
program = new ShaderProgram(readFromFile("example3.4.vert"), readFromFile("example3.4.frag"));
timeLocation = program.getUniformLocation("time");
int loopDurationLocation = program.getUniformLocation("loopDuration");
int fragLoopDuration = program.getUniformLocation("fragLoopDuration");
program.begin();
glUniform1f(loopDurationLocation, 5);
glUniform1f(fragLoopDuration, 10);
program.end();
vbo = glGenBuffers();
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glBufferData(GL_ARRAY_BUFFER, (FloatBuffer)BufferUtils.createFloatBuffer(12).put(new float[] { 0.25f, 0.25f, 0.0f, 1.0f,
0.25f, -0.25f, 0.0f, 1.0f,
-0.25f, -0.25f, 0.0f, 1.0f }).flip(), GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
// In core OpenGL, Vertex Array Objects (VAOs) are required for all draw calls. VAOs will be explained in Chapter 5.
glBindVertexArray(glGenVertexArrays());
}
示例3: loadShaders
import com.ra4king.opengl.util.ShaderProgram; //导入依赖的package包/类
private void loadShaders() {
blocksProgram = new ShaderProgram(Utils.readFully(Resources.getInputStream("shaders/blocks.vert")),
Utils.readFully(Resources.getInputStream("shaders/blocks.frag")));
projectionMatrixUniform = blocksProgram.getUniformLocation("projectionMatrix");
viewMatrixUniform = blocksProgram.getUniformLocation("viewMatrix");
normalMatrixUniform = blocksProgram.getUniformLocation("normalMatrix");
blocksProgram.begin();
glUniform1f(blocksProgram.getUniformLocation("cubeSize"), Chunk.BLOCK_SIZE);
blocksProgram.end();
deferredProgram = new ShaderProgram(Utils.readFully(Resources.getInputStream("shaders/deferred.vert")),
Utils.readFully(Resources.getInputStream("shaders/deferred.geom")),
Utils.readFully(Resources.getInputStream("shaders/deferred.frag")));
}
示例4: init
import com.ra4king.opengl.util.ShaderProgram; //导入依赖的package包/类
@Override
public void init() {
glClearColor(0, 0, 0, 0);
HashMap<Integer,String> attributes = new HashMap<>();
attributes.put(0, "position");
program = new ShaderProgram(readFromFile("example3.3.vert"), readFromFile("example3.3.frag"), attributes);
timeLocation = glGetUniformLocation(program.getProgram(), "time");
int loopDurationLocation = glGetUniformLocation(program.getProgram(), "loopDuration");
program.begin();
glUniform1f(loopDurationLocation, 5);
program.end();
vbo = glGenBuffers();
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glBufferData(GL_ARRAY_BUFFER, (FloatBuffer)BufferUtils.createFloatBuffer(12).put(new float[] { 0.25f, 0.25f, 0.0f, 1.0f,
0.25f, -0.25f, 0.0f, 1.0f,
-0.25f, -0.25f, 0.0f, 1.0f }).flip(), GL_STATIC_DRAW);
glBindVertexArray(glGenVertexArrays());
glBindBuffer(GL_ARRAY_BUFFER, 0);
}
示例5: init
import com.ra4king.opengl.util.ShaderProgram; //导入依赖的package包/类
@Override
public void init() {
glClearColor(0, 0, 0, 0);
HashMap<Integer,String> attributes = new HashMap<>();
attributes.put(0, "position");
program = new ShaderProgram(readFromFile("example3.1.vert"), readFromFile("example3.1.frag"), attributes);
vbo = glGenBuffers();
vertexData = (FloatBuffer)BufferUtils.createFloatBuffer(12).put(new float[] { 0.25f, 0.25f, 0.0f, 1.0f,
0.25f, -0.25f, 0.0f, 1.0f,
-0.25f, -0.25f, 0.0f, 1.0f }).flip();
newData = BufferUtils.createFloatBuffer(12);
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glBufferData(GL_ARRAY_BUFFER, vertexData, GL_STREAM_DRAW);
glBindVertexArray(glGenVertexArrays());
glBindBuffer(GL_ARRAY_BUFFER, 0);
}
示例6: init
import com.ra4king.opengl.util.ShaderProgram; //导入依赖的package包/类
@Override
public void init() {
glClearColor(0, 0, 0, 0);
program = new ShaderProgram(readFromFile("example2.2.vert"), readFromFile("example2.2.frag"));
vbo = glGenBuffers();
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glBufferData(GL_ARRAY_BUFFER, (FloatBuffer)BufferUtils.createFloatBuffer(24).put(new float[] { 0.0f, 0.5f, 0.0f, 1.0f,
0.5f, -0.366f, 0.0f, 1.0f,
-0.5f, -0.366f, 0.0f, 1.0f,
1.0f, 0.0f, 0.0f, 1.0f,
0.0f, 1.0f, 0.0f, 1.0f,
0.0f, 0.0f, 1.0f, 1.0f }).flip(), GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
// In core OpenGL, Vertex Array Objects (VAOs) are required for all draw calls. VAOs will be explained in Chapter 5.
glBindVertexArray(glGenVertexArrays());
}
示例7: init
import com.ra4king.opengl.util.ShaderProgram; //导入依赖的package包/类
@Override
public void init() {
glClearColor(0, 0, 0, 0);
HashMap<Integer,String> attributes = new HashMap<>();
attributes.put(0, "position");
program = new ShaderProgram(readFromFile("example3.2.vert"), readFromFile("example3.2.frag"), attributes);
offsetLocation = glGetUniformLocation(program.getProgram(), "offset");
vbo = glGenBuffers();
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glBufferData(GL_ARRAY_BUFFER, (FloatBuffer)BufferUtils.createFloatBuffer(12).put(new float[] { 0.25f, 0.25f, 0.0f, 1.0f,
0.25f, -0.25f, 0.0f, 1.0f,
-0.25f, -0.25f, 0.0f, 1.0f }).flip(), GL_STATIC_DRAW);
glBindVertexArray(glGenVertexArrays());
glBindBuffer(GL_ARRAY_BUFFER, 0);
}
示例8: init
import com.ra4king.opengl.util.ShaderProgram; //导入依赖的package包/类
@Override
public void init() {
glClearColor(0, 0, 0, 0);
HashMap<Integer,String> attributes = new HashMap<>();
attributes.put(0, "position");
attributes.put(1, "color");
program = new ShaderProgram(readFromFile("example2.2.vert"), readFromFile("example2.2.frag"), attributes);
vbo = glGenBuffers();
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glBufferData(GL_ARRAY_BUFFER, (FloatBuffer)BufferUtils.createFloatBuffer(24).put(new float[] { 0.0f, 0.5f, 0.0f, 1.0f,
0.5f, -0.366f, 0.0f, 1.0f,
-0.5f, -0.366f, 0.0f, 1.0f,
1.0f, 0.0f, 0.0f, 1.0f,
0.0f, 1.0f, 0.0f, 1.0f,
0.0f, 0.0f, 1.0f, 1.0f }).flip(), GL_STATIC_DRAW);
glBindVertexArray(glGenVertexArrays());
glBindBuffer(GL_ARRAY_BUFFER, 0);
}
示例9: loadLitShader
import com.ra4king.opengl.util.ShaderProgram; //导入依赖的package包/类
private ProgramData loadLitShader(String vertFile, String fragFile) {
ProgramData data = new ProgramData(new ShaderProgram(readFromFile(vertFile), readFromFile(fragFile)));
data.modelToCameraMatrixUniform = data.program.getUniformLocation("modelToCameraMatrix");
data.lightIntensityUniform = data.program.getUniformLocation("lightIntensity");
data.ambientIntensityUniform = data.program.getUniformLocation("ambientIntensity");
data.normalModelToCameraMatrixUniform = data.program.getUniformLocation("normalModelToCameraMatrix");
data.cameraSpaceLightPosUniform = data.program.getUniformLocation("cameraSpaceLightPos");
data.lightAttenuationUniform = data.program.getUniformLocation("lightAttenuation");
data.useRSquareUniform = data.program.getUniformLocation("useRSquare");
int projectionBlock = data.program.getUniformBlockIndex("Projection");
glUniformBlockBinding(data.program.getProgram(), projectionBlock, projectionBlockIndex);
int unprojectionBlock = data.program.getUniformBlockIndex("UnProjection");
glUniformBlockBinding(data.program.getProgram(), unprojectionBlock, unprojectionBlockIndex);
return data;
}
示例10: loadProgram
import com.ra4king.opengl.util.ShaderProgram; //导入依赖的package包/类
private ProgramData loadProgram(String vertexShader, String fragmentShader) {
ProgramData data = new ProgramData(new ShaderProgram(readFromFile(vertexShader), readFromFile(fragmentShader)));
data.modelToCameraMatrixUniform = data.program.getUniformLocation("modelToCameraMatrix");
data.numberOfLightsUniform = data.program.getUniformLocation("numberOfLights");
int projectionBlock = data.program.getUniformBlockIndex("Projection");
glUniformBlockBinding(data.program.getProgram(), projectionBlock, projectionBlockIndex);
int lightBlock = data.program.getUniformBlockIndex("Light");
glUniformBlockBinding(data.program.getProgram(), lightBlock, lightBlockIndex);
int colorTextureUniform = data.program.getUniformLocation("diffuseColorTex");
data.program.begin();
glUniform1i(colorTextureUniform, colorTexUnit);
data.program.end();
return data;
}
示例11: initializePrograms
import com.ra4king.opengl.util.ShaderProgram; //导入依赖的package包/类
private void initializePrograms() {
String vertexShader = readFromFile("example16.1.ScreenCoords.vert");
noGammaProgram = new ShaderProgram(vertexShader, readFromFile("example16.1.TextureNoGamma.frag"));
int projectionBlock = noGammaProgram.getUniformBlockIndex("Projection");
glUniformBlockBinding(noGammaProgram.getProgram(), projectionBlock, projectionBlockIndex);
int colorTextureUniform = noGammaProgram.getUniformLocation("colorTexture");
noGammaProgram.begin();
glUniform1i(colorTextureUniform, gammaRampTextureUnit);
noGammaProgram.end();
gammaProgram = new ShaderProgram(vertexShader, readFromFile("example16.1.TextureGamma.frag"));
projectionBlock = gammaProgram.getUniformBlockIndex("Projection");
glUniformBlockBinding(gammaProgram.getProgram(), projectionBlock, projectionBlockIndex);
colorTextureUniform = gammaProgram.getUniformLocation("colorTexture");
gammaProgram.begin();
glUniform1i(colorTextureUniform, gammaRampTextureUnit);
gammaProgram.end();
}
示例12: loadStandardProgram
import com.ra4king.opengl.util.ShaderProgram; //导入依赖的package包/类
private ProgramData loadStandardProgram(String vertexShader, String fragmentShader) {
ProgramData data = new ProgramData(new ShaderProgram(readFromFile(vertexShader), readFromFile(fragmentShader)));
data.modelToCameraMatrixUniform = data.program.getUniformLocation("modelToCameraMatrix");
data.normalModelToCameraMatrixUniform = data.program.getUniformLocation("normalModelToCameraMatrix");
int materialBlock = data.program.getUniformBlockIndex("Material");
int lightBlock = data.program.getUniformBlockIndex("Light");
int projectionBlock = data.program.getUniformBlockIndex("Projection");
glUniformBlockBinding(data.program.getProgram(), materialBlock, materialBlockIndex);
glUniformBlockBinding(data.program.getProgram(), lightBlock, lightBlockIndex);
glUniformBlockBinding(data.program.getProgram(), projectionBlock, projectionBlockIndex);
int gaussianTextureUniform = data.program.getUniformLocation("gaussianTexture");
int shininessTextureUniform = data.program.getUniformLocation("shininessTexture");
data.program.begin();
glUniform1i(gaussianTextureUniform, gaussTexUnit);
glUniform1i(shininessTextureUniform, shineTexUnit);
data.program.end();
return data;
}
示例13: loadStandardProgram
import com.ra4king.opengl.util.ShaderProgram; //导入依赖的package包/类
private ProgramData loadStandardProgram(String vertexShader, String fragmentShader) {
ProgramData data = new ProgramData(new ShaderProgram(readFromFile(vertexShader), readFromFile(fragmentShader)));
data.modelToCameraMatrixUniform = data.program.getUniformLocation("modelToCameraMatrix");
data.normalModelToCameraMatrixUniform = data.program.getUniformLocation("normalModelToCameraMatrix");
int materialBlock = data.program.getUniformBlockIndex("Material");
int lightBlock = data.program.getUniformBlockIndex("Light");
int projectionBlock = data.program.getUniformBlockIndex("Projection");
glUniformBlockBinding(data.program.getProgram(), materialBlock, materialBlockIndex);
glUniformBlockBinding(data.program.getProgram(), lightBlock, lightBlockIndex);
glUniformBlockBinding(data.program.getProgram(), projectionBlock, projectionBlockIndex);
int gaussianTextureUniform = data.program.getUniformLocation("gaussianTexture");
data.program.begin();
glUniform1i(gaussianTextureUniform, gaussTexUnit);
data.program.end();
return data;
}
示例14: loadLitProgram
import com.ra4king.opengl.util.ShaderProgram; //导入依赖的package包/类
private ProgramData loadLitProgram(String vertexFile, String fragmentFile) {
ProgramData data = new ProgramData(new ShaderProgram(readFromFile(vertexFile), readFromFile(fragmentFile)));
data.modelToCameraMatrixUniform = data.program.getUniformLocation("modelToCameraMatrix");
data.lightIntensityUniform = data.program.getUniformLocation("lightIntensity");
data.ambientIntensityUniform = data.program.getUniformLocation("ambientIntensity");
data.normalModelToCameraMatrixUniform = data.program.getUniformLocation("normalModelToCameraMatrix");
data.cameraSpaceLightPositionUniform = data.program.getUniformLocation("cameraSpaceLightPos");
data.lightAttenuationUniform = data.program.getUniformLocation("lightAttenuation");
data.shininessFactorUniform = data.program.getUniformLocation("shininessFactor");
data.baseDiffuseColorUniform = data.program.getUniformLocation("baseDiffuseColor");
int projectionBlock = data.program.getUniformBlockIndex("Projection");
glUniformBlockBinding(data.program.getProgram(), projectionBlock, projectionBlockIndex);
return data;
}
示例15: loadLitProgram
import com.ra4king.opengl.util.ShaderProgram; //导入依赖的package包/类
private ProgramData loadLitProgram(String vertFile, String fragFile) {
ProgramData data = new ProgramData(new ShaderProgram(readFromFile(vertFile), readFromFile(fragFile)));
data.modelToCameraMatrixUniform = data.program.getUniformLocation("modelToCameraMatrix");
data.lightIntensityUniform = data.program.getUniformLocation("lightIntensity");
data.ambientIntensityUniform = data.program.getUniformLocation("ambientIntensity");
data.normalModelToCameraMatrixUniform = data.program.getUniformLocation("normalModelToCameraMatrix");
data.cameraSpaceLightPosUniform = data.program.getUniformLocation("cameraSpaceLightPos");
data.lightAttenuationUniform = data.program.getUniformLocation("lightAttenuation");
data.shininessFactorUniform = data.program.getUniformLocation("shininessFactor");
data.baseDiffuseColorUniform = data.program.getUniformLocation("baseDiffuseColor");
int projectionBlock = data.program.getUniformBlockIndex("Projection");
glUniformBlockBinding(data.program.getProgram(), projectionBlock, projectionBlockIndex);
return data;
}