Skip to content

Commit 2fcd64a

Browse files
committed
1 parent a724c31 commit 2fcd64a

File tree

80 files changed

+2792
-3310
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+2792
-3310
lines changed

build.gradle

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
apply plugin: 'java'
2-
//apply plugin: 'application'
32
apply plugin: 'kotlin'
43

54

@@ -22,8 +21,8 @@ dependencies {
2221

2322
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
2423

25-
compile 'com.github.kotlin-graphics:glm:cf4471fabc7ec0f54ee2ea721b18fb6abf072335'
26-
compile 'com.github.kotlin-graphics:uno-sdk:a75239db46c8ddc7ca977f87f39f18823b1d0406'
24+
compile 'com.github.kotlin-graphics:glm:5bd25d4a397be05483b0d3103c1f6cc7e6e0235f'
25+
compile 'com.github.kotlin-graphics:uno-sdk:4bf07ffa5ea68e5b462fac7ed8ae951c9060ac2b'
2726
compile 'one.util:streamex:0.6.5'
2827

2928
def jogl = '2.3.2'

src/main/java/main/framework/Framework.java

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import static uno.buffer.UtilKt.destroyBuffers;
2222

2323
/**
24-
*
2524
* @author elect
2625
*/
2726
public class Framework implements GLEventListener, KeyListener, MouseListener {
@@ -94,53 +93,35 @@ public void run() {
9493

9594
@Override
9695
public final void init(GLAutoDrawable drawable) {
97-
98-
GL3 gl3 = drawable.getGL().getGL3();
99-
100-
init(gl3);
101-
96+
init(drawable.getGL().getGL3());
10297
}
10398

10499
protected void init(GL3 gl) {
105-
106100
}
107101

108102
@Override
109103
public final void display(GLAutoDrawable drawable) {
110-
111-
GL3 gl3 = drawable.getGL().getGL3();
112-
113-
display(gl3);
104+
display(drawable.getGL().getGL3());
114105
}
115106

116107
protected void display(GL3 gl) {
117-
118108
}
119109

120110
@Override
121111
public final void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
122-
123-
GL3 gl3 = drawable.getGL().getGL3();
124-
125-
reshape(gl3, width, height);
112+
reshape(drawable.getGL().getGL3(), width, height);
126113
}
127114

128115
protected void reshape(GL3 gl, int width, int height) {
129-
130116
}
131117

132118
@Override
133119
public final void dispose(GLAutoDrawable drawable) {
134-
135-
GL3 gl3 = drawable.getGL().getGL3();
136-
137-
end(gl3);
138-
120+
end(drawable.getGL().getGL3());
139121
destroyBuffers(clearColor, clearDepth, matBuffer, vecBuffer);
140122
}
141123

142124
protected void end(GL3 gl) {
143-
144125
}
145126

146127
@Override
@@ -190,9 +171,11 @@ public void mouseDragged(MouseEvent e) {
190171
public void mouseWheelMoved(MouseEvent e) {
191172
}
192173

193-
/** Note: calling System.exit() synchronously inside the draw, reshape or init callbacks can lead to deadlocks on
174+
/**
175+
* Note: calling System.exit() synchronously inside the draw, reshape or init callbacks can lead to deadlocks on
194176
* certain platforms (in particular, X11) because the JAWT's locking routines cause a global AWT lock to be grabbed.
195-
* Instead run the exit routine in another thread. */
177+
* Instead run the exit routine in another thread.
178+
*/
196179
protected void quit() {
197180
new Thread(new Runnable() {
198181
public void run() {

src/main/java/main/framework/component/Attribute.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,20 +111,20 @@ public Attribute(Element element) {
111111
dataArray.position(0);
112112
}
113113

114-
public void fillBoundBufferObject(GL3 gl3, int offset) {
115-
attribType.writeToBuffer(gl3, GL_ARRAY_BUFFER, dataArray, offset);
114+
public void fillBoundBufferObject(GL3 gl, int offset) {
115+
attribType.writeToBuffer(gl, GL_ARRAY_BUFFER, dataArray, offset);
116116
}
117117

118-
public void setupAttributeArray(GL3 gl3, int offset) {
118+
public void setupAttributeArray(GL3 gl, int offset) {
119119
// System.out.println("glEnableVertexAttribArray(" + index + ")");
120-
gl3.glEnableVertexAttribArray(index);
120+
gl.glEnableVertexAttribArray(index);
121121
if (isIntegral) {
122-
gl3.glVertexAttribIPointer(index, size, attribType.glType(), size * attribType.numBytes(), offset);
122+
gl.glVertexAttribIPointer(index, size, attribType.glType(), size * attribType.numBytes(), offset);
123123
} else {
124124
// System.out.println("glVertexAttribPointer(" + index + ", " + size + ", " + (attribType.glType == GL_FLOAT
125125
// ? "GL_FLOAT" : attribType.glType) + ", " + attribType.normalized + ", "
126126
// + (size * attribType.numBytes) + ", " + offset + ")");
127-
gl3.glVertexAttribPointer(index, size, attribType.glType(), attribType.normalized(),
127+
gl.glVertexAttribPointer(index, size, attribType.glType(), attribType.normalized(),
128128
size * attribType.numBytes(), offset);
129129
}
130130
}

src/main/java/main/framework/component/AttributeType.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ private AttributeType(String nameFromFile, boolean normalized, int glType, int n
3030
this.numBytes = numBytes;
3131
}
3232

33-
public void writeToBuffer(GL3 gl3, int buffer, ByteBuffer theData, int offset) {
33+
public void writeToBuffer(GL3 gl, int buffer, ByteBuffer theData, int offset) {
3434
// System.out.println("glBufferData(" + (buffer == GL_ARRAY_BUFFER ? "GL_ARRAY_BUFFER"
3535
// : buffer == GL_ELEMENT_ARRAY_BUFFER ? "GL_ELEMENT_ARRAY_BUFFER" : buffer)
3636
// + ", " + offset + ", " + theData.capacity() + ")");
37-
gl3.glBufferSubData(buffer, offset, theData.capacity(), theData);
37+
gl.glBufferSubData(buffer, offset, theData.capacity(), theData);
3838
}
3939

4040
public static AttributeType get(String type) {

src/main/java/main/framework/component/Mesh.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -204,42 +204,42 @@ public Mesh(GL3 gl, Class context, String xml) throws ParserConfigurationExcepti
204204
}
205205
}
206206

207-
public void render(GL3 gl3) {
207+
public void render(GL3 gl) {
208208

209209
if (vao.get(0) == 0) {
210210
return;
211211
}
212212

213-
gl3.glBindVertexArray(vao.get(0));
214-
primatives.forEach(renderCmd -> renderCmd.render(gl3));
215-
gl3.glBindVertexArray(0);
213+
gl.glBindVertexArray(vao.get(0));
214+
primatives.forEach(renderCmd -> renderCmd.render(gl));
215+
gl.glBindVertexArray(0);
216216
}
217217

218-
public void render(GL3 gl3, String meshName) {
218+
public void render(GL3 gl, String meshName) {
219219

220220
if (!namedVAOs.containsKey(meshName)) {
221221
return;
222222
}
223223

224-
gl3.glBindVertexArray(namedVAOs.get(meshName));
225-
primatives.forEach(renderCmd -> renderCmd.render(gl3));
226-
gl3.glBindVertexArray(0);
224+
gl.glBindVertexArray(namedVAOs.get(meshName));
225+
primatives.forEach(renderCmd -> renderCmd.render(gl));
226+
gl.glBindVertexArray(0);
227227
}
228228

229-
public void dispose(GL3 gl3) {
229+
public void dispose(GL3 gl) {
230230

231231
attribs.forEach(attrib -> destroyBuffer(attrib.dataArray()));
232232
indexData.forEach(cmd -> destroyBuffer(cmd.dataArray()));
233233

234-
gl3.glDeleteBuffers(1, attribArraysBuffer);
234+
gl.glDeleteBuffers(1, attribArraysBuffer);
235235
if (!indexData.isEmpty()) {
236-
gl3.glDeleteBuffers(1, indexBuffer);
236+
gl.glDeleteBuffers(1, indexBuffer);
237237
}
238238

239-
gl3.glDeleteVertexArrays(1, vao);
239+
gl.glDeleteVertexArrays(1, vao);
240240
namedVAOs.forEach((s, i) -> {
241241
vao.put(0, i);
242-
gl3.glDeleteVertexArrays(1, vao);
242+
gl.glDeleteVertexArrays(1, vao);
243243
});
244244
}
245245

src/main/java/main/framework/component/RenderCmd.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,23 +112,23 @@ private static void processArrays(Element element, RenderCmd cmd) {
112112
}
113113
}
114114

115-
public void fillBoundBufferObject(GL3 gl3, int offset) {
116-
attribType.writeToBuffer(gl3, GL_ELEMENT_ARRAY_BUFFER, dataArray, offset);
115+
public void fillBoundBufferObject(GL3 gl, int offset) {
116+
attribType.writeToBuffer(gl, GL_ELEMENT_ARRAY_BUFFER, dataArray, offset);
117117
}
118118

119119
public int calcByteSize() {
120120
return dataArray.capacity();
121121
}
122122

123-
public void render(GL3 gl3) {
123+
public void render(GL3 gl) {
124124
if (isIndexedCmd) {
125125
// System.out.println("glDrawElements(" + (primType == GL_TRIANGLE_FAN ? "GL_TRIANGLE_FAN"
126126
// : primType == GL_TRIANGLE_STRIP ? "GL_TRIANGLE_STRIP" : primType) + ", " + elemCount + ", "
127127
// + (indexDataType == GL_UNSIGNED_SHORT ? "GL_UNSIGNED_SHORT" : indexDataType) + ", "
128128
// + (start * attribType.numBytes) + ")");
129-
gl3.glDrawElements(primType, elemCount, indexDataType, start * attribType.numBytes());
129+
gl.glDrawElements(primType, elemCount, indexDataType, start * attribType.numBytes());
130130
} else {
131-
gl3.glDrawArrays(primType, start, elemCount);
131+
gl.glDrawArrays(primType, start, elemCount);
132132
}
133133
}
134134

src/main/java/main/tut03/CpuPositionOffset.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public void display(GL3 gl) {
9595
private void computePositionOffsets(Vec2 offset) {
9696

9797
float loopDuration = 5.0f;
98-
float scale = (float) Glm.pi * 2.0f / loopDuration;
98+
float scale = Glm.PIf * 2.0f / loopDuration;
9999

100100
float elapsedTime = (System.currentTimeMillis() - startingTime) / 1_000.0f;
101101

src/main/java/main/tut03/VertPositionOffset.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import com.jogamp.newt.event.KeyEvent;
55
import com.jogamp.opengl.GL3;
66
import com.jogamp.opengl.util.GLBuffers;
7+
import glm.Glm;
78
import glm.vec._2.Vec2;
89
import glm.vec._4.Vec4;
910
import main.framework.Framework;
@@ -98,7 +99,7 @@ public void display(GL3 gl) {
9899
private void computePositionOffsets(Vec2 offset) {
99100

100101
float loopDuration = 5.0f;
101-
float scale = (float) glm.pi * 2f / loopDuration;
102+
float scale = Glm.PIf * 2f / loopDuration;
102103

103104
float elapsedTime = (System.currentTimeMillis() - startingTime) / 1_000f;
104105

src/main/java/main/tut05/DepthFighting.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ private float calcZOffset() {
187187

188188
float start = 2534.0f;
189189
float loopDuration = 5.0f;
190-
float scale = (float) Glm.pi * 2.0f / loopDuration;
190+
float scale = Glm.PIf * 2.0f / loopDuration;
191191

192192
float elapsedTime = (System.currentTimeMillis() - timeStart) / 1_000.0f;
193193

src/main/java/main/tut06/Hierarchy.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ void draw(GL3 gl) {
348348
.push()
349349
.translate(posBaseLeft)
350350
.scale(new Vec3(1.0f, 1.0f, scaleBaseZ));
351-
gl.glUniformMatrix4fv(modelToCameraMatrixUnif, 1, false, modelToCameraStack.to(Framework.matBuffer));
351+
gl.glUniformMatrix4fv(modelToCameraMatrixUnif, 1, false, modelToCameraStack.to(matBuffer));
352352
gl.glDrawElements(GL_TRIANGLES, indexData.length, GL_UNSIGNED_SHORT, 0);
353353
modelToCameraStack.pop();
354354
}
@@ -359,7 +359,7 @@ void draw(GL3 gl) {
359359
.push()
360360
.translate(posBaseRight)
361361
.scale(new Vec3(1.0f, 1.0f, scaleBaseZ));
362-
gl.glUniformMatrix4fv(modelToCameraMatrixUnif, 1, false, modelToCameraStack.to(Framework.matBuffer));
362+
gl.glUniformMatrix4fv(modelToCameraMatrixUnif, 1, false, modelToCameraStack.to(matBuffer));
363363
gl.glDrawElements(GL_TRIANGLES, indexData.length, GL_UNSIGNED_SHORT, 0);
364364
modelToCameraStack.pop();
365365
}
@@ -382,7 +382,7 @@ private void drawUpperArm(GL3 gl, MatrixStack modelToCameraStack) {
382382
.push()
383383
.translate(new Vec3(0.0f, 0.0f, sizeUpperArm / 2.0f - 1.0f))
384384
.scale(new Vec3(1.0f, 1.0f, sizeUpperArm / 2.0f));
385-
gl.glUniformMatrix4fv(modelToCameraMatrixUnif, 1, false, modelToCameraStack.to(Framework.matBuffer));
385+
gl.glUniformMatrix4fv(modelToCameraMatrixUnif, 1, false, modelToCameraStack.to(matBuffer));
386386
gl.glDrawElements(GL_TRIANGLES, indexData.length, GL_UNSIGNED_SHORT, 0);
387387
modelToCameraStack.pop();
388388
}
@@ -403,7 +403,7 @@ private void drawLowerArm(GL3 gl, MatrixStack modelToCameraStack) {
403403
.push()
404404
.translate(new Vec3(0.0f, 0.0f, lengthLowerArm / 2.0f))
405405
.scale(new Vec3(widthLowerArm / 2.0f, widthLowerArm / 2.0f, lengthLowerArm / 2.0f));
406-
gl.glUniformMatrix4fv(modelToCameraMatrixUnif, 1, false, modelToCameraStack.to(Framework.matBuffer));
406+
gl.glUniformMatrix4fv(modelToCameraMatrixUnif, 1, false, modelToCameraStack.to(matBuffer));
407407
gl.glDrawElements(GL_TRIANGLES, indexData.length, GL_UNSIGNED_SHORT, 0);
408408
modelToCameraStack.pop();
409409

@@ -423,7 +423,7 @@ private void drawWrist(GL3 gl, MatrixStack modelToCameraStack) {
423423
modelToCameraStack
424424
.push()
425425
.scale(new Vec3(widthWrist / 2.0f, widthWrist / 2.0f, lenWrist / 2.0f));
426-
gl.glUniformMatrix4fv(modelToCameraMatrixUnif, 1, false, modelToCameraStack.to(Framework.matBuffer));
426+
gl.glUniformMatrix4fv(modelToCameraMatrixUnif, 1, false, modelToCameraStack.to(matBuffer));
427427
gl.glDrawElements(GL_TRIANGLES, indexData.length, GL_UNSIGNED_SHORT, 0);
428428
modelToCameraStack.pop();
429429

@@ -444,7 +444,7 @@ private void drawFingers(GL3 gl, MatrixStack modelToCameraStack) {
444444
.push()
445445
.translate(new Vec3(0.0f, 0.0f, lengthFinger / 2.0f))
446446
.scale(new Vec3(widthFinger / 2.0f, widthFinger / 2.0f, lengthFinger / 2.0f));
447-
gl.glUniformMatrix4fv(modelToCameraMatrixUnif, 1, false, modelToCameraStack.to(Framework.matBuffer));
447+
gl.glUniformMatrix4fv(modelToCameraMatrixUnif, 1, false, modelToCameraStack.to(matBuffer));
448448
gl.glDrawElements(GL_TRIANGLES, indexData.length, GL_UNSIGNED_SHORT, 0);
449449
modelToCameraStack.pop();
450450

@@ -459,7 +459,7 @@ private void drawFingers(GL3 gl, MatrixStack modelToCameraStack) {
459459
.push()
460460
.translate(new Vec3(0.0f, 0.0f, lengthFinger / 2.0f))
461461
.scale(new Vec3(widthFinger / 2.0f, widthFinger / 2.0f, lengthFinger / 2.0f));
462-
gl.glUniformMatrix4fv(modelToCameraMatrixUnif, 1, false, modelToCameraStack.to(Framework.matBuffer));
462+
gl.glUniformMatrix4fv(modelToCameraMatrixUnif, 1, false, modelToCameraStack.to(matBuffer));
463463
gl.glDrawElements(GL_TRIANGLES, indexData.length, GL_UNSIGNED_SHORT, 0);
464464
modelToCameraStack.pop();
465465

@@ -478,7 +478,7 @@ private void drawFingers(GL3 gl, MatrixStack modelToCameraStack) {
478478
.push()
479479
.translate(new Vec3(0.0f, 0.0f, lengthFinger / 2.0f))
480480
.scale(new Vec3(widthFinger / 2.0f, widthFinger / 2.0f, lengthFinger / 2.0f));
481-
gl.glUniformMatrix4fv(modelToCameraMatrixUnif, 1, false, modelToCameraStack.to(Framework.matBuffer));
481+
gl.glUniformMatrix4fv(modelToCameraMatrixUnif, 1, false, modelToCameraStack.to(matBuffer));
482482
gl.glDrawElements(GL_TRIANGLES, indexData.length, GL_UNSIGNED_SHORT, 0);
483483
modelToCameraStack.pop();
484484

@@ -493,7 +493,7 @@ private void drawFingers(GL3 gl, MatrixStack modelToCameraStack) {
493493
.push()
494494
.translate(new Vec3(0.0f, 0.0f, lengthFinger / 2.0f))
495495
.scale(new Vec3(widthFinger / 2.0f, widthFinger / 2.0f, lengthFinger / 2.0f));
496-
gl.glUniformMatrix4fv(modelToCameraMatrixUnif, 1, false, modelToCameraStack.to(Framework.matBuffer));
496+
gl.glUniformMatrix4fv(modelToCameraMatrixUnif, 1, false, modelToCameraStack.to(matBuffer));
497497
gl.glDrawElements(GL_TRIANGLES, indexData.length, GL_UNSIGNED_SHORT, 0);
498498
modelToCameraStack.pop();
499499

0 commit comments

Comments
 (0)