Fixing more bitmapchar bugs
This commit is contained in:
parent
be6f725504
commit
7d17d28a35
@ -162,6 +162,10 @@ public class Globals {
|
|||||||
|
|
||||||
public static int WINDOW_WIDTH = 1920;
|
public static int WINDOW_WIDTH = 1920;
|
||||||
public static int WINDOW_HEIGHT = 1080;
|
public static int WINDOW_HEIGHT = 1080;
|
||||||
|
|
||||||
|
//title bar dimensions
|
||||||
|
public static int WINDOW_TITLE_BAR_HEIGHT = 0;
|
||||||
|
|
||||||
public static float FOV = 90;
|
public static float FOV = 90;
|
||||||
|
|
||||||
//matrices for drawing models
|
//matrices for drawing models
|
||||||
|
|||||||
@ -703,20 +703,20 @@ public class ModelUtils {
|
|||||||
glBindVertexArray(m.vertexArrayObject);
|
glBindVertexArray(m.vertexArrayObject);
|
||||||
//vertices
|
//vertices
|
||||||
FloatBuffer VertexArrayBufferData = BufferUtils.createFloatBuffer(12);
|
FloatBuffer VertexArrayBufferData = BufferUtils.createFloatBuffer(12);
|
||||||
VertexArrayBufferData.put( 0);
|
VertexArrayBufferData.put(-1);
|
||||||
VertexArrayBufferData.put( 1);
|
VertexArrayBufferData.put( 1);
|
||||||
|
|
||||||
VertexArrayBufferData.put( 0);
|
VertexArrayBufferData.put(-1);
|
||||||
VertexArrayBufferData.put( 0);
|
VertexArrayBufferData.put(-1);
|
||||||
|
|
||||||
VertexArrayBufferData.put( 1);
|
VertexArrayBufferData.put( 1);
|
||||||
VertexArrayBufferData.put( 0);
|
VertexArrayBufferData.put(-1);
|
||||||
|
|
||||||
VertexArrayBufferData.put( 0);
|
VertexArrayBufferData.put(-1);
|
||||||
VertexArrayBufferData.put( 1);
|
VertexArrayBufferData.put( 1);
|
||||||
|
|
||||||
VertexArrayBufferData.put( 1);
|
VertexArrayBufferData.put( 1);
|
||||||
VertexArrayBufferData.put( 0);
|
VertexArrayBufferData.put(-1);
|
||||||
|
|
||||||
VertexArrayBufferData.put( 1);
|
VertexArrayBufferData.put( 1);
|
||||||
VertexArrayBufferData.put( 1);
|
VertexArrayBufferData.put( 1);
|
||||||
|
|||||||
@ -21,10 +21,12 @@ import electrosphere.renderer.framebuffer.Renderbuffer;
|
|||||||
import electrosphere.renderer.texture.Texture;
|
import electrosphere.renderer.texture.Texture;
|
||||||
import electrosphere.renderer.ui.Widget;
|
import electrosphere.renderer.ui.Widget;
|
||||||
import java.nio.FloatBuffer;
|
import java.nio.FloatBuffer;
|
||||||
|
import java.nio.IntBuffer;
|
||||||
import org.joml.Matrix4f;
|
import org.joml.Matrix4f;
|
||||||
import org.joml.Quaternionf;
|
import org.joml.Quaternionf;
|
||||||
import org.joml.Vector3d;
|
import org.joml.Vector3d;
|
||||||
import org.joml.Vector3f;
|
import org.joml.Vector3f;
|
||||||
|
import org.lwjgl.BufferUtils;
|
||||||
import org.lwjgl.glfw.GLFW;
|
import org.lwjgl.glfw.GLFW;
|
||||||
import static org.lwjgl.glfw.GLFW.GLFW_CONTEXT_VERSION_MAJOR;
|
import static org.lwjgl.glfw.GLFW.GLFW_CONTEXT_VERSION_MAJOR;
|
||||||
import static org.lwjgl.glfw.GLFW.GLFW_CONTEXT_VERSION_MINOR;
|
import static org.lwjgl.glfw.GLFW.GLFW_CONTEXT_VERSION_MINOR;
|
||||||
@ -136,6 +138,25 @@ public class RenderingEngine {
|
|||||||
glfwMakeContextCurrent(Globals.window);
|
glfwMakeContextCurrent(Globals.window);
|
||||||
//Maximize it
|
//Maximize it
|
||||||
glfwMaximizeWindow(Globals.window);
|
glfwMaximizeWindow(Globals.window);
|
||||||
|
//grab actual framebuffer
|
||||||
|
IntBuffer xBuffer = BufferUtils.createIntBuffer(1);
|
||||||
|
IntBuffer yBuffer = BufferUtils.createIntBuffer(1);
|
||||||
|
GLFW.glfwGetFramebufferSize(Globals.window, xBuffer, yBuffer);
|
||||||
|
|
||||||
|
int bufferWidth = xBuffer.get();
|
||||||
|
int bufferHeight = yBuffer.get();
|
||||||
|
|
||||||
|
//get title bar size
|
||||||
|
Globals.WINDOW_TITLE_BAR_HEIGHT = Globals.WINDOW_HEIGHT - bufferHeight;
|
||||||
|
|
||||||
|
System.out.println(Globals.WINDOW_TITLE_BAR_HEIGHT);
|
||||||
|
|
||||||
|
Globals.WINDOW_WIDTH = bufferWidth;
|
||||||
|
Globals.WINDOW_HEIGHT = bufferHeight;
|
||||||
|
|
||||||
|
//get title bar dimensions
|
||||||
|
// setTitleBarDimensions();
|
||||||
|
|
||||||
//Creates the OpenGL capabilities for the program.
|
//Creates the OpenGL capabilities for the program.
|
||||||
GL.createCapabilities();
|
GL.createCapabilities();
|
||||||
|
|
||||||
@ -665,4 +686,16 @@ public class RenderingEngine {
|
|||||||
glViewport(0, 0, width, height);
|
glViewport(0, 0, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setTitleBarDimensions(){
|
||||||
|
IntBuffer tLeft = BufferUtils.createIntBuffer(1);
|
||||||
|
IntBuffer tTop = BufferUtils.createIntBuffer(1);
|
||||||
|
IntBuffer tRight = BufferUtils.createIntBuffer(1);
|
||||||
|
IntBuffer tBottom = BufferUtils.createIntBuffer(1);
|
||||||
|
|
||||||
|
// Get the title bar dims
|
||||||
|
GLFW.glfwGetWindowFrameSize(Globals.window, tLeft, tTop, tRight, tBottom);
|
||||||
|
Globals.WINDOW_TITLE_BAR_HEIGHT = tTop.get();
|
||||||
|
// System.out.println(tLeft.get() + " " + tTop.get() + " " + tRight.get() + " " + tBottom.get());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -95,7 +95,7 @@ public class WidgetUtils {
|
|||||||
// rVal.addWidget(textInput);
|
// rVal.addWidget(textInput);
|
||||||
|
|
||||||
|
|
||||||
BitmapCharacter characterDisp = new BitmapCharacter(0,-50,500,500,'A');
|
BitmapCharacter characterDisp = new BitmapCharacter(0,0,500,500,'A');
|
||||||
rVal.addWidget(characterDisp);
|
rVal.addWidget(characterDisp);
|
||||||
|
|
||||||
// TextInput textInput2 = new TextInput();
|
// TextInput textInput2 = new TextInput();
|
||||||
|
|||||||
@ -51,7 +51,7 @@ public class BitmapCharacter extends Widget {
|
|||||||
Globals.renderingEngine.bindFramebuffer(parentFramebufferPointer);
|
Globals.renderingEngine.bindFramebuffer(parentFramebufferPointer);
|
||||||
Globals.renderingEngine.setViewportSize(parentWidth, parentHeight);
|
Globals.renderingEngine.setViewportSize(parentWidth, parentHeight);
|
||||||
float ndcX = (float)positionX/parentWidth;
|
float ndcX = (float)positionX/parentWidth;
|
||||||
float ndcY = (float)positionY/parentHeight;
|
float ndcY = (float)positionY/parentHeight + (float)Globals.WINDOW_TITLE_BAR_HEIGHT/parentHeight;
|
||||||
float ndcWidth = (float)width/parentWidth;
|
float ndcWidth = (float)width/parentWidth;
|
||||||
float ndcHeight = (float)height/parentHeight;
|
float ndcHeight = (float)height/parentHeight;
|
||||||
// System.out.println(ndcX + " " + ndcY + " " + ndcWidth + " " + ndcHeight);
|
// System.out.println(ndcX + " " + ndcY + " " + ndcWidth + " " + ndcHeight);
|
||||||
@ -63,6 +63,10 @@ public class BitmapCharacter extends Widget {
|
|||||||
Vector3f characterDimensions = new Vector3f(ndcWidth,ndcHeight,0);
|
Vector3f characterDimensions = new Vector3f(ndcWidth,ndcHeight,0);
|
||||||
Vector3f bitMapPosition = FontUtils.getPositionOfCharacter(toDraw);
|
Vector3f bitMapPosition = FontUtils.getPositionOfCharacter(toDraw);
|
||||||
Vector3f bitMapDimension = FontUtils.getDimensionOfCharacter(toDraw);
|
Vector3f bitMapDimension = FontUtils.getDimensionOfCharacter(toDraw);
|
||||||
|
// bitMapDimension.y = 1;
|
||||||
|
// System.out.println(bitMapPosition);
|
||||||
|
// System.out.println(bitMapDimension);
|
||||||
|
// System.out.println("\n\n");
|
||||||
Model charModel = Globals.assetManager.fetchModel(AssetDataStrings.BITMAP_CHARACTER_MODEL);
|
Model charModel = Globals.assetManager.fetchModel(AssetDataStrings.BITMAP_CHARACTER_MODEL);
|
||||||
if(charModel != null && toDraw != ' '){
|
if(charModel != null && toDraw != ' '){
|
||||||
charModel.pushUniformToMesh(AssetDataStrings.ASSET_STRING_BITMAP_FONT_MESH_NAME, "mPosition", characterPosition);
|
charModel.pushUniformToMesh(AssetDataStrings.ASSET_STRING_BITMAP_FONT_MESH_NAME, "mPosition", characterPosition);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user