[DEV] add basic test for Textured model
This commit is contained in:
parent
e9fe2b9649
commit
b84960ae9c
@ -65,7 +65,7 @@ public class Transform3D {
|
||||
return new Transform3D(invMatrix.multiply(this.position.multiply_new(-1)), invQuaternion);
|
||||
}
|
||||
/// Return an interpolated transform
|
||||
Transform3D interpolateTransforms(Transform3D old,
|
||||
public Transform3D interpolateTransforms(Transform3D old,
|
||||
Transform3D newOne,
|
||||
float interpolationFactor) {
|
||||
Vector3f interPosition = old.position.multiply_new(1.0f - interpolationFactor)
|
||||
@ -75,24 +75,24 @@ public class Transform3D {
|
||||
return new Transform3D(interPosition, interOrientation);
|
||||
}
|
||||
/// Return the transformed vector
|
||||
Vector3f multiply(Vector3f vector) {
|
||||
public Vector3f multiply(Vector3f vector) {
|
||||
return this.orientation.getMatrix().multiply(vector).add(this.position);
|
||||
}
|
||||
/// Operator of multiplication of a transform with another one
|
||||
Transform3D multiply_new(Transform3D transform2) {
|
||||
public Transform3D multiply_new(Transform3D transform2) {
|
||||
return new Transform3D(this.orientation.getMatrix().multiply(transform2.position).add(this.position),
|
||||
this.orientation.multiply_new(transform2.orientation));
|
||||
}
|
||||
/// Return true if the two transforms are equal
|
||||
boolean isEqual(Transform3D transform2) {
|
||||
public boolean isEqual(Transform3D transform2) {
|
||||
return this.position.isEqual(transform2.position) && this.orientation.isEqual(transform2.orientation);
|
||||
}
|
||||
/// Return true if the two transforms are different
|
||||
boolean isDifferent(Transform3D transform2) {
|
||||
public boolean isDifferent(Transform3D transform2) {
|
||||
return this.position.isDifferent(transform2.position) || this.orientation.isDifferent(transform2.orientation);
|
||||
}
|
||||
/// Assignment operator
|
||||
Transform3D set(Transform3D transform) {
|
||||
public Transform3D set(Transform3D transform) {
|
||||
this.position = transform.position.clone();
|
||||
this.orientation = transform.orientation.clone();
|
||||
return this;
|
||||
|
@ -48,7 +48,7 @@ public class Application {
|
||||
* @param[in] context Current gale context.
|
||||
*/
|
||||
public void onRegenerateDisplay(Context context) {
|
||||
Log.verbose("Regenerate Gale Application");
|
||||
//Log.verbose("Regenerate Gale Application");
|
||||
markDrawingIsNeeded();
|
||||
}
|
||||
|
||||
@ -157,7 +157,11 @@ public class Application {
|
||||
* @param[in] size New size of the window.
|
||||
*/
|
||||
public void onResize(Vector2f size) {
|
||||
|
||||
if (size == null) {
|
||||
Log.error("Try to set a null size ...");
|
||||
return;
|
||||
}
|
||||
windowsSize = size;
|
||||
}
|
||||
/**
|
||||
* @brief Set the size of the window (if possible: Android and Ios does not support it)
|
||||
@ -179,6 +183,9 @@ public class Application {
|
||||
public Vector2f getSize() {
|
||||
return windowsSize;
|
||||
}
|
||||
public float getAspectRatio() {
|
||||
return windowsSize.x/windowsSize.y;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Event generated when user change the position of the window.
|
||||
|
@ -195,6 +195,12 @@ public class OpenGL {
|
||||
elem.getValue().mustBeSet = false;
|
||||
}
|
||||
}
|
||||
public static void resetFlagState() {
|
||||
for (Map.Entry<Flag, StateFlag> elem: flagsStates.entrySet()) {
|
||||
elem.getValue().mustBeSet = false;
|
||||
}
|
||||
flagsStatesChange = true;
|
||||
}
|
||||
private static Map<Long, Boolean> threadHasContext = new HashMap<Long, Boolean>();
|
||||
/**
|
||||
* @brief Get the current thread context status.
|
||||
@ -519,7 +525,7 @@ public class OpenGL {
|
||||
* @brief Use openGL program
|
||||
* @param[in] id Id of the program that might be used
|
||||
*/
|
||||
public static void useProgram(int id) {
|
||||
public static void programUse(int id) {
|
||||
//Log.verbose("USE prog : " + id);
|
||||
// note : In normal openGL case, the system might call with the program ID and at the end with 0,
|
||||
// here, we wrap this use to prevent over call of glUseProgram == > then we set -1 when the
|
||||
@ -534,7 +540,7 @@ public class OpenGL {
|
||||
}
|
||||
checkGlError("glUseProgram");
|
||||
}
|
||||
public static void unUseProgram(int id) {
|
||||
public static void programUnUse(int id) {
|
||||
// nothing to do ...
|
||||
}
|
||||
public static void reset() {
|
||||
@ -859,5 +865,8 @@ public class OpenGL {
|
||||
public static void programLoadUniformMatrix(int location, Matrix4f value, boolean transpose) {
|
||||
GL20.glUniformMatrix4fv(location, transpose, value.getTable());
|
||||
}
|
||||
public static void drawElements(RenderMode mode, int vertexCount) {
|
||||
GL11.glDrawElements(convertRenderMode.get(mode), vertexCount, GL11.GL_UNSIGNED_INT, 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -56,6 +56,7 @@ class PeriodicThread extends ThreadAbstract {
|
||||
};
|
||||
|
||||
public abstract class Context {
|
||||
protected final int MAX_MANAGE_INPUT = 15;
|
||||
protected ThreadAbstract periodicThread;
|
||||
protected Application application; //!< Application handle
|
||||
public Application getApplication() {
|
||||
@ -167,7 +168,7 @@ public abstract class Context {
|
||||
// simulation area:
|
||||
private long previousDisplayTime; // this is to limit framerate ... in case...
|
||||
private Vector<ActionToDoInAsyncLoop> msgSystem = new Vector<ActionToDoInAsyncLoop>();
|
||||
private boolean displayFps = false;
|
||||
private boolean displayFps = true;
|
||||
private Fps FpsSystemEvent = new Fps("SystemEvent", displayFps);
|
||||
private Fps FpsSystemContext = new Fps("SystemContext", displayFps);
|
||||
private Fps FpsSystem = new Fps("System", displayFps);
|
||||
@ -264,6 +265,12 @@ public abstract class Context {
|
||||
status);
|
||||
});
|
||||
}
|
||||
public void OS_setKeyboard( Special special,
|
||||
Keyboard type,
|
||||
Status state,
|
||||
boolean isARepeateKey) {
|
||||
OS_setKeyboard(special, type, state, isARepeateKey, (char)0);
|
||||
}
|
||||
public void OS_setKeyboard( Special special,
|
||||
Keyboard type,
|
||||
Status state,
|
||||
@ -381,6 +388,7 @@ public abstract class Context {
|
||||
}
|
||||
this.previousDisplayTime = currentTime;
|
||||
OpenGL.threadHasContext();
|
||||
OpenGL.resetFlagState();
|
||||
// process the events
|
||||
if (this.displayFps == true) {
|
||||
this.FpsSystemEvent.tic();
|
||||
@ -543,6 +551,10 @@ public abstract class Context {
|
||||
Log.debug("Receive MSG : THREAD_RESIZE : " + context.windowsSize + " ==> " + _size);
|
||||
context.windowsSize = _size;
|
||||
//gale::Dimension::setPixelWindowsSize(_context.windowsSize);
|
||||
Application tmpAppl = context.getApplication();
|
||||
if (tmpAppl != null) {
|
||||
tmpAppl.onResize(context.windowsSize);
|
||||
}
|
||||
// call application inside ..
|
||||
context.forceRedrawAll();
|
||||
});
|
||||
|
@ -1,44 +1,7 @@
|
||||
package org.atriaSoft.gale.context.LWJGL;
|
||||
|
||||
import static org.lwjgl.glfw.Callbacks.glfwFreeCallbacks;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_FALSE;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_A;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_D;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_ESCAPE;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_Q;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_S;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_SPACE;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_W;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_Z;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_MOUSE_BUTTON_LEFT;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_MOUSE_BUTTON_RIGHT;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_PRESS;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_RELEASE;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_RESIZABLE;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_TRUE;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_VISIBLE;
|
||||
import static org.lwjgl.glfw.GLFW.glfwCreateWindow;
|
||||
import static org.lwjgl.glfw.GLFW.glfwDefaultWindowHints;
|
||||
import static org.lwjgl.glfw.GLFW.glfwDestroyWindow;
|
||||
import static org.lwjgl.glfw.GLFW.glfwGetPrimaryMonitor;
|
||||
import static org.lwjgl.glfw.GLFW.glfwGetVideoMode;
|
||||
import static org.lwjgl.glfw.GLFW.glfwGetWindowSize;
|
||||
import static org.lwjgl.glfw.GLFW.glfwInit;
|
||||
import static org.lwjgl.glfw.GLFW.glfwMakeContextCurrent;
|
||||
import static org.lwjgl.glfw.GLFW.glfwPollEvents;
|
||||
import static org.lwjgl.glfw.GLFW.glfwSetCursorPosCallback;
|
||||
import static org.lwjgl.glfw.GLFW.glfwSetErrorCallback;
|
||||
import static org.lwjgl.glfw.GLFW.glfwSetKeyCallback;
|
||||
import static org.lwjgl.glfw.GLFW.glfwSetMouseButtonCallback;
|
||||
import static org.lwjgl.glfw.GLFW.glfwSetScrollCallback;
|
||||
import static org.lwjgl.glfw.GLFW.glfwSetWindowPos;
|
||||
import static org.lwjgl.glfw.GLFW.glfwSetWindowShouldClose;
|
||||
import static org.lwjgl.glfw.GLFW.glfwShowWindow;
|
||||
import static org.lwjgl.glfw.GLFW.glfwSwapBuffers;
|
||||
import static org.lwjgl.glfw.GLFW.glfwSwapInterval;
|
||||
import static org.lwjgl.glfw.GLFW.glfwTerminate;
|
||||
import static org.lwjgl.glfw.GLFW.glfwWindowHint;
|
||||
import static org.lwjgl.glfw.GLFW.glfwWindowShouldClose;
|
||||
import static org.lwjgl.glfw.GLFW.*;
|
||||
import static org.lwjgl.opengl.GL11.GL_COLOR_BUFFER_BIT;
|
||||
import static org.lwjgl.opengl.GL11.GL_DEPTH_BUFFER_BIT;
|
||||
import static org.lwjgl.opengl.GL11.glClear;
|
||||
@ -49,11 +12,16 @@ import static org.lwjgl.system.MemoryUtil.NULL;
|
||||
|
||||
import java.nio.IntBuffer;
|
||||
|
||||
import org.atriaSoft.etk.Uri;
|
||||
import org.atriaSoft.etk.math.Vector2f;
|
||||
import org.atriaSoft.gale.Application;
|
||||
import org.atriaSoft.gale.Fps;
|
||||
import org.atriaSoft.gale.context.Context;
|
||||
import org.atriaSoft.gale.key.Keyboard;
|
||||
import org.atriaSoft.gale.key.Special;
|
||||
import org.atriaSoft.gale.key.Status;
|
||||
import org.atriaSoft.gale.key.Type;
|
||||
import org.atriaSoft.gameEngine.Log;
|
||||
import org.lwjgl.Version;
|
||||
import org.lwjgl.glfw.GLFWErrorCallback;
|
||||
import org.lwjgl.glfw.GLFWVidMode;
|
||||
@ -63,7 +31,9 @@ import org.lwjgl.system.MemoryStack;
|
||||
import renderEngine.DisplayManagerDraw;
|
||||
|
||||
public class ContextLWJGL extends Context {
|
||||
|
||||
|
||||
private boolean[] inputIsPressed = new boolean[MAX_MANAGE_INPUT];
|
||||
private Vector2f cursorPos = new Vector2f(0, 0);
|
||||
private static final int WIDTH = 800;
|
||||
private static final int HEIGHT = 600;
|
||||
private static final String TITLE = "Gale basic UI";
|
||||
@ -178,99 +148,26 @@ public class ContextLWJGL extends Context {
|
||||
// Setup a key callback. It will be called every time a key is pressed, repeated or released.
|
||||
// https://www.glfw.org/docs/latest/input_guide.html
|
||||
glfwSetKeyCallback(window, (window, key, scancode, action, mods) -> {
|
||||
if ( key == GLFW_KEY_ESCAPE && action == GLFW_RELEASE ) {
|
||||
glfwSetWindowShouldClose(window, true); // We will detect this in the rendering loop
|
||||
}
|
||||
if ( key == GLFW_KEY_Z ) {
|
||||
if (action == GLFW_PRESS ) {
|
||||
System.out.println("Key Z is pressed");
|
||||
valueZ = true;
|
||||
} else if (action == GLFW_RELEASE ) {
|
||||
System.out.println("Key Z is release");
|
||||
valueZ = false;
|
||||
}
|
||||
}
|
||||
if ( key == GLFW_KEY_S ) {
|
||||
if (action == GLFW_PRESS ) {
|
||||
System.out.println("Key S is pressed");
|
||||
valueS = true;
|
||||
} else if (action == GLFW_RELEASE ) {
|
||||
System.out.println("Key S is release");
|
||||
valueS = false;
|
||||
}
|
||||
}
|
||||
if ( key == GLFW_KEY_Q ) {
|
||||
if (action == GLFW_PRESS ) {
|
||||
System.out.println("Key Q is pressed");
|
||||
valueQ = true;
|
||||
} else if (action == GLFW_RELEASE ) {
|
||||
System.out.println("Key Q is release");
|
||||
valueQ = false;
|
||||
}
|
||||
}
|
||||
if ( key == GLFW_KEY_D ) {
|
||||
if (action == GLFW_PRESS ) {
|
||||
System.out.println("Key D is pressed");
|
||||
valueD = true;
|
||||
} else if (action == GLFW_RELEASE ) {
|
||||
System.out.println("Key D is release");
|
||||
valueD = false;
|
||||
}
|
||||
}
|
||||
if ( key == GLFW_KEY_A ) {
|
||||
if (action == GLFW_PRESS ) {
|
||||
System.out.println("Key A is pressed");
|
||||
valueA = true;
|
||||
} else if (action == GLFW_RELEASE ) {
|
||||
System.out.println("Key A is release");
|
||||
valueA = false;
|
||||
}
|
||||
}
|
||||
if ( key == GLFW_KEY_W ) {
|
||||
if (action == GLFW_PRESS ) {
|
||||
System.out.println("Key W is pressed");
|
||||
valueW = true;
|
||||
} else if (action == GLFW_RELEASE ) {
|
||||
System.out.println("Key W is release");
|
||||
valueW = false;
|
||||
}
|
||||
}
|
||||
if ( key == GLFW_KEY_SPACE ) {
|
||||
if (action == GLFW_PRESS ) {
|
||||
System.out.println("Key SPACE is pressed");
|
||||
valueSPACE = true;
|
||||
} else if (action == GLFW_RELEASE ) {
|
||||
System.out.println("Key SPACE is release");
|
||||
valueSPACE = false;
|
||||
}
|
||||
}
|
||||
this.keyCallback(window, key, scancode, action, mods);
|
||||
});
|
||||
glfwSetWindowSizeCallback(window, (windows, sizeX, sizeY) -> {
|
||||
this.windowSizeCallback(window, sizeX, sizeY);
|
||||
});
|
||||
|
||||
glfwSetCharCallback(window, (window, key) -> {
|
||||
this.charCallback(window, key);
|
||||
});
|
||||
|
||||
glfwSetCursorPosCallback(window, (window, xpos, ypos) -> {
|
||||
currentMousePositionX = xpos;
|
||||
currentMousePositionY = ypos;
|
||||
|
||||
this.cursorPosCallback(window, xpos, ypos);
|
||||
});
|
||||
|
||||
glfwSetMouseButtonCallback(window, (window, button, action, mods) -> {
|
||||
if (button == GLFW_MOUSE_BUTTON_RIGHT) {
|
||||
if (action == GLFW_PRESS) {
|
||||
rightButtonStateDown = true;
|
||||
} else if (action == GLFW_RELEASE) {
|
||||
rightButtonStateDown = false;
|
||||
}
|
||||
} else if (button == GLFW_MOUSE_BUTTON_LEFT) {
|
||||
if (action == GLFW_PRESS) {
|
||||
leftButtonStateDown = true;
|
||||
} else if (action == GLFW_RELEASE) {
|
||||
leftButtonStateDown = false;
|
||||
}
|
||||
}
|
||||
this.mouseCallback(window, button, action, mods);
|
||||
});
|
||||
|
||||
glfwSetScrollCallback(window, (window, xoffset, yoffset) -> {
|
||||
whellOffsetY += yoffset;
|
||||
whellOffsetX += xoffset;
|
||||
this.scrollCallback(window, xoffset, yoffset);
|
||||
});
|
||||
|
||||
|
||||
@ -304,8 +201,329 @@ public class ContextLWJGL extends Context {
|
||||
lastFrameTime = getCurrentTime();
|
||||
|
||||
}
|
||||
private void windowSizeCallback(long window2, int sizeX, int sizeY) {
|
||||
OS_Resize(new Vector2f(sizeX, sizeY));
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void charCallback(long window, int key) {;
|
||||
Log.error("keyboard char " + key + " " + (char)key);
|
||||
}
|
||||
private void keyCallback(long window, int key, int scancode, int action, int mods) {
|
||||
boolean find = true;
|
||||
boolean thisIsAReapeateKey = false; // TODO detect this ...
|
||||
Keyboard keyInput = Keyboard.unknow;
|
||||
Log.error("keyboard input " + key + " " + scancode);
|
||||
switch (key) {
|
||||
//case 80: // keypad
|
||||
case GLFW_KEY_UP: keyInput = Keyboard.up; break;
|
||||
//case 83: // keypad
|
||||
case GLFW_KEY_LEFT: keyInput = Keyboard.left; break;
|
||||
//case 85: // keypad
|
||||
case GLFW_KEY_RIGHT: keyInput = Keyboard.right; break;
|
||||
//case 88: // keypad
|
||||
case GLFW_KEY_DOWN: keyInput = Keyboard.down; break;
|
||||
//case 81: // keypad
|
||||
case GLFW_KEY_PAGE_UP: keyInput = Keyboard.pageUp; break;
|
||||
//case 89: // keypad
|
||||
case GLFW_KEY_PAGE_DOWN: keyInput = Keyboard.pageDown; break;
|
||||
//case 79: // keypad
|
||||
case GLFW_KEY_HOME: keyInput = Keyboard.start; break;
|
||||
//case 87: // keypad
|
||||
case GLFW_KEY_END: keyInput = Keyboard.end; break;
|
||||
case GLFW_KEY_PRINT_SCREEN: keyInput = Keyboard.stopDefil; break;
|
||||
case GLFW_KEY_PAUSE: keyInput = Keyboard.wait; break;
|
||||
//case 90: // keypad
|
||||
case GLFW_KEY_INSERT:
|
||||
keyInput = Keyboard.insert;
|
||||
if(action == GLFW_RELEASE) {
|
||||
if (guiKeyBoardMode.getInsert() == true) {
|
||||
guiKeyBoardMode.setInsert(false);
|
||||
} else {
|
||||
guiKeyBoardMode.setInsert(true);
|
||||
}
|
||||
}
|
||||
break;
|
||||
//case 84: keyInput = KeyboardCenter; break; // Keypad
|
||||
case GLFW_KEY_F1: keyInput = Keyboard.f1; break;
|
||||
case GLFW_KEY_F2: keyInput = Keyboard.f2; break;
|
||||
case GLFW_KEY_F3: keyInput = Keyboard.f3; break;
|
||||
case GLFW_KEY_F4: keyInput = Keyboard.f4; break;
|
||||
case GLFW_KEY_F5: keyInput = Keyboard.f5; break;
|
||||
case GLFW_KEY_F6: keyInput = Keyboard.f6; break;
|
||||
case GLFW_KEY_F7: keyInput = Keyboard.f7; break;
|
||||
case GLFW_KEY_F8: keyInput = Keyboard.f8; break;
|
||||
case GLFW_KEY_F9: keyInput = Keyboard.f9; break;
|
||||
case GLFW_KEY_F10: keyInput = Keyboard.f10; break;
|
||||
case GLFW_KEY_F11: keyInput = Keyboard.f11; break;
|
||||
case GLFW_KEY_F12: keyInput = Keyboard.f12; break;
|
||||
case GLFW_KEY_CAPS_LOCK: keyInput = Keyboard.capLock; guiKeyBoardMode.setCapsLock (action == GLFW_PRESS); break;
|
||||
case GLFW_KEY_LEFT_SHIFT: keyInput = Keyboard.shiftLeft; guiKeyBoardMode.setShiftLeft (action == GLFW_PRESS); break;
|
||||
case GLFW_KEY_RIGHT_SHIFT: keyInput = Keyboard.shiftRight; guiKeyBoardMode.setShiftRight(action == GLFW_PRESS); break;
|
||||
case GLFW_KEY_LEFT_CONTROL: keyInput = Keyboard.ctrlLeft; guiKeyBoardMode.setCtrlLeft (action == GLFW_PRESS); break;
|
||||
case GLFW_KEY_RIGHT_CONTROL: keyInput = Keyboard.ctrlRight; guiKeyBoardMode.setCtrlRight (action == GLFW_PRESS); break;
|
||||
case GLFW_KEY_LEFT_SUPER: keyInput = Keyboard.metaLeft; guiKeyBoardMode.setMetaLeft (action == GLFW_PRESS); break;
|
||||
case GLFW_KEY_RIGHT_SUPER: keyInput = Keyboard.metaRight; guiKeyBoardMode.setMetaRight (action == GLFW_PRESS); break;
|
||||
case GLFW_KEY_LEFT_ALT: keyInput = Keyboard.altLeft; guiKeyBoardMode.setAltLeft (action == GLFW_PRESS); break;
|
||||
case GLFW_KEY_RIGHT_ALT: keyInput = Keyboard.altRight; guiKeyBoardMode.setAltRight (action == GLFW_PRESS); break;
|
||||
case GLFW_KEY_MENU: keyInput = Keyboard.contextMenu; break;
|
||||
case GLFW_KEY_NUM_LOCK: keyInput = Keyboard.numLock; guiKeyBoardMode.setNumLock (action == GLFW_PRESS); break;
|
||||
case GLFW_KEY_DELETE: // Suppr on keypad
|
||||
find = false;
|
||||
if(guiKeyBoardMode.getNumLock() == true){
|
||||
OS_setKeyboard(guiKeyBoardMode,
|
||||
Keyboard.character,
|
||||
(action == GLFW_PRESS?Status.down:Status.up),
|
||||
thisIsAReapeateKey,
|
||||
'.');
|
||||
if (thisIsAReapeateKey == true) {
|
||||
OS_setKeyboard(guiKeyBoardMode,
|
||||
Keyboard.character,
|
||||
(action != GLFW_PRESS?Status.down:Status.up),
|
||||
thisIsAReapeateKey,
|
||||
'.');
|
||||
}
|
||||
} else {
|
||||
OS_setKeyboard(guiKeyBoardMode,
|
||||
Keyboard.character,
|
||||
(action == GLFW_PRESS?Status.down:Status.up),
|
||||
thisIsAReapeateKey,
|
||||
(char)0x7F);
|
||||
if (thisIsAReapeateKey == true) {
|
||||
OS_setKeyboard(guiKeyBoardMode,
|
||||
Keyboard.character,
|
||||
(action != GLFW_PRESS?Status.down:Status.up),
|
||||
thisIsAReapeateKey,
|
||||
(char)0x7F);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case GLFW_KEY_TAB: // special case for TAB
|
||||
find = false;
|
||||
OS_setKeyboard(guiKeyBoardMode,
|
||||
Keyboard.character,
|
||||
(action == GLFW_PRESS?Status.down:Status.up),
|
||||
thisIsAReapeateKey,
|
||||
(char)0x09);
|
||||
if (thisIsAReapeateKey == true) {
|
||||
OS_setKeyboard(guiKeyBoardMode,
|
||||
Keyboard.character,
|
||||
(action!=GLFW_PRESS?Status.down:Status.up),
|
||||
thisIsAReapeateKey,
|
||||
(char)0x09);
|
||||
}
|
||||
break;
|
||||
case GLFW_KEY_A:
|
||||
case GLFW_KEY_B:
|
||||
case GLFW_KEY_C:
|
||||
case GLFW_KEY_D:
|
||||
case GLFW_KEY_E:
|
||||
case GLFW_KEY_F:
|
||||
case GLFW_KEY_G:
|
||||
case GLFW_KEY_H:
|
||||
case GLFW_KEY_I:
|
||||
case GLFW_KEY_J:
|
||||
case GLFW_KEY_K:
|
||||
case GLFW_KEY_L:
|
||||
case GLFW_KEY_M:
|
||||
case GLFW_KEY_N:
|
||||
case GLFW_KEY_O:
|
||||
case GLFW_KEY_P:
|
||||
case GLFW_KEY_Q:
|
||||
case GLFW_KEY_R:
|
||||
case GLFW_KEY_S:
|
||||
case GLFW_KEY_T:
|
||||
case GLFW_KEY_U:
|
||||
case GLFW_KEY_V:
|
||||
case GLFW_KEY_W:
|
||||
case GLFW_KEY_X:
|
||||
case GLFW_KEY_Y:
|
||||
case GLFW_KEY_Z:
|
||||
{
|
||||
find = false;
|
||||
int tmpKey = key-GLFW_KEY_A + (int)'a';
|
||||
if (guiKeyBoardMode.getCapsLock() == true || guiKeyBoardMode.getShift() == true) {
|
||||
tmpKey += (int)'A' - (int)'a';
|
||||
}
|
||||
OS_setKeyboard(guiKeyBoardMode,
|
||||
Keyboard.character,
|
||||
(action==GLFW_PRESS?Status.down:Status.up),
|
||||
thisIsAReapeateKey,
|
||||
(char)tmpKey);
|
||||
if (thisIsAReapeateKey == true) {
|
||||
OS_setKeyboard(guiKeyBoardMode,
|
||||
Keyboard.character,
|
||||
(action!=GLFW_PRESS?Status.down:Status.up),
|
||||
thisIsAReapeateKey,
|
||||
(char)tmpKey);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case GLFW_KEY_1:
|
||||
case GLFW_KEY_2:
|
||||
case GLFW_KEY_3:
|
||||
case GLFW_KEY_4:
|
||||
case GLFW_KEY_5:
|
||||
case GLFW_KEY_6:
|
||||
case GLFW_KEY_7:
|
||||
case GLFW_KEY_8:
|
||||
case GLFW_KEY_9:
|
||||
case GLFW_KEY_0:
|
||||
{
|
||||
find = false;
|
||||
int tmpKey = key-GLFW_KEY_0 + (int)'0';
|
||||
// if (guiKeyBoardMode.getCapsLock() == true || guiKeyBoardMode.getShift() == true) {
|
||||
// tmpKey += (int)'A' - (int)'a';
|
||||
// }
|
||||
OS_setKeyboard(guiKeyBoardMode,
|
||||
Keyboard.character,
|
||||
(action==GLFW_PRESS?Status.down:Status.up),
|
||||
thisIsAReapeateKey,
|
||||
(char)tmpKey);
|
||||
if (thisIsAReapeateKey == true) {
|
||||
OS_setKeyboard(guiKeyBoardMode,
|
||||
Keyboard.character,
|
||||
(action!=GLFW_PRESS?Status.down:Status.up),
|
||||
thisIsAReapeateKey,
|
||||
(char)tmpKey);
|
||||
}
|
||||
}
|
||||
default:
|
||||
find = false;
|
||||
// {
|
||||
// char buf[11];
|
||||
// //GALE_DEBUG("Keycode: " << event.xkey.keycode);
|
||||
// // change keystate for simple reson of the ctrl error...
|
||||
// int32_t keyStateSave = event.xkey.state;
|
||||
// if (event.xkey.state & (1<<2) ) {
|
||||
// event.xkey.state = event.xkey.state & 0xFFFFFFFB;
|
||||
// }
|
||||
// KeySym keysym;
|
||||
// Status status = 0;
|
||||
// //int count = Xutf8LookupString(m_xic, (XKeyPressedEvent*)&event, buf, 10, &keysym, &status);
|
||||
// int count = Xutf8LookupString(m_xic, &event.xkey, buf, 10, &keysym, &status);
|
||||
// // retreave real keystate
|
||||
// event.xkey.state = keyStateSave;
|
||||
// buf[count] = '\0';
|
||||
// // Replace \r error ...
|
||||
// if (buf[0] == '\r') {
|
||||
// buf[0] = '\n';
|
||||
// buf[1] = '\0';
|
||||
// }
|
||||
// if (count >= 0) {
|
||||
// // repeated kay from previous element :
|
||||
// if (count > 0) {
|
||||
// // transform it in unicode
|
||||
// m_lastKeyPressed = utf8::convertChar32(buf);
|
||||
// }
|
||||
// X11_INFO("event Key : " << event.xkey.keycode << " char=\"" << buf << "\"'len=" << strlen(buf) << " unicode=" << m_lastKeyPressed);
|
||||
// OS_setKeyboard(m_guiKeyBoardMode,
|
||||
// gale::key::keyboard::character,
|
||||
// (event.type==KeyPress?gale::key::status::down:gale::key::status::up),
|
||||
// thisIsAReapeateKey,
|
||||
// m_lastKeyPressed);
|
||||
// if (thisIsAReapeateKey == true) {
|
||||
// OS_setKeyboard(m_guiKeyBoardMode,
|
||||
// gale::key::keyboard::character,
|
||||
// (event.type!=KeyPress?gale::key::status::down:gale::key::status::up),
|
||||
// thisIsAReapeateKey,
|
||||
// m_lastKeyPressed);
|
||||
// }
|
||||
// } else {
|
||||
// GALE_WARNING("Unknow event Key : " << event.xkey.keycode << " res='" << buf << "' repeate=" << thisIsAReapeateKey);
|
||||
// }
|
||||
// }
|
||||
// break;
|
||||
}
|
||||
if (find == true) {
|
||||
OS_setKeyboard(guiKeyBoardMode,
|
||||
keyInput,
|
||||
(action == GLFW_PRESS?Status.down:Status.up),
|
||||
thisIsAReapeateKey);
|
||||
if (thisIsAReapeateKey == true) {
|
||||
OS_setKeyboard(guiKeyBoardMode,
|
||||
keyInput,
|
||||
(action!=GLFW_PRESS?Status.down:Status.up),
|
||||
thisIsAReapeateKey);
|
||||
}
|
||||
}
|
||||
// if ( key == GLFW_KEY_ESCAPE && action == GLFW_RELEASE ) {
|
||||
// glfwSetWindowShouldClose(window, true); // We will detect this in the rendering loop
|
||||
// }
|
||||
}
|
||||
private void cursorPosCallback(long window, double xpos, double ypos) {
|
||||
cursorPos.x = (float)xpos;
|
||||
cursorPos.y = /*m_currentHeight*/800.0f-(float)ypos;
|
||||
// For compatibility of the Android system :
|
||||
boolean findOne = false;
|
||||
for (int iii=0; iii<MAX_MANAGE_INPUT; iii++) {
|
||||
if (inputIsPressed[iii] == true) {
|
||||
//Log.debug("X11 event: bt=" << iii << " " << event.type << " = \"MotionNotify\" (" << m_cursorEventX << "," << m_cursorEventY << ")");
|
||||
OS_SetInput(Type.mouse,
|
||||
Status.move,
|
||||
iii,
|
||||
cursorPos);
|
||||
findOne = true;
|
||||
}
|
||||
}
|
||||
if (findOne == false) {
|
||||
//X11_DEBUG("X11 event: bt=" << 0 << " " << event.type << " = \"MotionNotify\" (" << m_cursorEventX << "," << m_cursorEventY << ")");
|
||||
OS_SetInput(Type.mouse,
|
||||
Status.move,
|
||||
0,
|
||||
cursorPos);
|
||||
}
|
||||
}
|
||||
private void scrollCallback(long window, double xoffset, double yoffset) {
|
||||
/*
|
||||
Log.error("scroll: " + xoffset + " " + yoffset);
|
||||
whellOffsetY += yoffset;
|
||||
whellOffsetX += xoffset;
|
||||
*/
|
||||
if (yoffset<0) {
|
||||
inputIsPressed[5] = true;
|
||||
OS_SetInput(Type.mouse,
|
||||
Status.down,
|
||||
5,
|
||||
cursorPos);
|
||||
inputIsPressed[5] = false;
|
||||
OS_SetInput(Type.mouse,
|
||||
Status.up,
|
||||
5,
|
||||
cursorPos);
|
||||
} else if (yoffset>0) {
|
||||
inputIsPressed[4] = true;
|
||||
OS_SetInput(Type.mouse,
|
||||
Status.down,
|
||||
4,
|
||||
cursorPos);
|
||||
inputIsPressed[4] = false;
|
||||
OS_SetInput(Type.mouse,
|
||||
Status.up,
|
||||
4,
|
||||
cursorPos);
|
||||
}
|
||||
}
|
||||
private void mouseCallback(long window, int button, int action, int mods) {
|
||||
if (action == GLFW_PRESS) {
|
||||
if (button < MAX_MANAGE_INPUT) {
|
||||
inputIsPressed[button] = true;
|
||||
}
|
||||
OS_SetInput(Type.mouse,
|
||||
Status.down,
|
||||
button,
|
||||
cursorPos);
|
||||
} else if (action == GLFW_RELEASE) {
|
||||
leftButtonStateDown = false;
|
||||
if (button < MAX_MANAGE_INPUT) {
|
||||
inputIsPressed[button] = false;
|
||||
}
|
||||
OS_SetInput(Type.mouse,
|
||||
Status.up,
|
||||
button,
|
||||
cursorPos);
|
||||
}
|
||||
}
|
||||
public static float getFrameTimeSecconds() {
|
||||
return delta;
|
||||
}
|
||||
@ -379,6 +597,15 @@ public class ContextLWJGL extends Context {
|
||||
System.exit(0);
|
||||
return 0;
|
||||
}
|
||||
/****************************************************************************************/
|
||||
@Override
|
||||
public void setTitle(String title) {
|
||||
glfwSetWindowTitle(this.window, title);
|
||||
}
|
||||
public void setIcon(Uri inputFile) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static Context create(Application application, String[] arg) {
|
||||
// TODO Auto-generated method stub
|
||||
|
@ -293,4 +293,12 @@ public class Special {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Special [CapLock=" + valueCapLock + ", Shift=(" + valueShiftLeft + ","
|
||||
+ valueShiftRight + "), Ctrl=(" + valueCtrlLeft + "," + valueCtrlRight
|
||||
+ "), Meta=(" + valueMetaLeft + "," + valueMetaRight + "), Alt=("
|
||||
+ valueAltLeft + "," + valueAltRight + "), NumLock=" + valueNumLock
|
||||
+ ", Insert=" + valueInsert + "]";
|
||||
}
|
||||
}
|
||||
|
@ -836,9 +836,9 @@ public class ResourceProgram extends Resource {
|
||||
* @brief Request the processing of this program
|
||||
*/
|
||||
public void use() {
|
||||
Log.verbose("Will use program : " + this.program);
|
||||
//Log.verbose("Will use program : " + this.program);
|
||||
// event if it was 0 == > set it to prevent other use of the previous shader display ...
|
||||
OpenGL.useProgram(this.program);
|
||||
OpenGL.programUse(this.program);
|
||||
}
|
||||
/**
|
||||
* @brief set the testure Id on the specify uniform element.
|
||||
@ -886,7 +886,7 @@ public class ResourceProgram extends Resource {
|
||||
* @brief Stop the processing of this program
|
||||
*/
|
||||
public void unUse() {
|
||||
Log.verbose("Will UN-use program : " + this.program);
|
||||
//Log.verbose("Will UN-use program : " + this.program);
|
||||
|
||||
if (this.exist == false) {
|
||||
return;
|
||||
@ -896,12 +896,8 @@ public class ResourceProgram extends Resource {
|
||||
}
|
||||
this.listOfVBOUsed.clear();
|
||||
// no need to disable program == > this only generate perturbation on speed ...
|
||||
OpenGL.useProgram(-1);
|
||||
OpenGL.programUse(-1);
|
||||
}
|
||||
public static final int INDICE_VBO_POSITIONS = 0;
|
||||
public static final int INDICE_VBO_TEXTURE_COORDINATES = 1;
|
||||
public static final int INDICE_VBO_NORMALS = 2;
|
||||
public static final int INDICE_VBO_COLORS = 3;
|
||||
|
||||
|
||||
/**
|
||||
@ -925,10 +921,10 @@ public class ResourceProgram extends Resource {
|
||||
OpenGL.programAttach(this.program, this.shaderFragment.getGLID());
|
||||
}
|
||||
|
||||
OpenGL.programBindAttribute(this.program, INDICE_VBO_POSITIONS, "position");
|
||||
OpenGL.programBindAttribute(this.program, INDICE_VBO_TEXTURE_COORDINATES, "textureCoords");
|
||||
OpenGL.programBindAttribute(this.program, INDICE_VBO_NORMALS, "normal");
|
||||
OpenGL.programBindAttribute(this.program, INDICE_VBO_COLORS, "colors");
|
||||
OpenGL.programBindAttribute(this.program, ResourceVirtualArrayObject.INDICE_VBO_POSITIONS, "position");
|
||||
OpenGL.programBindAttribute(this.program, ResourceVirtualArrayObject.INDICE_VBO_TEXTURE_COORDINATES, "textureCoords");
|
||||
OpenGL.programBindAttribute(this.program, ResourceVirtualArrayObject.INDICE_VBO_NORMALS, "normal");
|
||||
OpenGL.programBindAttribute(this.program, ResourceVirtualArrayObject.INDICE_VBO_COLORS, "colors");
|
||||
|
||||
if (OpenGL.programCompile(this.program) == false) {
|
||||
Log.error("Could not compile'PROGRAM':'" + this.name + "'");
|
||||
|
@ -1,7 +1,67 @@
|
||||
package org.atriaSoft.gale.resource;
|
||||
|
||||
public class ResourceTexture {
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import org.atriaSoft.etk.Uri;
|
||||
import org.atriaSoft.etk.math.Vector2f;
|
||||
import org.atriaSoft.etk.math.Vector2i;
|
||||
import org.atriaSoft.gale.Log;
|
||||
import org.atriaSoft.gale.backend3d.OpenGL;
|
||||
import org.atriaSoft.gale.tools.ImageLoader;
|
||||
import org.atriaSoft.gale.tools.ImageRawData;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL13;
|
||||
import org.lwjgl.opengl.GL20;
|
||||
import org.lwjgl.opengl.GL30;
|
||||
|
||||
public class ResourceTexture extends Resource {
|
||||
private static int[] textureIdBinding = {
|
||||
GL13.GL_TEXTURE0,
|
||||
GL13.GL_TEXTURE1,
|
||||
GL13.GL_TEXTURE2,
|
||||
GL13.GL_TEXTURE3,
|
||||
GL13.GL_TEXTURE4,
|
||||
GL13.GL_TEXTURE5,
|
||||
GL13.GL_TEXTURE6,
|
||||
GL13.GL_TEXTURE7,
|
||||
GL13.GL_TEXTURE8,
|
||||
GL13.GL_TEXTURE9,
|
||||
GL13.GL_TEXTURE10,
|
||||
GL13.GL_TEXTURE11,
|
||||
GL13.GL_TEXTURE12,
|
||||
GL13.GL_TEXTURE13,
|
||||
GL13.GL_TEXTURE14,
|
||||
GL13.GL_TEXTURE15,
|
||||
GL13.GL_TEXTURE16,
|
||||
GL13.GL_TEXTURE17,
|
||||
GL13.GL_TEXTURE18,
|
||||
GL13.GL_TEXTURE19,
|
||||
GL13.GL_TEXTURE20,
|
||||
GL13.GL_TEXTURE21,
|
||||
GL13.GL_TEXTURE22,
|
||||
GL13.GL_TEXTURE23,
|
||||
GL13.GL_TEXTURE24,
|
||||
GL13.GL_TEXTURE25,
|
||||
GL13.GL_TEXTURE26,
|
||||
GL13.GL_TEXTURE27,
|
||||
GL13.GL_TEXTURE28,
|
||||
GL13.GL_TEXTURE29,
|
||||
GL13.GL_TEXTURE30,
|
||||
GL13.GL_TEXTURE31
|
||||
};
|
||||
public enum TextureColorMode {
|
||||
rgb, //!< red/green/blue data
|
||||
rgba //!< red/green/blue/alpha data
|
||||
};
|
||||
protected int texId = -1; //!< openGl textureID.
|
||||
protected Vector2f endPointSize = new Vector2f(-1, -1); //!< some image are not square == > we need to sqared it to prevent some openGl api error the the displayable size is not all the time 0.0 . 1.0.
|
||||
protected boolean loaded = false; //!< internal state of the openGl system.
|
||||
// Image properties:
|
||||
private ByteBuffer data = null; //!< pointer on the image data.
|
||||
private Vector2i size = new Vector2i(-1,-1); //!< size of the image data.
|
||||
private TextureColorMode dataColorSpace = TextureColorMode.rgb; //!< Color space of the image.
|
||||
private int textureUnit = 0; // number of lines and colomns in the texture (multiple texturing in a single texture)
|
||||
private String filename = "";
|
||||
/**
|
||||
* @brief get the next power 2 if the input
|
||||
* @param[in] value Value that we want the next power of 2
|
||||
@ -18,131 +78,152 @@ public class ResourceTexture {
|
||||
Log.critical("impossible CASE....");
|
||||
return val;
|
||||
}
|
||||
public:
|
||||
enum class color {
|
||||
mono = 0, //!< Monochrome color
|
||||
rgb, //!< red/green/blue data
|
||||
rgba //!< red/green/blue/alpha data
|
||||
};
|
||||
enum dataType {
|
||||
int16 = 0, //!< Image data are stored on integer 16 bit for each element
|
||||
float32, //!< Image data are stored on flaoting point value on 32 bit for each element
|
||||
};
|
||||
protected:
|
||||
int this.texId; //!< openGl textureID.
|
||||
Vector2f this.endPointSize; //!< some image are not square == > we need to sqared it to prevent some openGl api error the the displayable size is not all the time 0.0 . 1.0.
|
||||
boolean this.loaded; //!< internal state of the openGl system.
|
||||
// Gale internal API:
|
||||
public:
|
||||
virtual boolean updateContext(){
|
||||
ethread::RecursiveLock lock(this.mutex, true);
|
||||
if (lock.tryLock() == false) {
|
||||
//Lock error ==> try later ...
|
||||
return false;
|
||||
}
|
||||
if (this.loaded == false) {
|
||||
// Request a new texture at openGl :
|
||||
glGenTextures(1, this.texId);
|
||||
}
|
||||
// in all case we set the texture properties :
|
||||
// TODO : check error ???
|
||||
glBindTexture(GLTEXTURE2D, this.texId);
|
||||
// TODO : Check error ???
|
||||
//glTexParameteri(GLTEXTURE2D, GLTEXTUREWRAPS, GLREPEAT);
|
||||
//glTexParameteri(GLTEXTURE2D, GLTEXTUREWRAPT, GLREPEAT);
|
||||
//--- mode nearest
|
||||
//glTexParameteri(GLTEXTURE2D, GLTEXTUREMAGFILTER, GLNEAREST);
|
||||
//glTexParameteri(GLTEXTURE2D, GLTEXTUREMINFILTER, GLNEAREST);
|
||||
//--- Mode linear
|
||||
glTexParameteri(GLTEXTURE2D, GLTEXTUREMAGFILTER, GLLINEAR);
|
||||
glTexParameteri(GLTEXTURE2D, GLTEXTUREMINFILTER, GLLINEAR);
|
||||
Log.info("TEXTURE: add [" + getId() + "]=" + this.size + " OGlId=" + this.texId);
|
||||
glTexImage2D(GLTEXTURE2D, // Target
|
||||
0, // Level
|
||||
GLRGBA, // Format internal
|
||||
this.size.x(),
|
||||
this.size.y(),
|
||||
0, // Border
|
||||
GLRGBA, // format
|
||||
GLUNSIGNEDBYTE, // type
|
||||
((*this.data)[0]) );
|
||||
// now the data is loaded
|
||||
this.loaded = true;
|
||||
return true;
|
||||
}
|
||||
virtual void removeContext() {
|
||||
ethread::RecursiveLock lock(this.mutex);
|
||||
if (true == this.loaded) {
|
||||
// Request remove texture ...
|
||||
Log.info("TEXTURE: Rm [" + getId() + "] texId=" + this.texId);
|
||||
// TODO: Check if we are in the correct thread
|
||||
glDeleteTextures(1, this.texId);
|
||||
this.loaded = false;
|
||||
}
|
||||
}
|
||||
virtual void removeContextToLate() {
|
||||
ethread::RecursiveLock lock(this.mutex);
|
||||
this.loaded = false;
|
||||
this.texId=0;
|
||||
}
|
||||
// middleware interface:
|
||||
public:
|
||||
int getRendererId() {
|
||||
return this.texId;
|
||||
};
|
||||
Vector2f getUsableSize() {
|
||||
return this.endPointSize;
|
||||
};
|
||||
Vector2i getOpenGlSize() {
|
||||
return this.size;
|
||||
};
|
||||
// Public API:
|
||||
protected:
|
||||
void init( String filename) {
|
||||
super.init(filename);
|
||||
protected ResourceTexture(String filename, int textureUnit) {
|
||||
super(filename + "__" + textureUnit);
|
||||
this.filename = filename;
|
||||
this.textureUnit = textureUnit;
|
||||
addResourceType("gale::resource::Texture");
|
||||
}
|
||||
protected ResourceTexture(Uri filename, int textureUnit) {
|
||||
super(filename + "__" + textureUnit);
|
||||
this.filename = filename.get();
|
||||
this.textureUnit = textureUnit;
|
||||
addResourceType("gale::resource::Texture");
|
||||
}
|
||||
protected ResourceTexture() {
|
||||
super();
|
||||
addResourceType("gale::resource::Texture");
|
||||
}
|
||||
public void cleanUp() {
|
||||
removeContext();
|
||||
}
|
||||
// Gale internal API:
|
||||
@Override
|
||||
public boolean updateContext() {
|
||||
if (this.loaded == true) {
|
||||
return true;
|
||||
}
|
||||
void init() {
|
||||
gale::Resource::init();
|
||||
// Request a new texture at openGl :
|
||||
texId = GL11.glGenTextures();
|
||||
GL13.glActiveTexture(textureUnit);
|
||||
GL11.glBindTexture(GL11.GL_TEXTURE_2D, texId);
|
||||
|
||||
// All RGB bytes are aligned to each other and each component is 1 byte
|
||||
GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1);
|
||||
Log.info("TEXTURE: add [" + getId() + "]=" + this.size + " OGlId=" + this.texId);
|
||||
if (dataColorSpace == TextureColorMode.rgb) {
|
||||
GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, this.size.x, this.size.y, 0, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, data);
|
||||
} else {
|
||||
GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, this.size.x, this.size.y, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, data);
|
||||
}
|
||||
Texture() :
|
||||
this.texId(0),
|
||||
this.endPointSize(1,1),
|
||||
this.loaded(false),
|
||||
this.size(0,0),
|
||||
this.dataType(gale::resource::Texture::dataType::int16),
|
||||
this.dataColorSpace(gale::resource::Texture::color::mono) {
|
||||
addResourceType("gale::resource::Texture");
|
||||
// generate multi-texture mapping
|
||||
GL30.glGenerateMipmap(GL11.GL_TEXTURE_2D);
|
||||
|
||||
// Setup the ST coordinate system
|
||||
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT);
|
||||
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_REPEAT);
|
||||
|
||||
// Setup what to do when the texture has to be scaled
|
||||
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
|
||||
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR_MIPMAP_LINEAR);
|
||||
// now the data is loaded
|
||||
this.loaded = true;
|
||||
return true;
|
||||
}
|
||||
public void removeContext() {
|
||||
if (true == this.loaded) {
|
||||
// Request remove texture ...
|
||||
Log.info("TEXTURE: Rm [" + getId() + "] texId=" + this.texId);
|
||||
// TODO: Check if we are in the correct thread
|
||||
GL11.glDeleteTextures(this.texId);
|
||||
this.loaded = false;
|
||||
}
|
||||
}
|
||||
public void removeContextToLate() {
|
||||
this.loaded = false;
|
||||
this.texId = -1;
|
||||
}
|
||||
public int getRendererId() {
|
||||
return this.texId;
|
||||
};
|
||||
public Vector2f getUsableSize() {
|
||||
return this.endPointSize;
|
||||
};
|
||||
public Vector2i getOpenGlSize() {
|
||||
return this.size;
|
||||
};
|
||||
// flush the data to send it at the openGl system
|
||||
public void flush() {
|
||||
// request to the manager to be call at the next update ...
|
||||
getManager().update(this);
|
||||
}
|
||||
public void setTexture(ByteBuffer data,
|
||||
Vector2i size,
|
||||
TextureColorMode dataColorSpace,
|
||||
int textureUnit) {
|
||||
this.data = data;
|
||||
this.size = size;
|
||||
this.textureUnit = textureUnit;
|
||||
this.endPointSize.x = (float)size.x;
|
||||
this.endPointSize.y = (float)size.y;
|
||||
this.dataColorSpace = dataColorSpace;
|
||||
flush();
|
||||
}
|
||||
public void bindForRendering(int idTexture) {
|
||||
if (this.loaded == false) {
|
||||
return;
|
||||
}
|
||||
GL13.glActiveTexture(textureIdBinding[idTexture]);
|
||||
GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.texId);
|
||||
if (dataColorSpace == TextureColorMode.rgba) {
|
||||
OpenGL.enable(OpenGL.Flag.flag_cullFace);
|
||||
OpenGL.enable(OpenGL.Flag.flag_back);
|
||||
}
|
||||
}
|
||||
public void unBindForRendering() {
|
||||
if (this.loaded == false) {
|
||||
return;
|
||||
}
|
||||
if (dataColorSpace == TextureColorMode.rgba) {
|
||||
OpenGL.disable(OpenGL.Flag.flag_cullFace);
|
||||
OpenGL.disable(OpenGL.Flag.flag_back);
|
||||
}
|
||||
}
|
||||
|
||||
public static ResourceTexture createFromPng(Uri uriTexture) {
|
||||
return createFromPng(uriTexture, 1);
|
||||
}
|
||||
public static ResourceTexture createFromPng(Uri uriTexture, int textureUnit) {
|
||||
ResourceTexture resource;
|
||||
Resource resource2;
|
||||
String name = uriTexture.getValue();
|
||||
if (name.isEmpty() == false && name != "---") {
|
||||
resource2 = getManager().localKeep(name);
|
||||
} else {
|
||||
Log.error("Can not create a shader without a filaname");
|
||||
return null;
|
||||
}
|
||||
if (resource2 != null) {
|
||||
if (resource2 instanceof ResourceTexture) {
|
||||
resource2.keep();
|
||||
return (ResourceTexture)resource2;
|
||||
}
|
||||
public:
|
||||
virtual ~Texture() {
|
||||
removeContext();
|
||||
Log.critical("Request resource file : '" + name + "' With the wrong type (dynamic cast error)");
|
||||
return null;
|
||||
}
|
||||
public:
|
||||
// flush the data to send it at the openGl system
|
||||
void flush(){
|
||||
ethread::RecursiveLock lock(this.mutex);
|
||||
// request to the manager to be call at the next update ...
|
||||
getManager().update(ememory::dynamicPointerCast<gale::Resource>(sharedFromThis()));
|
||||
resource = new ResourceTexture(uriTexture, textureUnit);
|
||||
ImageRawData decodedData = ImageLoader.decodePngFile(uriTexture);
|
||||
resource.setTexture(decodedData.getBuffer(),
|
||||
new Vector2i(decodedData.getWidth(), decodedData.getHeight()),
|
||||
(decodedData.isHasAlpha() == true?TextureColorMode.rgba:TextureColorMode.rgb),
|
||||
textureUnit);
|
||||
if (resource.resourceHasBeenCorectlyInit() == false) {
|
||||
Log.critical("resource Is not correctly init : ResourceProgram" );
|
||||
return null;
|
||||
}
|
||||
getManager().localAdd(resource);
|
||||
return resource;
|
||||
}
|
||||
|
||||
private:
|
||||
// Image propoerties:
|
||||
etk::Vector<char>> this.data; //!< pointer on the image data.
|
||||
Vector2i this.size; //!< size of the image data.
|
||||
enum dataType this.dataType; //!< Type of the image.
|
||||
enum color this.dataColorSpace; //!< Color space of the image.
|
||||
public:
|
||||
void setTexture( etk::Vector<char>> data,
|
||||
Vector2i size,
|
||||
enum gale::resource::Texture::dataType dataType,
|
||||
enum gale::resource::Texture::color dataColorSpace) {
|
||||
ethread::RecursiveLock lock(this.mutex);
|
||||
this.data = data;
|
||||
this.size = size;
|
||||
this.endPointSize = size;
|
||||
this.dataType = dataType;
|
||||
this.dataColorSpace = dataColorSpace;
|
||||
// TODO : Reload ...
|
||||
flush();
|
||||
}
|
||||
}
|
||||
}
|
@ -11,6 +11,7 @@ import org.atriaSoft.etk.math.Vector2f;
|
||||
import org.atriaSoft.etk.math.Vector3f;
|
||||
import org.atriaSoft.gale.Log;
|
||||
import org.atriaSoft.gale.backend3d.OpenGL;
|
||||
import org.atriaSoft.gale.backend3d.OpenGL.RenderMode;
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL15;
|
||||
@ -29,7 +30,54 @@ public class ResourceVirtualArrayObject extends Resource {
|
||||
float[] normals = null;
|
||||
int[] indices = null;
|
||||
int vertexCount = -1;
|
||||
public static final int INDICE_VBO_POSITIONS = 0;
|
||||
public static final int INDICE_VBO_TEXTURE_COORDINATES = 1;
|
||||
public static final int INDICE_VBO_NORMALS = 2;
|
||||
public static final int INDICE_VBO_COLORS = 3;
|
||||
|
||||
public void bindForRendering() {
|
||||
if (exist == false) {
|
||||
return;
|
||||
}
|
||||
GL30.glBindVertexArray(vaoID);
|
||||
if (positions != null) {
|
||||
GL20.glEnableVertexAttribArray(INDICE_VBO_POSITIONS);
|
||||
}
|
||||
if (textureCoordinates != null) {
|
||||
GL20.glEnableVertexAttribArray(INDICE_VBO_TEXTURE_COORDINATES);
|
||||
}
|
||||
if (normals != null) {
|
||||
GL20.glEnableVertexAttribArray(INDICE_VBO_NORMALS);
|
||||
}
|
||||
if (colors != null) {
|
||||
GL20.glEnableVertexAttribArray(INDICE_VBO_COLORS);
|
||||
}
|
||||
}
|
||||
|
||||
public void unBindForRendering() {
|
||||
if (exist == false) {
|
||||
return;
|
||||
}
|
||||
if (positions != null) {
|
||||
GL20.glDisableVertexAttribArray(INDICE_VBO_POSITIONS);
|
||||
}
|
||||
if (textureCoordinates != null) {
|
||||
GL20.glDisableVertexAttribArray(INDICE_VBO_TEXTURE_COORDINATES);
|
||||
}
|
||||
if (normals != null) {
|
||||
GL20.glDisableVertexAttribArray(INDICE_VBO_NORMALS);
|
||||
}
|
||||
if (colors != null) {
|
||||
GL20.glDisableVertexAttribArray(INDICE_VBO_COLORS);
|
||||
}
|
||||
GL30.glBindVertexArray(0);
|
||||
}
|
||||
|
||||
public void render(RenderMode mode) {
|
||||
OpenGL.drawElements(mode, vertexCount);
|
||||
}
|
||||
|
||||
|
||||
private FloatBuffer storeDataInFloatBuffer(float[] data) {
|
||||
FloatBuffer buffer = BufferUtils.createFloatBuffer(data.length);
|
||||
buffer.put(data);
|
||||
@ -209,4 +257,5 @@ public class ResourceVirtualArrayObject extends Resource {
|
||||
getManager().localAdd(resource);
|
||||
return resource;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,36 +4,26 @@ import org.atriaSoft.etk.Color;
|
||||
import org.atriaSoft.etk.Uri;
|
||||
import org.atriaSoft.etk.math.Matrix4f;
|
||||
import org.atriaSoft.etk.math.Vector2f;
|
||||
import org.atriaSoft.etk.math.Vector2i;
|
||||
import org.atriaSoft.etk.math.Vector3f;
|
||||
import org.atriaSoft.gale.Application;
|
||||
import org.atriaSoft.gale.backend3d.OpenGL;
|
||||
import org.atriaSoft.gale.backend3d.OpenGL.RenderMode;
|
||||
import org.atriaSoft.gale.context.Context;
|
||||
import org.atriaSoft.gale.resource.ResourceProgram;
|
||||
import org.atriaSoft.gale.resource.ResourceVirtualArrayObject;
|
||||
import org.atriaSoft.gale.context.Cursor;
|
||||
import org.atriaSoft.gale.key.Keyboard;
|
||||
import org.atriaSoft.gale.key.Special;
|
||||
import org.atriaSoft.gale.key.Status;
|
||||
import org.atriaSoft.gale.key.Type;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL20;
|
||||
import org.lwjgl.opengl.GL30;
|
||||
|
||||
public class MainApplication extends Application {
|
||||
private ResourceProgram GLprogram;
|
||||
private int GLPosition;
|
||||
private int GLMatrixTransformation;
|
||||
private int GLMatrixProjection;
|
||||
private int GLMatrixView;
|
||||
private int GLColor;
|
||||
private float angle;
|
||||
private ResourceVirtualArrayObject verticesVBO;
|
||||
private static final int INDICE_VBO_POSITIONS = 0;
|
||||
private static final int INDICE_VBO_TEXTURE_COORDINATES = 1;
|
||||
private static final int INDICE_VBO_NORMALS = 2;
|
||||
private static final int INDICE_VBO_COLORS = 3;
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreate(Context _context) {
|
||||
this.canDraw = true;
|
||||
@ -41,16 +31,9 @@ public class MainApplication extends Application {
|
||||
this.angle = 0.0f;
|
||||
this.GLprogram = ResourceProgram.create(new Uri("DATA", "basic.vert"), new Uri("DATA", "basic.frag"));
|
||||
if (this.GLprogram != null) {
|
||||
//this.GLPosition = this.GLprogram.getAttribute("EW_coord3d");
|
||||
//this.GLColor = this.GLprogram.getAttribute("EW_color");
|
||||
this.GLMatrixTransformation = this.GLprogram.getUniform("EW_MatrixTransformation");
|
||||
this.GLMatrixProjection = this.GLprogram.getUniform("EW_MatrixProjection");
|
||||
this.GLMatrixView = this.GLprogram.getUniform("EW_MatrixView");
|
||||
|
||||
// this.GLprogram.bindAttribute(INDICE_VBO_POSITIONS, "position");
|
||||
// //this.GLprogram.bindAttribute(INDICE_VBO_TEXTURE_COORDINATES, "textureCoords");
|
||||
// //this.GLprogram.bindAttribute(INDICE_VBO_NORMALS, "normal");
|
||||
// this.GLprogram.bindAttribute(INDICE_VBO_COLORS, "colors");
|
||||
this.GLMatrixTransformation = this.GLprogram.getUniform("matrixTransformation");
|
||||
this.GLMatrixProjection = this.GLprogram.getUniform("matrixProjection");
|
||||
this.GLMatrixView = this.GLprogram.getUniform("matrixView");
|
||||
}
|
||||
|
||||
float[] vertices = {
|
||||
@ -81,7 +64,7 @@ public class MainApplication extends Application {
|
||||
@Override
|
||||
public void onDraw(Context _context) {
|
||||
this.angle += 0.01;
|
||||
Log.info("==> appl Draw ...");
|
||||
//Log.info("==> appl Draw ...");
|
||||
Vector2f size = getSize();
|
||||
// set the basic openGL view port: (position drawed in the windows)
|
||||
OpenGL.setViewPort(new Vector2f(0,0), size);
|
||||
@ -111,52 +94,39 @@ public class MainApplication extends Application {
|
||||
Matrix4f viewMatrix = OpenGL.getCameraMatrix();
|
||||
//Matrix4f tmpMatrix = projMatrix * camMatrix;
|
||||
|
||||
this.verticesVBO.bindForRendering();
|
||||
this.GLprogram.uniformMatrix(this.GLMatrixView, viewMatrix);
|
||||
this.GLprogram.uniformMatrix(this.GLMatrixTransformation, transforamtionMatrix);
|
||||
this.GLprogram.uniformMatrix(this.GLMatrixProjection, projectionMatrix);
|
||||
// position:
|
||||
//this.GLprogram.sendAttributePointer2(this.GLPosition, this.verticesVBO, INDICE_VBO_VERTICES);
|
||||
//glEnableVertexAttribArray
|
||||
// color:
|
||||
//this.GLprogram.sendAttributePointer2(this.GLColor, this.verticesVBO, INDICE_VBO_COLOR);
|
||||
|
||||
GL30.glBindVertexArray(this.verticesVBO.getGLID());
|
||||
GL20.glEnableVertexAttribArray(INDICE_VBO_POSITIONS);
|
||||
GL20.glEnableVertexAttribArray(INDICE_VBO_COLORS);
|
||||
// Change the position for each element with the same pipeline you need to render ...
|
||||
this.GLprogram.uniformMatrix(this.GLMatrixTransformation, transforamtionMatrix);
|
||||
|
||||
// Request the draw od the elements:
|
||||
//OpenGL.drawArrays(OpenGL.RenderMode.triangle, 0, 3 /*number of points*/);
|
||||
Log.warning("Draw 3 points");
|
||||
//GL11.glDrawElements(GL11.GL_TRIANGLES, 3 /*number of points*/, GL11.GL_UNSIGNED_INT, 0);
|
||||
GL11.glDrawElements(GL11.GL_TRIANGLES, 3, GL11.GL_UNSIGNED_INT, 0);
|
||||
|
||||
GL20.glDisableVertexAttribArray(INDICE_VBO_COLORS);
|
||||
GL20.glDisableVertexAttribArray(INDICE_VBO_POSITIONS);
|
||||
GL30.glBindVertexArray(0);
|
||||
this.verticesVBO.render(OpenGL.RenderMode.triangle);
|
||||
|
||||
this.verticesVBO.unBindForRendering();
|
||||
this.GLprogram.unUse();
|
||||
// Restore context of matrix
|
||||
OpenGL.pop();
|
||||
this.markDrawingIsNeeded();
|
||||
}
|
||||
@Override
|
||||
public void onPointer(Type _type,
|
||||
int _pointerID,
|
||||
Vector2f _pos,
|
||||
Status _state) {
|
||||
/*
|
||||
Log.info("input event: type=" + _type);
|
||||
Log.info(" id=" + _pointerID);
|
||||
Log.info(" pos=" + _pos);
|
||||
Log.info(" state=" + _state);
|
||||
*/
|
||||
public void onPointer(Type type,
|
||||
int pointerID,
|
||||
Vector2f pos,
|
||||
Status state) {
|
||||
// Log.info("input event: type=" + type);
|
||||
// Log.info(" id=" + pointerID);
|
||||
// Log.info(" pos=" + pos);
|
||||
// Log.info(" state=" + state);
|
||||
}
|
||||
@Override
|
||||
public void onKeyboard( Special _special,
|
||||
Keyboard _type,
|
||||
Character _value,
|
||||
Status _state) {
|
||||
Log.info("Keyboard event: special=" + _special);
|
||||
Log.info(" type=" + _type);
|
||||
Log.info(" value='" + _value + "'");
|
||||
Log.info(" state=" + _state);
|
||||
public void onKeyboard( Special special,
|
||||
Keyboard type,
|
||||
Character value,
|
||||
Status state) {
|
||||
Log.info("Keyboard event: special=" + special);
|
||||
Log.info(" type=" + type);
|
||||
Log.info(" value='" + value + "'");
|
||||
Log.info(" state=" + state);
|
||||
}
|
||||
}
|
||||
|
@ -8,14 +8,14 @@ precision mediump int;
|
||||
// Input:
|
||||
attribute vec3 position;
|
||||
attribute vec4 colors;
|
||||
uniform mat4 EW_MatrixTransformation;
|
||||
uniform mat4 EW_MatrixProjection;
|
||||
uniform mat4 EW_MatrixView;
|
||||
uniform mat4 matrixTransformation;
|
||||
uniform mat4 matrixProjection;
|
||||
uniform mat4 matrixView;
|
||||
|
||||
// output:
|
||||
varying vec4 f_color;
|
||||
|
||||
void main(void) {
|
||||
gl_Position = EW_MatrixProjection * EW_MatrixView * EW_MatrixTransformation * vec4(position, 1.0);
|
||||
gl_Position = matrixProjection * matrixView * matrixTransformation * vec4(position, 1.0);
|
||||
f_color = colors;
|
||||
}
|
||||
|
29
src/org/atriaSoft/gale/test/sample2/Log.java
Normal file
29
src/org/atriaSoft/gale/test/sample2/Log.java
Normal file
@ -0,0 +1,29 @@
|
||||
package org.atriaSoft.gale.test.sample2;
|
||||
|
||||
public class Log {
|
||||
private static String LIBNAME = "Sample1";
|
||||
public static void print(String data) {
|
||||
System.out.println(data);
|
||||
}
|
||||
public static void critical(String data) {
|
||||
System.out.println("[C] " + LIBNAME + " | " + data);
|
||||
}
|
||||
public static void error(String data) {
|
||||
System.out.println("[E] " + LIBNAME + " | " + data);
|
||||
}
|
||||
public static void warning(String data) {
|
||||
System.out.println("[W] " + LIBNAME + " | " + data);
|
||||
}
|
||||
public static void info(String data) {
|
||||
System.out.println("[I] " + LIBNAME + " | " + data);
|
||||
}
|
||||
public static void debug(String data) {
|
||||
System.out.println("[D] " + LIBNAME + " | " + data);
|
||||
}
|
||||
public static void verbose(String data) {
|
||||
System.out.println("[V] " + LIBNAME + " | " + data);
|
||||
}
|
||||
public static void todo(String data) {
|
||||
System.out.println("[TODO] " + LIBNAME + " | " + data);
|
||||
}
|
||||
}
|
193
src/org/atriaSoft/gale/test/sample2/MainApplication.java
Normal file
193
src/org/atriaSoft/gale/test/sample2/MainApplication.java
Normal file
@ -0,0 +1,193 @@
|
||||
package org.atriaSoft.gale.test.sample2;
|
||||
|
||||
import org.atriaSoft.etk.Color;
|
||||
import org.atriaSoft.etk.Uri;
|
||||
import org.atriaSoft.etk.math.Matrix4f;
|
||||
import org.atriaSoft.etk.math.Vector2f;
|
||||
import org.atriaSoft.etk.math.Vector3f;
|
||||
import org.atriaSoft.gale.Application;
|
||||
import org.atriaSoft.gale.backend3d.OpenGL;
|
||||
import org.atriaSoft.gale.context.Context;
|
||||
import org.atriaSoft.gale.resource.ResourceProgram;
|
||||
import org.atriaSoft.gale.resource.ResourceTexture;
|
||||
import org.atriaSoft.gale.resource.ResourceVirtualArrayObject;
|
||||
import org.atriaSoft.gale.tools.ImageLoader;
|
||||
import org.atriaSoft.gale.tools.ImageRawData;
|
||||
import org.atriaSoft.gale.key.Keyboard;
|
||||
import org.atriaSoft.gale.key.Special;
|
||||
import org.atriaSoft.gale.key.Status;
|
||||
import org.atriaSoft.gale.key.Type;
|
||||
|
||||
public class MainApplication extends Application {
|
||||
private ResourceProgram GLprogram;
|
||||
private int GLMatrixTransformation;
|
||||
private int GLMatrixProjection;
|
||||
private int GLMatrixView;
|
||||
private float angleX = 0;
|
||||
private float angleY = 0;
|
||||
private float angleZ = 0;
|
||||
private ResourceVirtualArrayObject verticesVBO;
|
||||
private ResourceTexture texture;
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreate(Context _context) {
|
||||
this.canDraw = true;
|
||||
setSize(new Vector2f(800, 600));
|
||||
this.GLprogram = ResourceProgram.create(new Uri("DATA", "basic.vert"), new Uri("DATA", "basic.frag"));
|
||||
if (this.GLprogram != null) {
|
||||
this.GLMatrixTransformation = this.GLprogram.getUniform("matrixTransformation");
|
||||
this.GLMatrixProjection = this.GLprogram.getUniform("matrixProjection");
|
||||
this.GLMatrixView = this.GLprogram.getUniform("matrixView");
|
||||
}
|
||||
|
||||
float[] vertices = {
|
||||
-0.5f,0.5f,-0.5f,
|
||||
-0.5f,-0.5f,-0.5f,
|
||||
0.5f,-0.5f,-0.5f,
|
||||
0.5f,0.5f,-0.5f,
|
||||
|
||||
-0.5f,0.5f,0.5f,
|
||||
-0.5f,-0.5f,0.5f,
|
||||
0.5f,-0.5f,0.5f,
|
||||
0.5f,0.5f,0.5f,
|
||||
|
||||
0.5f,0.5f,-0.5f,
|
||||
0.5f,-0.5f,-0.5f,
|
||||
0.5f,-0.5f,0.5f,
|
||||
0.5f,0.5f,0.5f,
|
||||
|
||||
-0.5f,0.5f,-0.5f,
|
||||
-0.5f,-0.5f,-0.5f,
|
||||
-0.5f,-0.5f,0.5f,
|
||||
-0.5f,0.5f,0.5f,
|
||||
|
||||
-0.5f,0.5f,0.5f,
|
||||
-0.5f,0.5f,-0.5f,
|
||||
0.5f,0.5f,-0.5f,
|
||||
0.5f,0.5f,0.5f,
|
||||
|
||||
-0.5f,-0.5f,0.5f,
|
||||
-0.5f,-0.5f,-0.5f,
|
||||
0.5f,-0.5f,-0.5f,
|
||||
0.5f,-0.5f,0.5f
|
||||
|
||||
};
|
||||
|
||||
float[] textureCoords = {
|
||||
0,0, 0,1, 1,1, 1,0,
|
||||
0,0, 0,1, 1,1, 1,0,
|
||||
0,0, 0,1, 1,1, 1,0,
|
||||
0,0, 0,1, 1,1, 1,0,
|
||||
0,0, 0,1, 1,1, 1,0,
|
||||
0,0, 0,1, 1,1, 1,0
|
||||
};
|
||||
|
||||
int[] indices = {
|
||||
0,1,3, 3,1,2,
|
||||
4,5,7, 7,5,6,
|
||||
8,9,11, 11,9,10,
|
||||
12,13,15, 15,13,14,
|
||||
16,17,19, 19,17,18,
|
||||
20,21,23, 23,21,22
|
||||
|
||||
};
|
||||
// this is the properties of the buffer requested : "r"/"w" + "-" + buffer type "f"=float "i"=integer
|
||||
this.verticesVBO = ResourceVirtualArrayObject.create(vertices, textureCoords, null, indices);
|
||||
if (this.verticesVBO == null) {
|
||||
Log.error("can not instanciate VBO ...");
|
||||
return;
|
||||
}
|
||||
// TO facilitate some debugs we add a name of the VBO:
|
||||
this.verticesVBO.setName("[VBO] of basic SAMPLE");
|
||||
// update all the VBO elements ...
|
||||
this.verticesVBO.flush();
|
||||
|
||||
this.texture = ResourceTexture.createFromPng(new Uri("DATA", "tree_sample.png"));
|
||||
if (this.texture == null) {
|
||||
Log.error("can not instanciate Texture ...");
|
||||
return;
|
||||
}
|
||||
Log.info("==> Init APPL (END)");
|
||||
}
|
||||
@Override
|
||||
public void onDraw(Context _context) {
|
||||
this.angleX += 0.001;
|
||||
this.angleY += 0.005;
|
||||
this.angleZ += 0.01;
|
||||
//Log.info("==> appl Draw ...");
|
||||
Vector2f size = getSize();
|
||||
//Log.info("==> Windows size = " + size);
|
||||
// set the basic openGL view port: (position drawed in the windows)
|
||||
OpenGL.setViewPort(new Vector2f(0,0), size);
|
||||
// Clear all the stacked matrix ...
|
||||
OpenGL.setBasicMatrix(Matrix4f.identity());
|
||||
// clear background
|
||||
Color bgColor = new Color(0.0f, 1.0f, 1.0f, 0.75f);
|
||||
OpenGL.enable(OpenGL.Flag.flag_depthTest);
|
||||
OpenGL.clearColor(bgColor);
|
||||
// real clear request:
|
||||
OpenGL.clear(OpenGL.ClearFlag.clearFlag_colorBuffer);
|
||||
OpenGL.clear(OpenGL.ClearFlag.clearFlag_depthBuffer);
|
||||
// create a local matrix environnement.
|
||||
OpenGL.push();
|
||||
|
||||
//Matrix4f tmpProjection = Matrix4f.createMatrixOrtho(-getAspectRatio(), getAspectRatio(), -1, 1, -50, 50);
|
||||
Matrix4f tmpProjection = Matrix4f.createMatrixPerspective(1.30f, getAspectRatio(), 1, 50);
|
||||
// set internal matrix system:
|
||||
OpenGL.setMatrix(tmpProjection);
|
||||
if (this.GLprogram == null) {
|
||||
Log.info("No shader ...");
|
||||
return;
|
||||
}
|
||||
//EWOL_DEBUG(" display " + this.coord.size() + " elements" );
|
||||
this.GLprogram.use();
|
||||
|
||||
// set Matrix : translation/positionMatrix
|
||||
Matrix4f projectionMatrix = tmpProjection; //OpenGL.getMatrix();
|
||||
Matrix4f transforamtionMatrix = Matrix4f.identity();
|
||||
transforamtionMatrix.multiply(Matrix4f.createMatrixTranslate(new Vector3f(0,0,-1)));
|
||||
transforamtionMatrix.multiply(Matrix4f.createMatrixRotate(new Vector3f(1,0,0),this.angleX));
|
||||
transforamtionMatrix.multiply(Matrix4f.createMatrixRotate(new Vector3f(0,1,0),this.angleY));
|
||||
transforamtionMatrix.multiply(Matrix4f.createMatrixRotate(new Vector3f(0,0,1),this.angleZ));
|
||||
Matrix4f viewMatrix = OpenGL.getCameraMatrix().multiply_new(Matrix4f.createMatrixTranslate(new Vector3f(0,0,-2)));
|
||||
//Matrix4f tmpMatrix = projMatrix * camMatrix;
|
||||
this.verticesVBO.bindForRendering();
|
||||
this.GLprogram.uniformMatrix(this.GLMatrixView, viewMatrix);
|
||||
this.GLprogram.uniformMatrix(this.GLMatrixProjection, projectionMatrix);
|
||||
// Change the position for each element with the same pipeline you need to render ...
|
||||
this.GLprogram.uniformMatrix(this.GLMatrixTransformation, transforamtionMatrix);
|
||||
this.texture.bindForRendering(0);
|
||||
// update of flags is done asyncronously ==> need update befor drawing...
|
||||
OpenGL.updateAllFlags();
|
||||
// Request the draw od the elements:
|
||||
this.verticesVBO.render(OpenGL.RenderMode.triangle);
|
||||
|
||||
this.verticesVBO.unBindForRendering();
|
||||
this.texture.unBindForRendering();
|
||||
this.GLprogram.unUse();
|
||||
// Restore context of matrix
|
||||
OpenGL.pop();
|
||||
this.markDrawingIsNeeded();
|
||||
}
|
||||
@Override
|
||||
public void onPointer(Type type,
|
||||
int pointerID,
|
||||
Vector2f pos,
|
||||
Status state) {
|
||||
// Log.info("input event: type=" + type);
|
||||
// Log.info(" id=" + pointerID);
|
||||
// Log.info(" pos=" + pos);
|
||||
// Log.info(" state=" + state);
|
||||
}
|
||||
@Override
|
||||
public void onKeyboard( Special special,
|
||||
Keyboard type,
|
||||
Character value,
|
||||
Status state) {
|
||||
Log.info("Keyboard event: special=" + special);
|
||||
Log.info(" type=" + type);
|
||||
Log.info(" value='" + value + "'");
|
||||
Log.info(" state=" + state);
|
||||
}
|
||||
}
|
17
src/org/atriaSoft/gale/test/sample2/basic.frag
Normal file
17
src/org/atriaSoft/gale/test/sample2/basic.frag
Normal file
@ -0,0 +1,17 @@
|
||||
#version 400 core
|
||||
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
precision mediump int;
|
||||
#endif
|
||||
|
||||
in vec2 out_textureCoords;
|
||||
|
||||
uniform sampler2D textureBase;
|
||||
|
||||
// output:
|
||||
out vec4 out_Color;
|
||||
|
||||
void main(void) {
|
||||
out_Color = texture(textureBase, out_textureCoords);
|
||||
}
|
21
src/org/atriaSoft/gale/test/sample2/basic.vert
Normal file
21
src/org/atriaSoft/gale/test/sample2/basic.vert
Normal file
@ -0,0 +1,21 @@
|
||||
#version 400 core
|
||||
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
precision mediump int;
|
||||
#endif
|
||||
|
||||
// Input:
|
||||
in vec3 position;
|
||||
in vec2 textureCoords;
|
||||
uniform mat4 matrixTransformation;
|
||||
uniform mat4 matrixProjection;
|
||||
uniform mat4 matrixView;
|
||||
|
||||
// output:
|
||||
out vec2 out_textureCoords;
|
||||
|
||||
void main(void) {
|
||||
gl_Position = matrixProjection * matrixView * matrixTransformation * vec4(position, 1.0);
|
||||
out_textureCoords = textureCoords;
|
||||
}
|
11
src/org/atriaSoft/gale/test/sample2/sample_2.java
Normal file
11
src/org/atriaSoft/gale/test/sample2/sample_2.java
Normal file
@ -0,0 +1,11 @@
|
||||
package org.atriaSoft.gale.test.sample2;
|
||||
|
||||
import org.atriaSoft.etk.Uri;
|
||||
import org.atriaSoft.gale.Gale;
|
||||
|
||||
public class sample_2 {
|
||||
public static void main(String[] args) {
|
||||
Uri.setGroup("DATA", "src/org/atriaSoft/gale/test/sample2/");
|
||||
Gale.run(new MainApplication(), args);
|
||||
}
|
||||
}
|
BIN
src/org/atriaSoft/gale/test/sample2/tree_sample.png
Normal file
BIN
src/org/atriaSoft/gale/test/sample2/tree_sample.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 98 KiB |
49
src/org/atriaSoft/gale/tools/ImageLoader.java
Normal file
49
src/org/atriaSoft/gale/tools/ImageLoader.java
Normal file
@ -0,0 +1,49 @@
|
||||
package org.atriaSoft.gale.tools;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import org.atriaSoft.etk.Uri;
|
||||
import org.atriaSoft.gale.test.sample2.Log;
|
||||
|
||||
import de.matthiasmann.twl.utils.PNGDecoder;
|
||||
import de.matthiasmann.twl.utils.PNGDecoder.Format;
|
||||
|
||||
public class ImageLoader {
|
||||
|
||||
public static ImageRawData decodePngFile(Uri filename) {
|
||||
ByteBuffer buf = null;
|
||||
int tWidth = 0;
|
||||
int tHeight = 0;
|
||||
boolean hasAlpha = false;
|
||||
try {
|
||||
// Open the PNG file as an InputStream
|
||||
InputStream in = new FileInputStream(filename.get());
|
||||
// Link the PNG decoder to this stream
|
||||
PNGDecoder decoder = new PNGDecoder(in);
|
||||
// Get the width and height of the texture
|
||||
tWidth = decoder.getWidth();
|
||||
tHeight = decoder.getHeight();
|
||||
hasAlpha = decoder.hasAlpha();
|
||||
// Decode the PNG file in a ByteBuffer
|
||||
if (hasAlpha == true) {
|
||||
buf = ByteBuffer.allocateDirect(4 * decoder.getWidth() * decoder.getHeight());
|
||||
//decoder.decodeFlipped(buf, decoder.getWidth() * 4, Format.RGBA);
|
||||
decoder.decode(buf, decoder.getWidth() * 4, Format.RGBA);
|
||||
} else {
|
||||
buf = ByteBuffer.allocateDirect(3 * decoder.getWidth() * decoder.getHeight());
|
||||
//decoder.decodeFlipped(buf, decoder.getWidth() * 4, Format.RGBA);
|
||||
decoder.decode(buf, decoder.getWidth() * 3, Format.RGB);
|
||||
}
|
||||
buf.flip();
|
||||
in.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
System.err.println("try to load texture " + filename + ", didn't work");
|
||||
System.exit(-1);
|
||||
}
|
||||
return new ImageRawData(buf, tWidth, tHeight, hasAlpha);
|
||||
}
|
||||
}
|
34
src/org/atriaSoft/gale/tools/ImageRawData.java
Normal file
34
src/org/atriaSoft/gale/tools/ImageRawData.java
Normal file
@ -0,0 +1,34 @@
|
||||
package org.atriaSoft.gale.tools;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public class ImageRawData {
|
||||
|
||||
private int width;
|
||||
private int height;
|
||||
private ByteBuffer buffer;
|
||||
private boolean hasAlpha;
|
||||
|
||||
public ImageRawData(ByteBuffer buffer, int width, int height, boolean hasAlpha){
|
||||
this.buffer = buffer;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.hasAlpha = hasAlpha;
|
||||
}
|
||||
|
||||
public int getWidth(){
|
||||
return width;
|
||||
}
|
||||
|
||||
public int getHeight(){
|
||||
return height;
|
||||
}
|
||||
|
||||
public ByteBuffer getBuffer(){
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public boolean isHasAlpha() {
|
||||
return hasAlpha;
|
||||
}
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
package org.atriaSoft.gameEngine;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.atriaSoft.gameEngine.camera.Camera;
|
||||
|
||||
public abstract class Engine {
|
||||
@ -34,5 +36,6 @@ public abstract class Engine {
|
||||
* @param[in] camera Camera property to render the engine properties ...
|
||||
*/
|
||||
public abstract void renderDebug(long deltaMili, Camera camera);
|
||||
public abstract String getType();
|
||||
}
|
||||
|
||||
|
@ -226,24 +226,24 @@ public abstract class Entity {
|
||||
* @param[in,out] draw Basic system to draw the debug shape and informations
|
||||
* @param[in] camera Current camera for display
|
||||
*/
|
||||
public void drawDebug(Colored3DObject draw, Camera camera) {
|
||||
/*
|
||||
mdebugText.clear();
|
||||
mdebugText.setColor(etk::Color<>(0x00, 0xFF, 0x00, 0xFF));
|
||||
mdebugText.setPos(Vector3f(-20,32,0));
|
||||
mdebugText.print(getType());
|
||||
mdebugText.setPos(Vector3f(-20,20,0));
|
||||
mdebugText.print("life=("+etk::toString(getLifeRatio()));
|
||||
*/
|
||||
//mdebugText.print(String("Axe=(")+String(mtmpAxe.x())+String(",")+etk::UString(mtmpAxe.y())+etk::UString(",")+etk::UString(m_tmpAxe.z())+etk::UString(")"));
|
||||
/*
|
||||
// TODO : Keep this it can be usefull to print something in direction of the camera ...
|
||||
mdebugText.draw( etk::matTranslate(getPosition())
|
||||
* etk::matRotate(Vector3f(0,0,1),camera.getAngleZ())
|
||||
* etk::matRotate(Vector3f(1,0,0),(MPI/2.0f-camera.getAngleTeta()))
|
||||
* etk::matScale(Vector3f(0.05,0.05,0.05)));
|
||||
*/
|
||||
}
|
||||
// public void drawDebug(Colored3DObject draw, Camera camera) {
|
||||
// /*
|
||||
// mdebugText.clear();
|
||||
// mdebugText.setColor(etk::Color<>(0x00, 0xFF, 0x00, 0xFF));
|
||||
// mdebugText.setPos(Vector3f(-20,32,0));
|
||||
// mdebugText.print(getType());
|
||||
// mdebugText.setPos(Vector3f(-20,20,0));
|
||||
// mdebugText.print("life=("+etk::toString(getLifeRatio()));
|
||||
// */
|
||||
// //mdebugText.print(String("Axe=(")+String(mtmpAxe.x())+String(",")+etk::UString(mtmpAxe.y())+etk::UString(",")+etk::UString(m_tmpAxe.z())+etk::UString(")"));
|
||||
// /*
|
||||
// // TODO : Keep this it can be usefull to print something in direction of the camera ...
|
||||
// mdebugText.draw( etk::matTranslate(getPosition())
|
||||
// * etk::matRotate(Vector3f(0,0,1),camera.getAngleZ())
|
||||
// * etk::matRotate(Vector3f(1,0,0),(MPI/2.0f-camera.getAngleTeta()))
|
||||
// * etk::matScale(Vector3f(0.05,0.05,0.05)));
|
||||
// */
|
||||
// }
|
||||
/**
|
||||
* @brief Event arrive when an Entity has been remove from the system == > this permit to keep pointer of ennemy, and not search them every cycle ...
|
||||
* @param[in] removedEntity Pointer on the Entity removed.
|
||||
|
@ -6,6 +6,10 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.atriaSoft.gameEngine.camera.Camera;
|
||||
import org.atriaSoft.gameEngine.engines.EngineRender;
|
||||
import org.atriaSoft.gameEngine.engines.EngineAI;
|
||||
import org.atriaSoft.gameEngine.engines.EngineParticle;
|
||||
import org.atriaSoft.gameEngine.engines.EnginePhysics;
|
||||
import org.atriaSoft.gameEngine.resource.Mesh;
|
||||
|
||||
public class Environement {
|
||||
@ -24,7 +28,7 @@ public class Environement {
|
||||
public Environement() {
|
||||
// we add the 4 classical engines (the order is used to the global rendering cycle ...
|
||||
addEngine(new EnginePhysics(this));
|
||||
addEngine(new EngineIA(this));
|
||||
addEngine(new EngineAI(this));
|
||||
addEngine(new EngineRender(this));
|
||||
addEngine(new EngineParticle(this));
|
||||
}
|
||||
@ -70,8 +74,8 @@ public class Environement {
|
||||
|
||||
public void engineComponentRemove(Component ref) {
|
||||
for (Engine it: engine) {
|
||||
if (it->getType() == ref->getType()) {
|
||||
it->componentRemove(ref);
|
||||
if (it.getType().contentEquals(ref.getType())) {
|
||||
it.componentRemove(ref);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -79,8 +83,8 @@ public class Environement {
|
||||
|
||||
public void engineComponentAdd(Component ref) {
|
||||
for (Engine it: engine) {
|
||||
if (it->getType() == ref->getType()) {
|
||||
it->componentAdd(ref);
|
||||
if (it.getType().contentEquals(ref.getType())) {
|
||||
it.componentAdd(ref);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -101,7 +105,7 @@ public class Environement {
|
||||
if(it == null) {
|
||||
continue;
|
||||
}
|
||||
Log.verbose(" render: " + it->getType());
|
||||
Log.verbose(" render: " + it.getType());
|
||||
it.renderDebug(deltaMilli, camera);
|
||||
}
|
||||
|
||||
@ -244,13 +248,13 @@ public class Environement {
|
||||
for (int iii=0; iii<listEntity.size() ; iii++) {
|
||||
event.applyEvent(listEntity.get(iii));
|
||||
/*
|
||||
Vector3f destPosition = mlistEntity[iii]->getPosition();
|
||||
Vector3f destPosition = mlistEntity[iii].getPosition();
|
||||
float dist = (sourcePosition - destPosition).length;
|
||||
if (dist == 0 || dist>decreasePower) {
|
||||
continue;
|
||||
}
|
||||
float inpact = (decreasePower-dist)/decreasePower * power;
|
||||
glistEntity[iii]->setFireOn(groupIdSource, type, -inpact, sourcePosition);
|
||||
glistEntity[iii].setFireOn(groupIdSource, type, -inpact, sourcePosition);
|
||||
*/
|
||||
}
|
||||
|
||||
@ -278,7 +282,7 @@ public class Environement {
|
||||
// for (auto it : mlistCamera) {
|
||||
// if (it.second != null) {
|
||||
// EGEVERBOSE(" update camera : '" + it.first + "'");
|
||||
// it.second->periodicCall(curentDelta);
|
||||
// it.second.periodicCall(curentDelta);
|
||||
// }
|
||||
// }
|
||||
// EGEVERBOSE(" step simulation : " + curentDelta);
|
||||
@ -286,8 +290,8 @@ public class Environement {
|
||||
// if(it == null) {
|
||||
// continue;
|
||||
// }
|
||||
// EGEVERBOSE(" update: " + it->getType());
|
||||
// it->update(echrono::Duration(double(curentDelta)));
|
||||
// EGEVERBOSE(" update: " + it.getType());
|
||||
// it.update(echrono::Duration(double(curentDelta)));
|
||||
// }
|
||||
//
|
||||
// //EGE.debug("stepSimulation (start)");
|
||||
@ -305,12 +309,12 @@ public class Environement {
|
||||
// auto it(mlistEntity.begin());
|
||||
// while (it != mlistEntity.end()) {
|
||||
// if(*it != null) {
|
||||
// if ((*it)->needToRemove() == true) {
|
||||
// if ((*it)->getGroup() > 1) {
|
||||
// if ((*it).needToRemove() == true) {
|
||||
// if ((*it).getGroup() > 1) {
|
||||
// numberEnnemyKilled++;
|
||||
// victoryPoint++;
|
||||
// }
|
||||
// EGEINFO("[" + (*it)->getUID() + "] entity Removing ... " + (*it)->getType());
|
||||
// EGEINFO("[" + (*it).getUID() + "] entity Removing ... " + (*it).getType());
|
||||
// rmEntity((*it));
|
||||
// it = mlistEntity.begin();
|
||||
// } else {
|
||||
@ -359,7 +363,7 @@ public class Environement {
|
||||
* 99999999999.0f; result.entity = null; for (int iii=0; iii<mlistEntity.size()
|
||||
* ; iii++) { // chack null pointer result.entity = mlistEntity[iii]; if
|
||||
* (result.entity == null) { continue; } // check distance ... Vector3f
|
||||
* destPosition = result.entity->getPosition(); if (sourcePosition ==
|
||||
* destPosition = result.entity.getPosition(); if (sourcePosition ==
|
||||
* destPosition) { continue; } result.dist = (sourcePosition -
|
||||
* destPosition).length(); //EGE.debug("Distance : " + distance + " >? " +
|
||||
* distance + " id=" + iii); if (distanceMax>result.dist) {
|
||||
@ -370,9 +374,9 @@ public class Environement {
|
||||
* resultList.clear(); Environement::ResultNearestEntity result; result.dist =
|
||||
* 99999999999.0f; result.entity = null; for (int iii=0; iii<mlistEntity.size()
|
||||
* ; iii++) { // chack null pointer result.entity = mlistEntity[iii]; if
|
||||
* (result.entity == null) { continue; } if (result.entity->isFixed() == false)
|
||||
* (result.entity == null) { continue; } if (result.entity.isFixed() == false)
|
||||
* { continue; } // check distance ... Vector3f destPosition =
|
||||
* result.entity->getPositionTheoric(); result.dist = (sourcePosition -
|
||||
* result.entity.getPositionTheoric(); result.dist = (sourcePosition -
|
||||
* destPosition).length(); //EGE.debug("Distance : " + distance + " >? " +
|
||||
* distance + " id=" + iii); if (distanceMax <= result.dist) { continue; } //
|
||||
* try to add the entity at the best positions: int jjj; for (jjj=0;
|
||||
|
@ -1,5 +1,12 @@
|
||||
package org.atriaSoft.gameEngine;
|
||||
|
||||
public class Signal<T> {
|
||||
import org.atriaSoft.etk.math.Transform3D;
|
||||
|
||||
public class Signal<TYPE> {
|
||||
|
||||
public void emit(TYPE transform) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
12
src/org/atriaSoft/gameEngine/components/ComponentAI.java
Normal file
12
src/org/atriaSoft/gameEngine/components/ComponentAI.java
Normal file
@ -0,0 +1,12 @@
|
||||
package org.atriaSoft.gameEngine.components;
|
||||
|
||||
import org.atriaSoft.gameEngine.Component;
|
||||
|
||||
public class ComponentAI extends Component {
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package org.atriaSoft.gameEngine.components;
|
||||
|
||||
import org.atriaSoft.gameEngine.Component;
|
||||
|
||||
public class ComponentParticle extends Component {
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,22 +1,24 @@
|
||||
package org.atriaSoft.gameEngine.component;
|
||||
package org.atriaSoft.gameEngine.components;
|
||||
|
||||
import org.atriaSoft.etk.math.Transform3D;
|
||||
import org.atriaSoft.gameEngine.Component;
|
||||
import org.atriaSoft.gameEngine.Log;
|
||||
import org.atriaSoft.gameEngine.Signal;
|
||||
|
||||
public class ComponentPosition {
|
||||
public Component {
|
||||
public class ComponentPosition extends Component {
|
||||
public Signal<Transform3D> signalPosition;
|
||||
protected Transform3D transform;
|
||||
/**
|
||||
* @brief Create a basic position component (no orientation and position (0,0,0))
|
||||
*/
|
||||
public Component() {
|
||||
public ComponentPosition() {
|
||||
transform = Transform3D.identity();
|
||||
}
|
||||
/**
|
||||
* @brief Create a basic position component
|
||||
* @param[in] transform transformation of the position
|
||||
*/
|
||||
public Component(Transform3D transform) {
|
||||
public ComponentPosition(Transform3D transform) {
|
||||
this.transform = transform;
|
||||
}
|
||||
/**
|
||||
@ -27,7 +29,7 @@ public class ComponentPosition {
|
||||
if (this.transform.isEqual(transform)) {
|
||||
return;
|
||||
}
|
||||
transform = transform;
|
||||
this.transform = transform;
|
||||
signalPosition.emit(this.transform);
|
||||
}
|
||||
/**
|
13
src/org/atriaSoft/gameEngine/components/ComponentRender.java
Normal file
13
src/org/atriaSoft/gameEngine/components/ComponentRender.java
Normal file
@ -0,0 +1,13 @@
|
||||
package org.atriaSoft.gameEngine.components;
|
||||
|
||||
import org.atriaSoft.gameEngine.Component;
|
||||
|
||||
public class ComponentRender extends Component {
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
12
src/org/atriaSoft/gameEngine/components/CoponentPhysics.java
Normal file
12
src/org/atriaSoft/gameEngine/components/CoponentPhysics.java
Normal file
@ -0,0 +1,12 @@
|
||||
package org.atriaSoft.gameEngine.components;
|
||||
|
||||
import org.atriaSoft.gameEngine.Component;
|
||||
|
||||
public class CoponentPhysics extends Component {
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
}
|
51
src/org/atriaSoft/gameEngine/engines/EngineAI.java
Normal file
51
src/org/atriaSoft/gameEngine/engines/EngineAI.java
Normal file
@ -0,0 +1,51 @@
|
||||
package org.atriaSoft.gameEngine.engines;
|
||||
|
||||
import org.atriaSoft.gameEngine.Component;
|
||||
import org.atriaSoft.gameEngine.Engine;
|
||||
import org.atriaSoft.gameEngine.Environement;
|
||||
import org.atriaSoft.gameEngine.camera.Camera;
|
||||
|
||||
public class EngineAI extends Engine {
|
||||
|
||||
public EngineAI(Environement env) {
|
||||
super(env);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public void componentRemove(Component ref) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void componentAdd(Component ref) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(long deltaMili) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(long deltaMili, Camera camera) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderDebug(long deltaMili, Camera camera) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
52
src/org/atriaSoft/gameEngine/engines/EngineParticle.java
Normal file
52
src/org/atriaSoft/gameEngine/engines/EngineParticle.java
Normal file
@ -0,0 +1,52 @@
|
||||
package org.atriaSoft.gameEngine.engines;
|
||||
|
||||
import org.atriaSoft.gameEngine.Component;
|
||||
import org.atriaSoft.gameEngine.Engine;
|
||||
import org.atriaSoft.gameEngine.Environement;
|
||||
import org.atriaSoft.gameEngine.camera.Camera;
|
||||
|
||||
public class EngineParticle extends Engine {
|
||||
|
||||
public EngineParticle(Environement env) {
|
||||
super(env);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public void componentRemove(Component ref) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void componentAdd(Component ref) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(long deltaMili) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(long deltaMili, Camera camera) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderDebug(long deltaMili, Camera camera) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
51
src/org/atriaSoft/gameEngine/engines/EnginePhysics.java
Normal file
51
src/org/atriaSoft/gameEngine/engines/EnginePhysics.java
Normal file
@ -0,0 +1,51 @@
|
||||
package org.atriaSoft.gameEngine.engines;
|
||||
|
||||
import org.atriaSoft.gameEngine.Component;
|
||||
import org.atriaSoft.gameEngine.Engine;
|
||||
import org.atriaSoft.gameEngine.Environement;
|
||||
import org.atriaSoft.gameEngine.camera.Camera;
|
||||
|
||||
public class EnginePhysics extends Engine {
|
||||
|
||||
public EnginePhysics(Environement env) {
|
||||
super(env);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public void componentRemove(Component ref) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void componentAdd(Component ref) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(long deltaMili) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(long deltaMili, Camera camera) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderDebug(long deltaMili, Camera camera) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
51
src/org/atriaSoft/gameEngine/engines/EngineRender.java
Normal file
51
src/org/atriaSoft/gameEngine/engines/EngineRender.java
Normal file
@ -0,0 +1,51 @@
|
||||
package org.atriaSoft.gameEngine.engines;
|
||||
|
||||
import org.atriaSoft.gameEngine.Component;
|
||||
import org.atriaSoft.gameEngine.Engine;
|
||||
import org.atriaSoft.gameEngine.Environement;
|
||||
import org.atriaSoft.gameEngine.camera.Camera;
|
||||
|
||||
public class EngineRender extends Engine {
|
||||
|
||||
public EngineRender(Environement env) {
|
||||
super(env);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public void componentRemove(Component ref) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void componentAdd(Component ref) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(long deltaMili) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(long deltaMili, Camera camera) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderDebug(long deltaMili, Camera camera) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
package org.atriaSoft.gameEngine.sample.lowPoly;
|
||||
|
||||
public class sample_lowPoly {
|
||||
|
||||
}
|
@ -38,10 +38,10 @@ public abstract class ShaderProgram {
|
||||
}
|
||||
|
||||
public void start() {
|
||||
OpenGL.useProgram(programID);
|
||||
OpenGL.programUse(programID);
|
||||
}
|
||||
public void stop() {
|
||||
OpenGL.unUseProgram(programID);
|
||||
OpenGL.programUnUse(programID);
|
||||
}
|
||||
public void cleanUp() {
|
||||
stop();
|
||||
|
Loading…
Reference in New Issue
Block a user