Partway to getting fonts working
This commit is contained in:
parent
152aac2492
commit
31e506ff1f
@ -62,5 +62,11 @@ public class EntityDataStrings {
|
||||
public static final String DATA_STRING_LIGHT_CUTOFF = "lightCutoff";
|
||||
public static final String DATA_STRING_LIGHT_CUTOFF_OUTER = "lightCutoffOuter";
|
||||
|
||||
/*
|
||||
UI Entity
|
||||
*/
|
||||
public static final String DATA_STRING_UI_ELEMENT = "uiEntity";
|
||||
public static final String DATA_STRING_UI_ELEMENT_FONT = "uiFont";
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -16,6 +16,7 @@ public class EntityManager {
|
||||
static CopyOnWriteArrayList<Entity> drawableList = new CopyOnWriteArrayList();
|
||||
static CopyOnWriteArrayList<Entity> moveableList = new CopyOnWriteArrayList();
|
||||
static CopyOnWriteArrayList<Entity> lightList = new CopyOnWriteArrayList();
|
||||
static CopyOnWriteArrayList<Entity> uiList = new CopyOnWriteArrayList();
|
||||
|
||||
public EntityManager(){
|
||||
|
||||
@ -50,6 +51,14 @@ public class EntityManager {
|
||||
return lightList;
|
||||
}
|
||||
|
||||
public void registerUIEntity(Entity e){
|
||||
uiList.add(e);
|
||||
}
|
||||
|
||||
public CopyOnWriteArrayList<Entity> getUIElements(){
|
||||
return uiList;
|
||||
}
|
||||
|
||||
public void deregisterEntity(Entity e){
|
||||
if(lightList.contains(e)){
|
||||
lightList.remove(e);
|
||||
@ -64,6 +73,9 @@ public class EntityManager {
|
||||
if(entityList.contains(e)){
|
||||
entityList.remove(e);
|
||||
}
|
||||
if(uiList.contains(e)){
|
||||
uiList.remove(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void overrideEntityId(Entity e, int id){
|
||||
|
||||
@ -58,6 +58,18 @@ public class EntityUtils {
|
||||
return rVal;
|
||||
}
|
||||
|
||||
public static Entity spawnUIEntity(String modelPath){
|
||||
Entity rVal = new Entity();
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_ACTOR, ActorUtils.createActorFromModelPath(modelPath));
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_POSITION, new Vector3f(0,0,0));
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_ROTATION, new Quaternionf().rotateAxis((float)0, new Vector3f(1,0,0)));
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_SCALE, new Vector3f(1,1,1));
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_UI_ELEMENT, true);
|
||||
Globals.entityManager.registerEntity(rVal);
|
||||
Globals.entityManager.registerUIEntity(rVal);
|
||||
return rVal;
|
||||
}
|
||||
|
||||
public static void cleanUpDrawableEntity(Entity e){
|
||||
if(e != null){
|
||||
Globals.entityManager.deregisterEntity(e);
|
||||
|
||||
@ -20,6 +20,7 @@ import electrosphere.net.client.ClientNetworkMessage;
|
||||
import electrosphere.net.client.ClientNetworking;
|
||||
import electrosphere.net.server.Server;
|
||||
import electrosphere.renderer.Actor;
|
||||
import electrosphere.renderer.ui.font.FontUtils;
|
||||
import electrosphere.renderer.ModelUtils;
|
||||
import electrosphere.terraingen.TerrainGen;
|
||||
import electrosphere.terraingen.models.TerrainModel;
|
||||
@ -104,7 +105,7 @@ public class Main {
|
||||
|
||||
static boolean running = true;
|
||||
|
||||
|
||||
public static Entity letterEntity;
|
||||
|
||||
public static void main(String args[]){
|
||||
|
||||
@ -162,7 +163,7 @@ public class Main {
|
||||
|
||||
// String unitCubeModelPath = Globals.assetManager.registerModel(ModelUtils.createUnitCube());
|
||||
// Entity unitCube = EntityUtils.spawnDrawableEntity(unitCubeModelPath);
|
||||
// EntityUtils.getEntityPosition(unitCube).set(playerStartRealX - 0.5f,10,playerStartRealY - 0.5f);
|
||||
// EntityUtils.getEntityPosition(unitCube).set(10,2,10);
|
||||
|
||||
// String goundPlaneModelPath = "Models/groundplanemassiveuv.fbx";
|
||||
// Entity groundPlane = EntityUtils.spawnDrawableEntity(goundPlaneModelPath);
|
||||
@ -175,6 +176,9 @@ public class Main {
|
||||
EntityUtils.getEntityPosition(unitsphere).set(10f,2f,10f);
|
||||
EntityUtils.getEntityScale(unitsphere).set(1);
|
||||
|
||||
Entity font = FontUtils.makeFont(7, 1);
|
||||
EntityUtils.getEntityPosition(font).set(new Vector3f(0.2f,0.2f,0.0f));
|
||||
|
||||
for(int i = 0; i < 10; i++){
|
||||
Random rand = new Random();
|
||||
Entity creature = CreatureUtils.spawnBasicCreature(0, 0.01f, 0.01f);
|
||||
|
||||
@ -90,4 +90,15 @@ public class Actor {
|
||||
}
|
||||
}
|
||||
|
||||
public void drawUI(){
|
||||
Model model = Globals.assetManager.fetchModel(modelPath);
|
||||
if(model != null){
|
||||
model.drawUI();
|
||||
}
|
||||
}
|
||||
|
||||
public String getModelPath(){
|
||||
return modelPath;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -176,7 +176,7 @@ public class Mesh {
|
||||
rVal.vertexMinZ = minZ;
|
||||
|
||||
VertexArrayBufferData.flip();
|
||||
rVal.buffer_vertices(VertexArrayBufferData);
|
||||
rVal.buffer_vertices(VertexArrayBufferData, 3);
|
||||
} catch (NullPointerException ex){
|
||||
ex.printStackTrace();
|
||||
}
|
||||
@ -198,7 +198,7 @@ public class Mesh {
|
||||
NormalArrayBufferData.put(temp);
|
||||
}
|
||||
NormalArrayBufferData.flip();
|
||||
rVal.buffer_normals(NormalArrayBufferData);
|
||||
rVal.buffer_normals(NormalArrayBufferData, 3);
|
||||
}
|
||||
} catch (NullPointerException ex){
|
||||
ex.printStackTrace();
|
||||
@ -243,7 +243,7 @@ public class Mesh {
|
||||
TextureArrayBufferData.put(temp);
|
||||
}
|
||||
TextureArrayBufferData.flip();
|
||||
rVal.buffer_texture_coords(TextureArrayBufferData);
|
||||
rVal.buffer_texture_coords(TextureArrayBufferData, 2);
|
||||
}
|
||||
} catch (NullPointerException ex){
|
||||
ex.printStackTrace();
|
||||
@ -540,19 +540,19 @@ public class Mesh {
|
||||
glBindVertexArray(0);
|
||||
}
|
||||
|
||||
public void buffer_vertices(FloatBuffer verticies){
|
||||
public void buffer_vertices(FloatBuffer verticies, int vertexDimension){
|
||||
vertexBuffer = glGenBuffers();
|
||||
glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer);
|
||||
GL15.glBufferData(GL_ARRAY_BUFFER, verticies, GL_STATIC_DRAW);
|
||||
glVertexAttribPointer(0, 3, GL_FLOAT, false, 0, 0);
|
||||
glVertexAttribPointer(0, vertexDimension, GL_FLOAT, false, 0, 0);
|
||||
glEnableVertexAttribArray(0);
|
||||
}
|
||||
|
||||
public void buffer_normals(FloatBuffer normals){
|
||||
public void buffer_normals(FloatBuffer normals, int normalDimension){
|
||||
normalBuffer = glGenBuffers();
|
||||
glBindBuffer(GL_ARRAY_BUFFER, normalBuffer);
|
||||
GL15.glBufferData(GL_ARRAY_BUFFER, normals, GL_STATIC_DRAW);
|
||||
glVertexAttribPointer(1, 3, GL_FLOAT, false, 0, 0);
|
||||
glVertexAttribPointer(1, normalDimension, GL_FLOAT, false, 0, 0);
|
||||
glEnableVertexAttribArray(1);
|
||||
}
|
||||
|
||||
@ -563,11 +563,11 @@ public class Mesh {
|
||||
elementCount = faces.capacity();
|
||||
}
|
||||
|
||||
public void buffer_texture_coords(FloatBuffer coords){
|
||||
public void buffer_texture_coords(FloatBuffer coords, int textureDimension){
|
||||
textureCoordBuffer = glGenBuffers();
|
||||
glBindBuffer(GL_ARRAY_BUFFER, textureCoordBuffer);
|
||||
GL15.glBufferData(GL_ARRAY_BUFFER, coords, GL_STATIC_DRAW);
|
||||
glVertexAttribPointer(4, 2, GL_FLOAT, false, 0, 0);
|
||||
glVertexAttribPointer(4, textureDimension, GL_FLOAT, false, 0, 0);
|
||||
glEnableVertexAttribArray(4);
|
||||
}
|
||||
|
||||
@ -617,6 +617,29 @@ public class Mesh {
|
||||
glUniformMatrix4fv(glGetUniformLocation(Globals.depthMapShaderProgramLoc, "lightSpaceMatrix"), false, Globals.lightDepthMatrix.get(new float[16]));
|
||||
|
||||
|
||||
GL11.glDrawElements(GL_TRIANGLES, elementCount, GL_UNSIGNED_INT, 0);
|
||||
glBindVertexArray(0);
|
||||
}
|
||||
|
||||
public void drawUI(){
|
||||
glUseProgram(shader.shaderProgram);
|
||||
|
||||
glBindVertexArray(vertexArrayObject);
|
||||
|
||||
if(material == null){
|
||||
Globals.materialDefault.apply_material(0,1);
|
||||
GL20.glUniform1i(glGetUniformLocation(shader.shaderProgram, "hasTransparency"), 0);
|
||||
} else {
|
||||
material.apply_material();
|
||||
if(material.hasTransparency){
|
||||
GL20.glUniform1i(glGetUniformLocation(shader.shaderProgram, "hasTransparency"), 1);
|
||||
} else {
|
||||
GL20.glUniform1i(glGetUniformLocation(shader.shaderProgram, "hasTransparency"), 1);
|
||||
}
|
||||
}
|
||||
|
||||
glUniformMatrix4fv(glGetUniformLocation(shader.shaderProgram, "model"), false, parent.modelMatrix.get(new float[16]));
|
||||
|
||||
GL11.glDrawElements(GL_TRIANGLES, elementCount, GL_UNSIGNED_INT, 0);
|
||||
glBindVertexArray(0);
|
||||
}
|
||||
|
||||
@ -347,4 +347,10 @@ public class Model {
|
||||
currentMesh.drawForDepthBuffer();
|
||||
}
|
||||
}
|
||||
|
||||
public void drawUI(){
|
||||
for(Mesh m : meshes){
|
||||
m.drawUI();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -141,13 +141,13 @@ public class ModelUtils {
|
||||
m.vertexArrayObject = glGenVertexArrays();
|
||||
glBindVertexArray(m.vertexArrayObject);
|
||||
//buffer vertices
|
||||
m.buffer_vertices(vertices);
|
||||
m.buffer_vertices(vertices, 3);
|
||||
//buffer normals
|
||||
m.buffer_normals(normals);
|
||||
m.buffer_normals(normals, 3);
|
||||
//buffer faces
|
||||
m.buffer_faces(faces);
|
||||
//buffer texture coords
|
||||
m.buffer_texture_coords(texture_coords);
|
||||
m.buffer_texture_coords(texture_coords, 2);
|
||||
m.shader = ShaderProgram.smart_assemble_shader(false,true);
|
||||
glBindVertexArray(0);
|
||||
m.parent = rVal;
|
||||
@ -305,13 +305,13 @@ public class ModelUtils {
|
||||
m.vertexArrayObject = glGenVertexArrays();
|
||||
glBindVertexArray(m.vertexArrayObject);
|
||||
//buffer vertices
|
||||
m.buffer_vertices(vertices);
|
||||
m.buffer_vertices(vertices, 3);
|
||||
//buffer normals
|
||||
m.buffer_normals(normals);
|
||||
m.buffer_normals(normals, 3);
|
||||
//buffer faces
|
||||
m.buffer_faces(faces);
|
||||
//buffer texture coords
|
||||
m.buffer_texture_coords(texture_coords);
|
||||
m.buffer_texture_coords(texture_coords, 2);
|
||||
m.shader = program;
|
||||
glBindVertexArray(0);
|
||||
m.parent = rVal;
|
||||
@ -473,13 +473,13 @@ public class ModelUtils {
|
||||
m.vertexArrayObject = glGenVertexArrays();
|
||||
glBindVertexArray(m.vertexArrayObject);
|
||||
//buffer vertices
|
||||
m.buffer_vertices(vertices);
|
||||
m.buffer_vertices(vertices, 3);
|
||||
//buffer normals
|
||||
m.buffer_normals(normals);
|
||||
m.buffer_normals(normals, 3);
|
||||
//buffer faces
|
||||
m.buffer_faces(faces);
|
||||
//buffer texture coords
|
||||
m.buffer_texture_coords(texture_coords);
|
||||
m.buffer_texture_coords(texture_coords, 2);
|
||||
m.shader = ShaderProgram.smart_assemble_shader(false,true);
|
||||
glBindVertexArray(0);
|
||||
m.parent = rVal;
|
||||
@ -523,4 +523,97 @@ public class ModelUtils {
|
||||
}
|
||||
System.out.println("dimensions: " + (maxX - minX) + "," + (maxY - minY) + "," + (maxZ-minZ));
|
||||
}
|
||||
|
||||
public static Model createBitmapDisplay(
|
||||
float mStartX, float mStartY, float mWidth, float mHeight,
|
||||
float tStartX, float tStartY, float tWidth, float tHeight
|
||||
){
|
||||
|
||||
Model rVal = new Model();
|
||||
rVal.meshes = new ArrayList();
|
||||
Mesh m = new Mesh();
|
||||
m.vertexArrayObject = glGenVertexArrays();
|
||||
glBindVertexArray(m.vertexArrayObject);
|
||||
//vertices
|
||||
FloatBuffer VertexArrayBufferData = BufferUtils.createFloatBuffer(12);
|
||||
VertexArrayBufferData.put( mStartX);
|
||||
VertexArrayBufferData.put( mStartY+mHeight);
|
||||
|
||||
VertexArrayBufferData.put( mStartX);
|
||||
VertexArrayBufferData.put( mStartY);
|
||||
|
||||
VertexArrayBufferData.put( mStartX+mWidth);
|
||||
VertexArrayBufferData.put( mStartY);
|
||||
|
||||
VertexArrayBufferData.put( mStartX);
|
||||
VertexArrayBufferData.put( mStartY+mHeight);
|
||||
|
||||
VertexArrayBufferData.put( mStartX+mWidth);
|
||||
VertexArrayBufferData.put( mStartY);
|
||||
|
||||
VertexArrayBufferData.put( mStartX+mWidth);
|
||||
VertexArrayBufferData.put( mStartY+mHeight);
|
||||
VertexArrayBufferData.flip();
|
||||
|
||||
|
||||
IntBuffer faceArrayBufferData = BufferUtils.createIntBuffer(6);
|
||||
faceArrayBufferData.put(0);
|
||||
faceArrayBufferData.put(1);
|
||||
faceArrayBufferData.put(2);
|
||||
|
||||
faceArrayBufferData.put(3);
|
||||
faceArrayBufferData.put(4);
|
||||
faceArrayBufferData.put(5);
|
||||
faceArrayBufferData.flip();
|
||||
|
||||
|
||||
|
||||
//texture coords
|
||||
FloatBuffer TextureArrayBufferData = BufferUtils.createFloatBuffer(12);
|
||||
TextureArrayBufferData.put(tStartX);
|
||||
TextureArrayBufferData.put(tStartY+tHeight);
|
||||
|
||||
TextureArrayBufferData.put(tStartX);
|
||||
TextureArrayBufferData.put(tStartY);
|
||||
|
||||
TextureArrayBufferData.put(tStartX+tWidth);
|
||||
TextureArrayBufferData.put(tStartY);
|
||||
|
||||
TextureArrayBufferData.put(tStartX);
|
||||
TextureArrayBufferData.put(tStartY+tHeight);
|
||||
|
||||
TextureArrayBufferData.put(tStartX+tWidth);
|
||||
TextureArrayBufferData.put(tStartY);
|
||||
|
||||
TextureArrayBufferData.put(tStartX+tWidth);
|
||||
TextureArrayBufferData.put(tStartY+tHeight);
|
||||
TextureArrayBufferData.flip();
|
||||
|
||||
|
||||
//buffer vertices
|
||||
m.buffer_vertices(VertexArrayBufferData, 2);
|
||||
//buffer normals
|
||||
m.buffer_normals(VertexArrayBufferData, 2);
|
||||
//buffer faces
|
||||
m.buffer_faces(faceArrayBufferData);
|
||||
//buffer texture coords
|
||||
m.buffer_texture_coords(TextureArrayBufferData, 2);
|
||||
|
||||
|
||||
m.shader = ShaderProgram.loadSpecificShader("/Shaders/font/basicbitmap/basicbitmap.vs", "/Shaders/font/basicbitmap/basicbitmap.fs");
|
||||
|
||||
|
||||
glBindVertexArray(0);
|
||||
m.parent = rVal;
|
||||
|
||||
Material uiMat = new Material();
|
||||
Texture uiTex = new Texture("Textures/Fonts/OpenSansBitmap.bmp");
|
||||
uiMat.set_diffuse(uiTex);
|
||||
uiMat.set_specular(uiTex);
|
||||
m.set_material(uiMat);
|
||||
|
||||
rVal.meshes.add(m);
|
||||
|
||||
return rVal;
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,6 +7,7 @@ package electrosphere.renderer;
|
||||
|
||||
import electrosphere.entity.CameraEntityUtils;
|
||||
import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.EntityDataStrings;
|
||||
import electrosphere.entity.EntityUtils;
|
||||
import java.nio.FloatBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
@ -367,7 +368,7 @@ public class RenderUtils {
|
||||
VertexArrayBufferData.put(temp);
|
||||
}
|
||||
VertexArrayBufferData.flip();
|
||||
skyboxmesh.buffer_vertices(VertexArrayBufferData);
|
||||
skyboxmesh.buffer_vertices(VertexArrayBufferData, 3);
|
||||
} catch (NullPointerException ex){
|
||||
ex.printStackTrace();
|
||||
}
|
||||
@ -426,7 +427,7 @@ public class RenderUtils {
|
||||
NormalArrayBufferData.put(temp);
|
||||
}
|
||||
NormalArrayBufferData.flip();
|
||||
skyboxmesh.buffer_normals(NormalArrayBufferData);
|
||||
skyboxmesh.buffer_normals(NormalArrayBufferData, 3);
|
||||
}
|
||||
} catch (NullPointerException ex){
|
||||
ex.printStackTrace();
|
||||
@ -619,6 +620,9 @@ public class RenderUtils {
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// glBindVertexArray(0);
|
||||
|
||||
//bind default FBO
|
||||
@ -628,6 +632,9 @@ public class RenderUtils {
|
||||
glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
|
||||
|
||||
|
||||
//
|
||||
//unbind texture channels
|
||||
//
|
||||
@ -647,12 +654,26 @@ public class RenderUtils {
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
|
||||
|
||||
|
||||
//render full screen quad
|
||||
glUseProgram(screenTextureShaders.shaderProgram);
|
||||
glBindVertexArray(screenTextureVAO);
|
||||
glBindTexture(GL_TEXTURE_2D, screenFramebuffer.getTexture());
|
||||
// glBindTexture(GL_TEXTURE_2D, lightDepthBuffer.getTexture());
|
||||
glDrawArrays(GL_TRIANGLES, 0, 6);
|
||||
glBindVertexArray(0);
|
||||
|
||||
|
||||
for(Entity currentEntity : Globals.entityManager.getUIElements()){
|
||||
Actor uiActor = EntityUtils.getEntityActor(currentEntity);
|
||||
if(currentEntity.getDataKeys().contains(EntityDataStrings.DATA_STRING_UI_ELEMENT_FONT)){
|
||||
modelTransformMatrix.identity();
|
||||
modelTransformMatrix.translate(EntityUtils.getEntityPosition(currentEntity));
|
||||
System.out.println(modelTransformMatrix);
|
||||
uiActor.applyModelMatrix(modelTransformMatrix);
|
||||
}
|
||||
uiActor.drawUI();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
34
src/main/java/electrosphere/renderer/ui/font/FontUtils.java
Normal file
34
src/main/java/electrosphere/renderer/ui/font/FontUtils.java
Normal file
@ -0,0 +1,34 @@
|
||||
package electrosphere.renderer.ui.font;
|
||||
|
||||
import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.EntityDataStrings;
|
||||
import electrosphere.entity.EntityUtils;
|
||||
import electrosphere.main.Globals;
|
||||
import electrosphere.renderer.ActorUtils;
|
||||
import electrosphere.renderer.Model;
|
||||
import electrosphere.renderer.ModelUtils;
|
||||
import org.joml.Quaternionf;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author amaterasu
|
||||
*/
|
||||
public class FontUtils {
|
||||
|
||||
public static Entity makeFont(int row, int column){
|
||||
Model letterModel = ModelUtils.createBitmapDisplay(0.0f, 0.0f, 0.0125f, 0.05f, 0.0f + row/8.0f, 0.04f + column/8.0f, 1.0f/16.0f, 1.0f/12.0f);
|
||||
String managerAssetPath = Globals.assetManager.registerModel(letterModel);
|
||||
|
||||
Entity rVal = new Entity();
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_ACTOR, ActorUtils.createActorFromModelPath(managerAssetPath));
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_POSITION, new Vector3f(0,0,0));
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_ROTATION, new Quaternionf().rotateAxis((float)0, new Vector3f(1,0,0)));
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_SCALE, new Vector3f(1,1,1));
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_UI_ELEMENT, true);
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_UI_ELEMENT_FONT, true);
|
||||
Globals.entityManager.registerEntity(rVal);
|
||||
Globals.entityManager.registerUIEntity(rVal);
|
||||
return rVal;
|
||||
}
|
||||
}
|
||||
83
src/main/java/electrosphere/renderer/ui/font/TextBox.java
Normal file
83
src/main/java/electrosphere/renderer/ui/font/TextBox.java
Normal file
@ -0,0 +1,83 @@
|
||||
package electrosphere.renderer.ui.font;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author amaterasu
|
||||
*/
|
||||
public class TextBox {
|
||||
float ndcX;
|
||||
float ndcY;
|
||||
float ndcWidth;
|
||||
float ndcHeight;
|
||||
int rows;
|
||||
int cols;
|
||||
String text;
|
||||
|
||||
public TextBox(float ndcX, float ndcY, float ndcWidth, float ndcHeight, int rows, int cols) {
|
||||
this.ndcX = ndcX;
|
||||
this.ndcY = ndcY;
|
||||
this.ndcWidth = ndcWidth;
|
||||
this.ndcHeight = ndcHeight;
|
||||
this.rows = rows;
|
||||
this.cols = cols;
|
||||
}
|
||||
|
||||
public float getNdcX() {
|
||||
return ndcX;
|
||||
}
|
||||
|
||||
public float getNdcY() {
|
||||
return ndcY;
|
||||
}
|
||||
|
||||
public float getNdcWidth() {
|
||||
return ndcWidth;
|
||||
}
|
||||
|
||||
public float getNdcHeight() {
|
||||
return ndcHeight;
|
||||
}
|
||||
|
||||
public int getRows() {
|
||||
return rows;
|
||||
}
|
||||
|
||||
public int getCols() {
|
||||
return cols;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public void setNdcX(float ndcX) {
|
||||
this.ndcX = ndcX;
|
||||
}
|
||||
|
||||
public void setNdcY(float ndcY) {
|
||||
this.ndcY = ndcY;
|
||||
}
|
||||
|
||||
public void setNdcWidth(float ndcWidth) {
|
||||
this.ndcWidth = ndcWidth;
|
||||
}
|
||||
|
||||
public void setNdcHeight(float ndcHeight) {
|
||||
this.ndcHeight = ndcHeight;
|
||||
}
|
||||
|
||||
public void setRows(int rows) {
|
||||
this.rows = rows;
|
||||
}
|
||||
|
||||
public void setCols(int cols) {
|
||||
this.cols = cols;
|
||||
}
|
||||
|
||||
public void setText(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
package electrosphere.renderer.ui.font;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author amaterasu
|
||||
*/
|
||||
public class TextBoxManager {
|
||||
|
||||
}
|
||||
18
src/main/resources/Shaders/font/basicbitmap/basicbitmap.fs
Normal file
18
src/main/resources/Shaders/font/basicbitmap/basicbitmap.fs
Normal file
@ -0,0 +1,18 @@
|
||||
|
||||
#version 330 core
|
||||
out vec4 FragColor;
|
||||
|
||||
in vec2 TexCoords;
|
||||
|
||||
uniform sampler2D screenTexture;
|
||||
uniform vec3 color;
|
||||
|
||||
void main(){
|
||||
vec3 textColorModifier = color;
|
||||
if(color.x == 0 && color.y == 0 && color.z == 0){
|
||||
textColorModifier.x = 1;
|
||||
textColorModifier.y = 1;
|
||||
textColorModifier.z = 1;
|
||||
}
|
||||
FragColor = texture(screenTexture, TexCoords) * vec4(textColorModifier.xyz, 1.0);
|
||||
}
|
||||
13
src/main/resources/Shaders/font/basicbitmap/basicbitmap.vs
Normal file
13
src/main/resources/Shaders/font/basicbitmap/basicbitmap.vs
Normal file
@ -0,0 +1,13 @@
|
||||
|
||||
#version 330 core
|
||||
layout (location = 0) in vec2 aPos;
|
||||
layout (location = 4) in vec2 aTexCoords;
|
||||
|
||||
out vec2 TexCoords;
|
||||
|
||||
uniform mat4 model;
|
||||
|
||||
void main(){
|
||||
gl_Position = model * vec4(aPos.x, aPos.y, 0.0, 1.0);
|
||||
TexCoords = aTexCoords;
|
||||
}
|
||||
3
src/main/resources/Textures/Fonts/sources.txt
Normal file
3
src/main/resources/Textures/Fonts/sources.txt
Normal file
@ -0,0 +1,3 @@
|
||||
|
||||
"oxygen mono" from https://www.fontsquirrel.com/fonts/oxygen-mono
|
||||
rendered to bitmap with https://github.com/andryblack/fontbuilder
|
||||
Loading…
Reference in New Issue
Block a user