Skip to content

Commit

Permalink
Rename SIZE and SIZE_IN_BYTES to BYTES
Browse files Browse the repository at this point in the history
  • Loading branch information
integeruser committed Nov 26, 2016
1 parent 9dbd36f commit 2991a98
Show file tree
Hide file tree
Showing 32 changed files with 105 additions and 103 deletions.
10 changes: 6 additions & 4 deletions src/integeruser/jglsdk/glimg/DdsLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public static ImageSet loadFromFile(String ddsFilepath) throws IOException {
throw new DdsFileMalformedException(ddsFilepath, "The Magic number is missing from the file.");
}

if (ddsFile.length < DdsHeader.SIZE + 4) {
if (ddsFile.length < DdsHeader.BYTES + 4) {
throw new DdsFileMalformedException(ddsFilepath, "The data is way too small to store actual information.");
}

Expand Down Expand Up @@ -128,6 +128,8 @@ private static class DxgiFormat {


private static class DdsPixelFormat {
static final int BYTES = Integer.BYTES * (8);

int size;
int flags;
int fourCC;
Expand All @@ -149,7 +151,7 @@ private static class DdsPixelFormatFlags {


private static class DdsHeader {
static final int SIZE = Integer.BYTES * (7 + 11 + 8 + 5);
static final int BYTES = Integer.BYTES * (7 + 11) + DdsPixelFormat.BYTES + Integer.BYTES * (5);

int size;
int flags;
Expand Down Expand Up @@ -242,7 +244,7 @@ private static int readDoubleWord(byte bytes[], int startIx) {
private static Dds10Header getDds10Header(byte[] ddsFile, DdsHeader ddsHeader) {
if (ddsHeader.ddsPixelFormat.fourCC == MagicNumbers.DDS10_FOUR_CC) {
Dds10Header dds10Header = new Dds10Header();
int offsetToNewHeader = DdsHeader.SIZE + 4;
int offsetToNewHeader = DdsHeader.BYTES + 4;

dds10Header.dxgiFormat = readDoubleWord(ddsFile, offsetToNewHeader);
dds10Header.resourceDimension = readDoubleWord(ddsFile, offsetToNewHeader + 4);
Expand Down Expand Up @@ -317,7 +319,7 @@ private static ImageFormat.UncheckedImageFormat getFormat(DdsHeader ddsHeader, D
}

private static int getOffsetToData(DdsHeader ddsHeader) {
int byteOffset = DdsHeader.SIZE + 4;
int byteOffset = DdsHeader.BYTES + 4;
if (ddsHeader.ddsPixelFormat.fourCC == MagicNumbers.DDS10_FOUR_CC) {
byteOffset += Dds10Header.SIZE;
}
Expand Down
8 changes: 4 additions & 4 deletions src/integeruser/jgltut/Tutorial.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ public abstract class Tutorial {
protected FloatBuffer vec4Buffer = BufferUtils.createFloatBuffer(4);
protected FloatBuffer mat3Buffer = BufferUtils.createFloatBuffer(9);
protected FloatBuffer mat4Buffer = BufferUtils.createFloatBuffer(16);
protected ByteBuffer projectionBlockBuffer = BufferUtils.createByteBuffer(ProjectionBlock.SIZE_IN_BYTES);
protected ByteBuffer unprojectionBlockBuffer = BufferUtils.createByteBuffer(UnprojectionBlock.SIZE_IN_BYTES);
protected ByteBuffer lightBlockBuffer = BufferUtils.createByteBuffer(LightBlock.SIZE_IN_BYTES);
protected ByteBuffer materialBlockBuffer = BufferUtils.createByteBuffer(MaterialBlock.SIZE_IN_BYTES);
protected ByteBuffer projectionBlockBuffer = BufferUtils.createByteBuffer(ProjectionBlock.BYTES);
protected ByteBuffer unprojectionBlockBuffer = BufferUtils.createByteBuffer(UnprojectionBlock.BYTES);
protected ByteBuffer lightBlockBuffer = BufferUtils.createByteBuffer(LightBlock.BYTES);
protected ByteBuffer materialBlockBuffer = BufferUtils.createByteBuffer(MaterialBlock.BYTES);

////////////////////////////////

Expand Down
2 changes: 1 addition & 1 deletion src/integeruser/jgltut/commons/LightBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/
public class LightBlock implements Bufferable {
public static final int MAX_NUMBER_OF_LIGHTS = 5;
public static final int SIZE_IN_BYTES = Float.BYTES * (4 + 1 + 1 + 2) + PerLight.SIZE_IN_BYTES * MAX_NUMBER_OF_LIGHTS;
public static final int BYTES = Float.BYTES * (4 + 1 + 1 + 2) + PerLight.BYTES * MAX_NUMBER_OF_LIGHTS;

public Vector4f ambientIntensity;
public float lightAttenuation;
Expand Down
2 changes: 1 addition & 1 deletion src/integeruser/jgltut/commons/MaterialBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* Visit https://github.com/integeruser/jgltut for info and updates.
*/
public class MaterialBlock implements Bufferable {
public static final int SIZE_IN_BYTES = Float.BYTES * (4 + 4 + 1 + 3);
public static final int BYTES = Float.BYTES * (4 + 4 + 1 + 3);

public Vector4f diffuseColor;
public Vector4f specularColor;
Expand Down
2 changes: 1 addition & 1 deletion src/integeruser/jgltut/commons/PerLight.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* Visit https://github.com/integeruser/jgltut for info and updates.
*/
public class PerLight implements Bufferable {
public static final int SIZE_IN_BYTES = Float.BYTES * (4 + 4);
public static final int BYTES = Float.BYTES * (4 + 4);

public Vector4f cameraSpaceLightPos;
public Vector4f lightIntensity;
Expand Down
2 changes: 1 addition & 1 deletion src/integeruser/jgltut/commons/ProjectionBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* Visit https://github.com/integeruser/jgltut for info and updates.
*/
public class ProjectionBlock implements Bufferable {
public static final int SIZE_IN_BYTES = Float.BYTES * (16);
public static final int BYTES = Float.BYTES * (16);

public Matrix4f cameraToClipMatrix;

Expand Down
2 changes: 1 addition & 1 deletion src/integeruser/jgltut/commons/UnprojectionBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* Visit https://github.com/integeruser/jgltut for info and updates.
*/
public class UnprojectionBlock implements Bufferable {
public static final int SIZE_IN_BYTES = Float.BYTES * (16) + Integer.BYTES * (2);
public static final int BYTES = Float.BYTES * (16) + Integer.BYTES * (2);

public Matrix4f clipToCameraMatrix;
public Vector2i windowSize;
Expand Down
4 changes: 2 additions & 2 deletions src/integeruser/jgltut/tut09/AmbientLighting.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ protected void init() {

projectionUniformBuffer = glGenBuffers();
glBindBuffer(GL_UNIFORM_BUFFER, projectionUniformBuffer);
glBufferData(GL_UNIFORM_BUFFER, ProjectionBlock.SIZE_IN_BYTES, GL_DYNAMIC_DRAW);
glBufferData(GL_UNIFORM_BUFFER, ProjectionBlock.BYTES, GL_DYNAMIC_DRAW);

// Bind the static buffers.
glBindBufferRange(GL_UNIFORM_BUFFER, projectionBlockIndex, projectionUniformBuffer, 0, ProjectionBlock.SIZE_IN_BYTES);
glBindBufferRange(GL_UNIFORM_BUFFER, projectionBlockIndex, projectionUniformBuffer, 0, ProjectionBlock.BYTES);

glBindBuffer(GL_UNIFORM_BUFFER, 0);

Expand Down
4 changes: 2 additions & 2 deletions src/integeruser/jgltut/tut09/BasicLighting.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ protected void init() {

projectionUniformBuffer = glGenBuffers();
glBindBuffer(GL_UNIFORM_BUFFER, projectionUniformBuffer);
glBufferData(GL_UNIFORM_BUFFER, ProjectionBlock.SIZE_IN_BYTES, GL_DYNAMIC_DRAW);
glBufferData(GL_UNIFORM_BUFFER, ProjectionBlock.BYTES, GL_DYNAMIC_DRAW);

// Bind the static buffers.
glBindBufferRange(GL_UNIFORM_BUFFER, projectionBlockIndex, projectionUniformBuffer, 0, ProjectionBlock.SIZE_IN_BYTES);
glBindBufferRange(GL_UNIFORM_BUFFER, projectionBlockIndex, projectionUniformBuffer, 0, ProjectionBlock.BYTES);

glBindBuffer(GL_UNIFORM_BUFFER, 0);

Expand Down
4 changes: 2 additions & 2 deletions src/integeruser/jgltut/tut09/ScaleAndLighting.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ protected void init() {

projectionUniformBuffer = glGenBuffers();
glBindBuffer(GL_UNIFORM_BUFFER, projectionUniformBuffer);
glBufferData(GL_UNIFORM_BUFFER, ProjectionBlock.SIZE_IN_BYTES, GL_DYNAMIC_DRAW);
glBufferData(GL_UNIFORM_BUFFER, ProjectionBlock.BYTES, GL_DYNAMIC_DRAW);

// Bind the static buffers.
glBindBufferRange(GL_UNIFORM_BUFFER, projectionBlockIndex, projectionUniformBuffer, 0, ProjectionBlock.SIZE_IN_BYTES);
glBindBufferRange(GL_UNIFORM_BUFFER, projectionBlockIndex, projectionUniformBuffer, 0, ProjectionBlock.BYTES);

glBindBuffer(GL_UNIFORM_BUFFER, 0);

Expand Down
8 changes: 4 additions & 4 deletions src/integeruser/jgltut/tut10/FragmentAttenuation.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,17 @@ protected void init() {

projectionUniformBuffer = glGenBuffers();
glBindBuffer(GL_UNIFORM_BUFFER, projectionUniformBuffer);
glBufferData(GL_UNIFORM_BUFFER, ProjectionBlock.SIZE_IN_BYTES, GL_DYNAMIC_DRAW);
glBufferData(GL_UNIFORM_BUFFER, ProjectionBlock.BYTES, GL_DYNAMIC_DRAW);

unprojectionUniformBuffer = glGenBuffers();
glBindBuffer(GL_UNIFORM_BUFFER, unprojectionUniformBuffer);
GL15.glBufferData(GL_UNIFORM_BUFFER, UnprojectionBlock.SIZE_IN_BYTES, GL_DYNAMIC_DRAW);
GL15.glBufferData(GL_UNIFORM_BUFFER, UnprojectionBlock.BYTES, GL_DYNAMIC_DRAW);

// Bind the static buffers.
glBindBufferRange(GL_UNIFORM_BUFFER, projectionBlockIndex, projectionUniformBuffer, 0, ProjectionBlock.SIZE_IN_BYTES);
glBindBufferRange(GL_UNIFORM_BUFFER, projectionBlockIndex, projectionUniformBuffer, 0, ProjectionBlock.BYTES);

// Bind the static buffers.
glBindBufferRange(GL_UNIFORM_BUFFER, unprojectionBlockIndex, unprojectionUniformBuffer, 0, UnprojectionBlock.SIZE_IN_BYTES);
glBindBufferRange(GL_UNIFORM_BUFFER, unprojectionBlockIndex, unprojectionUniformBuffer, 0, UnprojectionBlock.BYTES);

glBindBuffer(GL_UNIFORM_BUFFER, 0);

Expand Down
4 changes: 2 additions & 2 deletions src/integeruser/jgltut/tut10/FragmentPointLighting.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ protected void init() {

projectionUniformBuffer = glGenBuffers();
glBindBuffer(GL_UNIFORM_BUFFER, projectionUniformBuffer);
glBufferData(GL_UNIFORM_BUFFER, ProjectionBlock.SIZE_IN_BYTES, GL_DYNAMIC_DRAW);
glBufferData(GL_UNIFORM_BUFFER, ProjectionBlock.BYTES, GL_DYNAMIC_DRAW);

// Bind the static buffers.
glBindBufferRange(GL_UNIFORM_BUFFER, projectionBlockIndex, projectionUniformBuffer, 0, ProjectionBlock.SIZE_IN_BYTES);
glBindBufferRange(GL_UNIFORM_BUFFER, projectionBlockIndex, projectionUniformBuffer, 0, ProjectionBlock.BYTES);

glBindBuffer(GL_UNIFORM_BUFFER, 0);

Expand Down
4 changes: 2 additions & 2 deletions src/integeruser/jgltut/tut10/VertexPointLighting.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ protected void init() {

projectionUniformBuffer = glGenBuffers();
glBindBuffer(GL_UNIFORM_BUFFER, projectionUniformBuffer);
glBufferData(GL_UNIFORM_BUFFER, ProjectionBlock.SIZE_IN_BYTES, GL_DYNAMIC_DRAW);
glBufferData(GL_UNIFORM_BUFFER, ProjectionBlock.BYTES, GL_DYNAMIC_DRAW);

// Bind the static buffers.
glBindBufferRange(GL_UNIFORM_BUFFER, projectionBlockIndex, projectionUniformBuffer, 0, ProjectionBlock.SIZE_IN_BYTES);
glBindBufferRange(GL_UNIFORM_BUFFER, projectionBlockIndex, projectionUniformBuffer, 0, ProjectionBlock.BYTES);

glBindBuffer(GL_UNIFORM_BUFFER, 0);

Expand Down
4 changes: 2 additions & 2 deletions src/integeruser/jgltut/tut11/BlinnVsPhongLighting.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ protected void init() {

projectionUniformBuffer = glGenBuffers();
glBindBuffer(GL_UNIFORM_BUFFER, projectionUniformBuffer);
glBufferData(GL_UNIFORM_BUFFER, ProjectionBlock.SIZE_IN_BYTES, GL_DYNAMIC_DRAW);
glBufferData(GL_UNIFORM_BUFFER, ProjectionBlock.BYTES, GL_DYNAMIC_DRAW);

// Bind the static buffers.
glBindBufferRange(GL_UNIFORM_BUFFER, projectionBlockIndex, projectionUniformBuffer, 0, ProjectionBlock.SIZE_IN_BYTES);
glBindBufferRange(GL_UNIFORM_BUFFER, projectionBlockIndex, projectionUniformBuffer, 0, ProjectionBlock.BYTES);

glBindBuffer(GL_UNIFORM_BUFFER, 0);

Expand Down
4 changes: 2 additions & 2 deletions src/integeruser/jgltut/tut11/GaussianSpecularLighting.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ protected void init() {

projectionUniformBuffer = glGenBuffers();
glBindBuffer(GL_UNIFORM_BUFFER, projectionUniformBuffer);
glBufferData(GL_UNIFORM_BUFFER, ProjectionBlock.SIZE_IN_BYTES, GL_DYNAMIC_DRAW);
glBufferData(GL_UNIFORM_BUFFER, ProjectionBlock.BYTES, GL_DYNAMIC_DRAW);

// Bind the static buffers.
glBindBufferRange(GL_UNIFORM_BUFFER, projectionBlockIndex, projectionUniformBuffer, 0, ProjectionBlock.SIZE_IN_BYTES);
glBindBufferRange(GL_UNIFORM_BUFFER, projectionBlockIndex, projectionUniformBuffer, 0, ProjectionBlock.BYTES);

glBindBuffer(GL_UNIFORM_BUFFER, 0);

Expand Down
4 changes: 2 additions & 2 deletions src/integeruser/jgltut/tut11/PhongLighting.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ protected void init() {

projectionUniformBuffer = glGenBuffers();
glBindBuffer(GL_UNIFORM_BUFFER, projectionUniformBuffer);
glBufferData(GL_UNIFORM_BUFFER, ProjectionBlock.SIZE_IN_BYTES, GL_DYNAMIC_DRAW);
glBufferData(GL_UNIFORM_BUFFER, ProjectionBlock.BYTES, GL_DYNAMIC_DRAW);

// Bind the static buffers.
glBindBufferRange(GL_UNIFORM_BUFFER, projectionBlockIndex, projectionUniformBuffer, 0, ProjectionBlock.SIZE_IN_BYTES);
glBindBufferRange(GL_UNIFORM_BUFFER, projectionBlockIndex, projectionUniformBuffer, 0, ProjectionBlock.BYTES);

glBindBuffer(GL_UNIFORM_BUFFER, 0);

Expand Down
8 changes: 4 additions & 4 deletions src/integeruser/jgltut/tut12/GammaCorrection.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,16 @@ ProgramData getProgram(LightingProgramTypes lightingProgramType) {
// Setup our Uniform Buffers
lightUniformBuffer = glGenBuffers();
glBindBuffer(GL_UNIFORM_BUFFER, lightUniformBuffer);
GL15.glBufferData(GL_UNIFORM_BUFFER, LightManager.LightBlockGamma.SIZE, GL_DYNAMIC_DRAW);
GL15.glBufferData(GL_UNIFORM_BUFFER, LightManager.LightBlockGamma.BYTES, GL_DYNAMIC_DRAW);

projectionUniformBuffer = glGenBuffers();
glBindBuffer(GL_UNIFORM_BUFFER, projectionUniformBuffer);
GL15.glBufferData(GL_UNIFORM_BUFFER, ProjectionBlock.SIZE_IN_BYTES, GL_DYNAMIC_DRAW);
GL15.glBufferData(GL_UNIFORM_BUFFER, ProjectionBlock.BYTES, GL_DYNAMIC_DRAW);

// Bind the static buffers.
glBindBufferRange(GL_UNIFORM_BUFFER, lightBlockIndex, lightUniformBuffer, 0, LightManager.LightBlockGamma.SIZE);
glBindBufferRange(GL_UNIFORM_BUFFER, lightBlockIndex, lightUniformBuffer, 0, LightManager.LightBlockGamma.BYTES);

glBindBufferRange(GL_UNIFORM_BUFFER, projectionBlockIndex, projectionUniformBuffer, 0, ProjectionBlock.SIZE_IN_BYTES);
glBindBufferRange(GL_UNIFORM_BUFFER, projectionBlockIndex, projectionUniformBuffer, 0, ProjectionBlock.BYTES);

glBindBuffer(GL_UNIFORM_BUFFER, 0);

Expand Down
8 changes: 4 additions & 4 deletions src/integeruser/jgltut/tut12/HDRLighting.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,16 @@ ProgramData getProgram(LightingProgramTypes lightingProgramType) {
// Setup our Uniform Buffers
lightUniformBuffer = glGenBuffers();
glBindBuffer(GL_UNIFORM_BUFFER, lightUniformBuffer);
GL15.glBufferData(GL_UNIFORM_BUFFER, LightManager.LightBlockHDR.SIZE, GL_DYNAMIC_DRAW);
GL15.glBufferData(GL_UNIFORM_BUFFER, LightManager.LightBlockHDR.BYTES, GL_DYNAMIC_DRAW);

projectionUniformBuffer = glGenBuffers();
glBindBuffer(GL_UNIFORM_BUFFER, projectionUniformBuffer);
GL15.glBufferData(GL_UNIFORM_BUFFER, ProjectionBlock.SIZE_IN_BYTES, GL_DYNAMIC_DRAW);
GL15.glBufferData(GL_UNIFORM_BUFFER, ProjectionBlock.BYTES, GL_DYNAMIC_DRAW);

// Bind the static buffers.
glBindBufferRange(GL_UNIFORM_BUFFER, lightBlockIndex, lightUniformBuffer, 0, LightManager.LightBlockHDR.SIZE);
glBindBufferRange(GL_UNIFORM_BUFFER, lightBlockIndex, lightUniformBuffer, 0, LightManager.LightBlockHDR.BYTES);

glBindBufferRange(GL_UNIFORM_BUFFER, projectionBlockIndex, projectionUniformBuffer, 0, ProjectionBlock.SIZE_IN_BYTES);
glBindBufferRange(GL_UNIFORM_BUFFER, projectionBlockIndex, projectionUniformBuffer, 0, ProjectionBlock.BYTES);

glBindBuffer(GL_UNIFORM_BUFFER, 0);

Expand Down
4 changes: 2 additions & 2 deletions src/integeruser/jgltut/tut12/LightManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ Vector4f getBackgroundColor() {
private static final int NUMBER_OF_POINT_LIGHTS = NUMBER_OF_LIGHTS - 1;

class LightBlockHDR implements Bufferable {
static final int SIZE = Float.BYTES * (4 + 1 + 1 + 2) + PerLight.SIZE_IN_BYTES * NUMBER_OF_LIGHTS;
static final int BYTES = Float.BYTES * (4 + 1 + 1 + 2) + PerLight.BYTES * NUMBER_OF_LIGHTS;

Vector4f ambientIntensity;
float lightAttenuation;
Expand All @@ -234,7 +234,7 @@ public ByteBuffer get(ByteBuffer buffer) {
}

class LightBlockGamma implements Bufferable {
static final int SIZE = Float.BYTES * (4 + 1 + 1 + 2) + PerLight.SIZE_IN_BYTES * NUMBER_OF_LIGHTS;
static final int BYTES = Float.BYTES * (4 + 1 + 1 + 1 + 1) + PerLight.BYTES * NUMBER_OF_LIGHTS;

Vector4f ambientIntensity;
float lightAttenuation;
Expand Down
8 changes: 4 additions & 4 deletions src/integeruser/jgltut/tut12/Scene.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ abstract class Scene {
// Align the size of each MaterialBlock to the uniform buffer alignment.
int uniformBufferAlignSize = glGetInteger(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT);

sizeMaterialBlock = MaterialBlock.SIZE_IN_BYTES;
sizeMaterialBlock = MaterialBlock.BYTES;
sizeMaterialBlock += uniformBufferAlignSize - (sizeMaterialBlock % uniformBufferAlignSize);

int MATERIAL_COUNT = 6;
Expand All @@ -46,7 +46,7 @@ abstract class Scene {
getMaterials(materials);

ByteBuffer materialsBuffer = BufferUtils.createByteBuffer(sizeMaterialUniformBuffer);
final float[] padding = new float[(sizeMaterialBlock - MaterialBlock.SIZE_IN_BYTES) / (Float.SIZE / Byte.SIZE)];
final float[] padding = new float[(sizeMaterialBlock - MaterialBlock.BYTES) / (Float.SIZE / Byte.SIZE)];

for (MaterialBlock materialBlock : materials) {
materialBlock.get(materialsBuffer);
Expand Down Expand Up @@ -165,7 +165,7 @@ void draw(MatrixStackf modelMatrix, int materialBlockIndex, float alphaTetra) {

void drawObject(Mesh mesh, ProgramData progData, int materialBlockIndex, int materialIndex, MatrixStackf modelMatrix) {
glBindBufferRange(GL_UNIFORM_BUFFER, materialBlockIndex, materialUniformBuffer,
materialIndex * sizeMaterialBlock, MaterialBlock.SIZE_IN_BYTES);
materialIndex * sizeMaterialBlock, MaterialBlock.BYTES);

Matrix3f normMatrix = new Matrix3f(modelMatrix);
normMatrix.invert().transpose();
Expand All @@ -182,7 +182,7 @@ void drawObject(Mesh mesh, ProgramData progData, int materialBlockIndex, int mat

void drawObject(Mesh mesh, String meshName, ProgramData progData, int materialBlockIndex, int materialIndex, MatrixStackf modelMatrix) {
glBindBufferRange(GL_UNIFORM_BUFFER, materialBlockIndex, materialUniformBuffer,
materialIndex * sizeMaterialBlock, MaterialBlock.SIZE_IN_BYTES);
materialIndex * sizeMaterialBlock, MaterialBlock.BYTES);

Matrix3f normMatrix = new Matrix3f(modelMatrix);
normMatrix.invert().transpose();
Expand Down
8 changes: 4 additions & 4 deletions src/integeruser/jgltut/tut12/SceneLighting.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,16 @@ ProgramData getProgram(LightingProgramTypes lightingProgramType) {
// Setup our Uniform Buffers
lightUniformBuffer = glGenBuffers();
glBindBuffer(GL_UNIFORM_BUFFER, lightUniformBuffer);
GL15.glBufferData(GL_UNIFORM_BUFFER, LightBlock.SIZE_IN_BYTES, GL_DYNAMIC_DRAW);
GL15.glBufferData(GL_UNIFORM_BUFFER, LightBlock.BYTES, GL_DYNAMIC_DRAW);

projectionUniformBuffer = glGenBuffers();
glBindBuffer(GL_UNIFORM_BUFFER, projectionUniformBuffer);
glBufferData(GL_UNIFORM_BUFFER, ProjectionBlock.SIZE_IN_BYTES, GL_DYNAMIC_DRAW);
glBufferData(GL_UNIFORM_BUFFER, ProjectionBlock.BYTES, GL_DYNAMIC_DRAW);

// Bind the static buffers.
glBindBufferRange(GL_UNIFORM_BUFFER, lightBlockIndex, lightUniformBuffer, 0, LightBlock.SIZE_IN_BYTES);
glBindBufferRange(GL_UNIFORM_BUFFER, lightBlockIndex, lightUniformBuffer, 0, LightBlock.BYTES);

glBindBufferRange(GL_UNIFORM_BUFFER, projectionBlockIndex, projectionUniformBuffer, 0, ProjectionBlock.SIZE_IN_BYTES);
glBindBufferRange(GL_UNIFORM_BUFFER, projectionBlockIndex, projectionUniformBuffer, 0, ProjectionBlock.BYTES);

glBindBuffer(GL_UNIFORM_BUFFER, 0);

Expand Down
Loading

0 comments on commit 2991a98

Please sign in to comment.