ShaderOptions,ui debug draw bound,start regions
This commit is contained in:
parent
c2ce7c57cf
commit
9bf2f81ae1
30
assets/Shaders/anime/compositeAnimeOutline-low.fs
Normal file
30
assets/Shaders/anime/compositeAnimeOutline-low.fs
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
#version 330 core
|
||||||
|
|
||||||
|
// shader outputs
|
||||||
|
layout (location = 0) out vec4 frag;
|
||||||
|
|
||||||
|
// color accumulation buffer
|
||||||
|
uniform sampler2D texture;
|
||||||
|
|
||||||
|
void main(){
|
||||||
|
// fragment coordination
|
||||||
|
ivec2 coords = ivec2(gl_FragCoord.xy);
|
||||||
|
|
||||||
|
// fragment color
|
||||||
|
vec4 color = texelFetch(texture, coords, 0);
|
||||||
|
|
||||||
|
float val = color.r;
|
||||||
|
|
||||||
|
// if(color.r < 0.5){z
|
||||||
|
// discard;
|
||||||
|
// }
|
||||||
|
|
||||||
|
vec4 outColor = vec4(0);
|
||||||
|
|
||||||
|
if(val == 1){
|
||||||
|
outColor = vec4(0,0,0,0.5);
|
||||||
|
// outColor.a = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
frag = outColor;
|
||||||
|
}
|
||||||
@ -1,4 +1,4 @@
|
|||||||
#version 420 core
|
#version 330 core
|
||||||
|
|
||||||
// shader inputs
|
// shader inputs
|
||||||
layout (location = 0) in vec3 position;
|
layout (location = 0) in vec3 position;
|
||||||
|
|||||||
53
assets/Shaders/oit/composite-low.fs
Normal file
53
assets/Shaders/oit/composite-low.fs
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
#version 330 core
|
||||||
|
|
||||||
|
// shader outputs
|
||||||
|
layout (location = 0) out vec4 frag;
|
||||||
|
|
||||||
|
// color accumulation buffer
|
||||||
|
uniform sampler2D accum;
|
||||||
|
|
||||||
|
// revealage threshold buffer
|
||||||
|
uniform sampler2D reveal;
|
||||||
|
|
||||||
|
// epsilon number
|
||||||
|
const float EPSILON = 0.00001f;
|
||||||
|
|
||||||
|
// caluclate floating point numbers equality accurately
|
||||||
|
bool isApproximatelyEqual(float a, float b){
|
||||||
|
return abs(a - b) <= (abs(a) < abs(b) ? abs(b) : abs(a)) * EPSILON;
|
||||||
|
}
|
||||||
|
|
||||||
|
// get the max value between three values
|
||||||
|
float max3(vec3 v) {
|
||||||
|
return max(max(v.x, v.y), v.z);
|
||||||
|
}
|
||||||
|
|
||||||
|
void main(){
|
||||||
|
// fragment coordination
|
||||||
|
ivec2 coords = ivec2(gl_FragCoord.xy);
|
||||||
|
|
||||||
|
// fragment revealage
|
||||||
|
float revealage = texelFetch(reveal, coords, 0).r;
|
||||||
|
|
||||||
|
// save the blending and color texture fetch cost if there is not a transparent fragment
|
||||||
|
if (isApproximatelyEqual(revealage, 1.0f)){
|
||||||
|
discard;
|
||||||
|
}
|
||||||
|
|
||||||
|
// fragment color
|
||||||
|
vec4 accumulation = texelFetch(accum, coords, 0);
|
||||||
|
|
||||||
|
// suppress overflow
|
||||||
|
if (isinf(max3(abs(accumulation.rgb)))){
|
||||||
|
accumulation.rgb = vec3(accumulation.a);
|
||||||
|
}
|
||||||
|
|
||||||
|
// prevent floating point precision bug
|
||||||
|
vec3 average_color = accumulation.rgb / max(accumulation.a, EPSILON);
|
||||||
|
|
||||||
|
// blend pixels
|
||||||
|
frag = vec4(accumulation);
|
||||||
|
// frag = vec4(average_color, 1.0f - revealage);
|
||||||
|
// frag = vec4(accumulation.rgb, 1.0f - revealage);
|
||||||
|
// frag = vec4(0,0,0,0);
|
||||||
|
}
|
||||||
@ -1,4 +1,4 @@
|
|||||||
#version 420 core
|
#version 330 core
|
||||||
|
|
||||||
// shader inputs
|
// shader inputs
|
||||||
layout (location = 0) in vec3 position;
|
layout (location = 0) in vec3 position;
|
||||||
|
|||||||
13
assets/Shaders/shaderoptions.json
Normal file
13
assets/Shaders/shaderoptions.json
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"shaderAlternativesMap" : {
|
||||||
|
"/Shaders/terrain/terrain.fs" : [
|
||||||
|
"/Shaders/terrain/terrain-low.fs"
|
||||||
|
],
|
||||||
|
"Shaders/anime/compositeAnimeOutline.fs" : [
|
||||||
|
"Shaders/anime/compositeAnimeOutline-low.fs"
|
||||||
|
],
|
||||||
|
"Shaders/oit/composite.fs" : [
|
||||||
|
"Shaders/oit/composite-low.fs"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
284
assets/Shaders/terrain/terrain-low.fs
Normal file
284
assets/Shaders/terrain/terrain-low.fs
Normal file
@ -0,0 +1,284 @@
|
|||||||
|
#version 330 core
|
||||||
|
|
||||||
|
#define NR_POINT_LIGHTS 10
|
||||||
|
|
||||||
|
|
||||||
|
out vec4 FragColor;
|
||||||
|
|
||||||
|
|
||||||
|
layout (std140) uniform Lights {
|
||||||
|
// this is how many because we have to align
|
||||||
|
// bytes it SHOULD in multiples of 16, this
|
||||||
|
// take it where it ACTUALLY is
|
||||||
|
//
|
||||||
|
//refer: https://learnopengl.com/Advanced-OpenGL/Advanced-GLSL
|
||||||
|
//
|
||||||
|
// base alignment aligned offset
|
||||||
|
//direct light
|
||||||
|
vec3 dLDirection; // 16 0
|
||||||
|
vec3 dLAmbient; // 16 16
|
||||||
|
vec3 dLDiffuse; // 16 32
|
||||||
|
vec3 dLSpecular; // 16 48
|
||||||
|
|
||||||
|
//point light
|
||||||
|
vec3 pLposition[NR_POINT_LIGHTS]; // 16*10 64
|
||||||
|
float pLconstant[NR_POINT_LIGHTS]; // 16*10 224
|
||||||
|
float pLlinear[NR_POINT_LIGHTS]; // 16*10 384
|
||||||
|
float pLquadratic[NR_POINT_LIGHTS]; // 16*10 544
|
||||||
|
vec3 pLambient[NR_POINT_LIGHTS]; // 16*10 704
|
||||||
|
vec3 pLdiffuse[NR_POINT_LIGHTS]; // 16*10 864
|
||||||
|
vec3 pLspecular[NR_POINT_LIGHTS]; // 16*10 1024
|
||||||
|
|
||||||
|
//for a total size of 1184
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Material {
|
||||||
|
sampler2D diffuse;
|
||||||
|
sampler2D specular;
|
||||||
|
float shininess;
|
||||||
|
};
|
||||||
|
|
||||||
|
in vec3 FragPos;
|
||||||
|
in vec3 Normal;
|
||||||
|
in vec2 TexCoord;
|
||||||
|
in vec4 FragPosLightSpace;
|
||||||
|
flat in ivec4 groundTexIndices;
|
||||||
|
uniform vec3 viewPos;
|
||||||
|
|
||||||
|
|
||||||
|
uniform Material material;
|
||||||
|
|
||||||
|
//texture stuff
|
||||||
|
// uniform sampler2D ourTexture;
|
||||||
|
uniform int hasTransparency;
|
||||||
|
// uniform sampler2D specularTexture;
|
||||||
|
|
||||||
|
//pad first three samplers
|
||||||
|
uniform sampler2D texture0;
|
||||||
|
uniform sampler2D texture1;
|
||||||
|
uniform sampler2D texture2;
|
||||||
|
//light depth map
|
||||||
|
uniform sampler2D shadowMap;
|
||||||
|
|
||||||
|
//pad fifth texture
|
||||||
|
uniform sampler2D texture4;
|
||||||
|
|
||||||
|
//textures
|
||||||
|
//
|
||||||
|
// Goal is to have a texture for the current chunk and one for each nearnby chunk
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// uniform sampler2D groundTextures1;
|
||||||
|
// uniform sampler2D groundTextures2;
|
||||||
|
// uniform sampler2D groundTextures3;
|
||||||
|
// uniform sampler2D groundTextures4;
|
||||||
|
// //fifth texture unit is for shadow map
|
||||||
|
// uniform sampler2D groundTextures5;
|
||||||
|
//this is for bindable ground textures
|
||||||
|
uniform sampler2D groundTextures[10];
|
||||||
|
|
||||||
|
// function prototypes
|
||||||
|
vec3 CalcDirLight(vec3 normal, vec3 viewDir, vec3 texColor);
|
||||||
|
vec3 CalcPointLight(int i, vec3 normal, vec3 fragPos, vec3 viewDir);
|
||||||
|
// vec3 CalcSpotLight(vec3 normal, vec3 fragPos, vec3 viewDir);
|
||||||
|
|
||||||
|
float ShadowCalculation(vec4 fragPosLightSpace, vec3 lightDir, vec3 normal);
|
||||||
|
|
||||||
|
vec3 blendedTextureColor(vec2 texPos, vec4 tex1, vec4 tex2, vec4 tex3, vec4 tex4);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
vec4 getTextureColor(int index, vec2 coord){
|
||||||
|
if(index == 0){
|
||||||
|
return texture(groundTextures[0], coord);
|
||||||
|
}
|
||||||
|
if(index == 1){
|
||||||
|
return texture(groundTextures[1], coord);
|
||||||
|
}
|
||||||
|
if(index == 2){
|
||||||
|
return texture(groundTextures[2], coord);
|
||||||
|
}
|
||||||
|
if(index == 3){
|
||||||
|
return texture(groundTextures[3], coord);
|
||||||
|
}
|
||||||
|
if(index == 4){
|
||||||
|
return texture(groundTextures[4], coord);
|
||||||
|
}
|
||||||
|
// return texture(shadowMap, coord);
|
||||||
|
// return vec3(1,1,1);
|
||||||
|
return vec4(0,0,0,1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void main(){
|
||||||
|
if(hasTransparency == 1){
|
||||||
|
if(texture(material.diffuse, TexCoord).a < 0.1){
|
||||||
|
discard;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
vec3 norm = normalize(Normal);
|
||||||
|
vec3 viewDir = normalize(viewPos - FragPos);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// sampler2DArray text = groundTextures;
|
||||||
|
// sampler2D test = groundTextures1;
|
||||||
|
|
||||||
|
vec4 texColor1 = getTextureColor(groundTexIndices.x, TexCoord);
|
||||||
|
vec4 texColor2 = getTextureColor(groundTexIndices.y, TexCoord);
|
||||||
|
vec4 texColor3 = getTextureColor(groundTexIndices.z, TexCoord);
|
||||||
|
vec4 texColor4 = getTextureColor(groundTexIndices.w, TexCoord);
|
||||||
|
// vec4 texColor1 = texture(groundTextures[groundTexIndices.x], TexCoord);
|
||||||
|
// vec4 texColor2 = texture(groundTextures[groundTexIndices.y], TexCoord);
|
||||||
|
// vec4 texColor3 = texture(groundTextures[groundTexIndices.z], TexCoord);
|
||||||
|
// vec4 texColor4 = texture(groundTextures[groundTexIndices.w], TexCoord);
|
||||||
|
// vec4 texColor1 = texture(groundTextures[0], TexCoord);
|
||||||
|
// vec4 texColor2 = texture(groundTextures[1], TexCoord);
|
||||||
|
// vec4 texColor3 = texture(groundTextures[1], TexCoord);
|
||||||
|
// vec4 texColor4 = texture(groundTextures[1], TexCoord);
|
||||||
|
vec3 finalTexColor = blendedTextureColor(TexCoord, texColor1, texColor2, texColor3, texColor4);
|
||||||
|
// vec3 finalTexColor = vec3(0,0,0);
|
||||||
|
// vec3 finalTexColor = mix(mix(texColor1,texColor2,TexCoord.x),mix(texColor3,texColor4,TexCoord.x),TexCoord.y).xyz;//blendedTextureColor(TexCoord, texColor1, texColor2, texColor3, texColor4);
|
||||||
|
// if(groundTexIndices.x != 1 || groundTexIndices.y != 0 || groundTexIndices.z != 0 || groundTexIndices.w != 0){
|
||||||
|
// finalTexColor = vec3(1,0,0);
|
||||||
|
// }
|
||||||
|
// vec3 finalTexColor = vec3(groundTexIndices.x,groundTexIndices.y,groundTexIndices.z);
|
||||||
|
// vec3 finalTexColor = vec3(1.0,0,0);
|
||||||
|
|
||||||
|
// vec4 tex2 = texture(groundTextures[int(groundTexIndices.y)], TexCoord);
|
||||||
|
// vec4 tex3 = texture2D(groundTextures[int(groundTexIndex.z * 2)], texPos);
|
||||||
|
// vec4 tex4 = texture2D(groundTextures[int(groundTexIndex.w * 2)], texPos);
|
||||||
|
|
||||||
|
//get texture color
|
||||||
|
// vec3 texColor = vec3(0,0,1);//blendedTextureColor(texPos, groundTexIndices);
|
||||||
|
|
||||||
|
|
||||||
|
vec3 result = CalcDirLight(norm, viewDir, finalTexColor);
|
||||||
|
for(int i = 0; i < NR_POINT_LIGHTS; i++){
|
||||||
|
result += CalcPointLight(i, norm, FragPos, viewDir);
|
||||||
|
}
|
||||||
|
// result += CalcSpotLight(spotLight, norm, FragPos, viewDir);
|
||||||
|
|
||||||
|
FragColor = vec4(result, 1);//texture(ourTexture, TexCoord);//vec4(result, 1.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// calculates the color when using a directional light.
|
||||||
|
vec3 CalcDirLight(vec3 normal, vec3 viewDir, vec3 texColor){
|
||||||
|
vec3 lightDir = normalize(-dLDirection);
|
||||||
|
// diffuse shading
|
||||||
|
float diff = max(dot(normal, lightDir), 0.0);
|
||||||
|
// specular shading
|
||||||
|
vec3 reflectDir = reflect(-lightDir, normal);
|
||||||
|
float spec = pow(max(dot(viewDir, reflectDir), 0.0), material.shininess);
|
||||||
|
// combine results
|
||||||
|
// vec3 texColor = texture(material.diffuse, TexCoord).rgb;
|
||||||
|
vec3 ambient = dLAmbient;
|
||||||
|
vec3 diffuse = dLDiffuse * diff;
|
||||||
|
//vec3 specular = light.specular * spec * vec3(texture(material.specular, TexCoord).rgb);
|
||||||
|
|
||||||
|
|
||||||
|
float shadow = ShadowCalculation(FragPosLightSpace, lightDir, normal);
|
||||||
|
// return shadow * vec3(1,1,1);
|
||||||
|
return ( ambient + (1.0-shadow) * diffuse ) * texColor;// + specular);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// calculates the color when using a point light.
|
||||||
|
vec3 CalcPointLight(int i, vec3 normal, vec3 fragPos, vec3 viewDir){
|
||||||
|
vec3 lightDir = normalize(pLposition[i] - fragPos);
|
||||||
|
// diffuse shading
|
||||||
|
float diff = max(dot(normal, lightDir), 0.0);
|
||||||
|
// specular shading
|
||||||
|
// vec3 reflectDir = reflect(-lightDir, normal);
|
||||||
|
// float spec = pow(max(dot(viewDir, reflectDir), 0.0), material.shininess);
|
||||||
|
// attenuation
|
||||||
|
float distance = length(pLposition[i] - fragPos);
|
||||||
|
float attenuation = 1.0 / (pLconstant[i] + pLlinear[i] * distance + pLquadratic[i] * (distance * distance));
|
||||||
|
// combine results
|
||||||
|
vec3 ambient = pLambient[i];// * vec4(texture(material.diffuse, TexCoord)).xyz;
|
||||||
|
vec3 diffuse = pLdiffuse[i] * diff;// * vec4(texture(material.diffuse, TexCoord)).xyz;
|
||||||
|
// vec3 specular = pLspecular[i] * spec;// * vec4(texture(material.specular, TexCoord)).xyz;
|
||||||
|
ambient *= attenuation;
|
||||||
|
diffuse *= attenuation;
|
||||||
|
// specular *= attenuation;
|
||||||
|
vec3 specular = vec3(0,0,0);
|
||||||
|
|
||||||
|
vec3 finalValue = (ambient + diffuse + specular);
|
||||||
|
finalValue = vec3(max(finalValue.x,0),max(finalValue.y,0),max(finalValue.z,0));
|
||||||
|
|
||||||
|
return finalValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// calculates the color when using a spot light.
|
||||||
|
// vec3 CalcSpotLight(vec3 normal, vec3 fragPos, vec3 viewDir)
|
||||||
|
// {
|
||||||
|
// vec3 lightDir = normalize(light.position - fragPos);
|
||||||
|
// // diffuse shading
|
||||||
|
// float diff = max(dot(normal, lightDir), 0.0);
|
||||||
|
// // specular shading
|
||||||
|
// vec3 reflectDir = reflect(-lightDir, normal);
|
||||||
|
// float spec = pow(max(dot(viewDir, reflectDir), 0.0), material.shininess);
|
||||||
|
// // attenuation
|
||||||
|
// float distance = length(light.position - fragPos);
|
||||||
|
// float attenuation = 1.0 / (light.constant + light.linear * distance + light.quadratic * (distance * distance));
|
||||||
|
// // spotlight intensity
|
||||||
|
// float theta = dot(lightDir, normalize(-light.direction));
|
||||||
|
// float epsilon = light.cutOff - light.outerCutOff;
|
||||||
|
// float intensity = clamp((theta - light.outerCutOff) / epsilon, 0.0, 1.0);
|
||||||
|
// // combine results
|
||||||
|
// vec3 ambient = light.ambient * vec3(texture(material.diffuse, TexCoord));
|
||||||
|
// vec3 diffuse = light.diffuse * diff * vec3(texture(material.diffuse, TexCoord));
|
||||||
|
// vec3 specular = light.specular * spec * vec3(texture(material.specular, TexCoord));
|
||||||
|
// ambient *= attenuation * intensity;
|
||||||
|
// diffuse *= attenuation * intensity;
|
||||||
|
// specular *= attenuation * intensity;
|
||||||
|
// return (ambient + diffuse + specular);
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
float ShadowCalculation(vec4 fragPosLightSpace, vec3 lightDir, vec3 normal){
|
||||||
|
|
||||||
|
// perform perspective divide
|
||||||
|
vec3 projCoords = fragPosLightSpace.xyz / fragPosLightSpace.w;
|
||||||
|
|
||||||
|
//transform to NDC
|
||||||
|
projCoords = projCoords * 0.5 + 0.5;
|
||||||
|
|
||||||
|
//get closest depth from light's POV
|
||||||
|
float closestDepth = texture(shadowMap, projCoords.xy).r;
|
||||||
|
|
||||||
|
//get depth of current fragment
|
||||||
|
float currentDepth = projCoords.z;
|
||||||
|
|
||||||
|
//calculate bias
|
||||||
|
float bias = min(0.05 * (1.0 - dot(normal, lightDir)), 0.005);
|
||||||
|
|
||||||
|
//calculate shadow value
|
||||||
|
float shadow = currentDepth - bias > closestDepth ? 1.0 : 0.0;
|
||||||
|
|
||||||
|
if(projCoords.z > 1.0){
|
||||||
|
shadow = 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// shadow = currentDepth - closestDepth;
|
||||||
|
|
||||||
|
return shadow;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
vec3 blendedTextureColor(vec2 texPos, vec4 tex1, vec4 tex2, vec4 tex3, vec4 tex4){
|
||||||
|
// int texIndex1 = int(groundTexIndex.x * 2);
|
||||||
|
// int texIndex2 = int(groundTexIndex.y * 2);
|
||||||
|
// int texIndex3 = int(groundTexIndex.z * 2);
|
||||||
|
// int texIndex4 = int(groundTexIndex.w * 2);
|
||||||
|
// vec4 tex1 = texture2D(groundTextures[int(groundTexIndex.x * 2)], texPos);
|
||||||
|
// vec4 tex2 = texture2D(groundTextures[int(groundTexIndex.y * 2)], texPos);
|
||||||
|
// vec4 tex3 = texture2D(groundTextures[int(groundTexIndex.z * 2)], texPos);
|
||||||
|
// vec4 tex4 = texture2D(groundTextures[int(groundTexIndex.w * 2)], texPos);
|
||||||
|
// float percentTex1 = (texPos.x - 1) * (texPos.y - 1);
|
||||||
|
// float percentTex2 = (texPos.x - 0) * (texPos.y - 1);
|
||||||
|
// float percentTex3 = (texPos.x - 1) * (texPos.y - 0);
|
||||||
|
// float percentTex4 = (texPos.x - 0) * (texPos.y - 0);
|
||||||
|
return mix(mix(tex1,tex2,texPos.x),mix(tex3,tex4,texPos.x),texPos.y).rgb;
|
||||||
|
}
|
||||||
18
assets/Shaders/ui/debug/windowBound.fs
Normal file
18
assets/Shaders/ui/debug/windowBound.fs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#version 330 core
|
||||||
|
|
||||||
|
//threshold on borders of window where to actually draw outline
|
||||||
|
#define threshold 0.01
|
||||||
|
|
||||||
|
out vec4 FragColor;
|
||||||
|
|
||||||
|
uniform vec3 color;
|
||||||
|
|
||||||
|
in vec2 texCoord;
|
||||||
|
|
||||||
|
void main(){
|
||||||
|
if(abs(texCoord.x) > 1.0-threshold || abs(texCoord.y) > 1.0-threshold || abs(texCoord.x) < threshold || abs(texCoord.y) < threshold){
|
||||||
|
FragColor = vec4(color,1.0);
|
||||||
|
} else {
|
||||||
|
FragColor = vec4(0.0);
|
||||||
|
}
|
||||||
|
}
|
||||||
19
assets/Shaders/ui/debug/windowBound.vs
Normal file
19
assets/Shaders/ui/debug/windowBound.vs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#version 330 core
|
||||||
|
layout (location = 0) in vec3 aPos;
|
||||||
|
layout (location = 4) in vec2 aTexCoords;
|
||||||
|
|
||||||
|
out vec2 texCoord;
|
||||||
|
|
||||||
|
uniform vec3 mPosition;
|
||||||
|
uniform vec3 mDimension;
|
||||||
|
|
||||||
|
void main(){
|
||||||
|
//0,0
|
||||||
|
vec2 finalPos = vec2(
|
||||||
|
((((aPos.x + 1)/2) * mDimension.x + mPosition.x) * 2 - 1),
|
||||||
|
((((aPos.y + 1)/2) * mDimension.y + mPosition.y) * 2 - 1)
|
||||||
|
// aPos.y * mDimension.y + (mPosition.y) + (1 - mDimension.y)
|
||||||
|
);
|
||||||
|
gl_Position = vec4(finalPos.x, finalPos.y, 0.0, 1.0);
|
||||||
|
texCoord = aTexCoords;
|
||||||
|
}
|
||||||
2
pom.xml
2
pom.xml
@ -181,7 +181,7 @@
|
|||||||
</os>
|
</os>
|
||||||
</activation>
|
</activation>
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.target>14</maven.compiler.target>
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
<lwjgl.natives>natives-macos</lwjgl.natives>
|
<lwjgl.natives>natives-macos</lwjgl.natives>
|
||||||
</properties>
|
</properties>
|
||||||
</profile>
|
</profile>
|
||||||
|
|||||||
23
src/main/java/electrosphere/game/server/region/Region.java
Normal file
23
src/main/java/electrosphere/game/server/region/Region.java
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
package electrosphere.game.server.region;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.joml.Vector3d;
|
||||||
|
|
||||||
|
import electrosphere.entity.Entity;
|
||||||
|
|
||||||
|
public interface Region {
|
||||||
|
|
||||||
|
public static enum RegionType {
|
||||||
|
REGION_TYPE_CUBOID,
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vector3d getPosition();
|
||||||
|
|
||||||
|
public void setPosition(Vector3d position);
|
||||||
|
|
||||||
|
public RegionType getRegionType();
|
||||||
|
|
||||||
|
public List<Entity> getContainedEntities();
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,49 @@
|
|||||||
|
package electrosphere.game.server.region;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.joml.Vector3d;
|
||||||
|
|
||||||
|
import electrosphere.entity.Entity;
|
||||||
|
|
||||||
|
public class RegionCuboid implements Region {
|
||||||
|
|
||||||
|
Vector3d position;
|
||||||
|
Vector3d radius;
|
||||||
|
|
||||||
|
List<Entity> containedEntities;
|
||||||
|
|
||||||
|
public RegionCuboid(Vector3d position, Vector3d radius){
|
||||||
|
this.position = position;
|
||||||
|
this.radius = radius;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Vector3d getPosition() {
|
||||||
|
return position;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setPosition(Vector3d position) {
|
||||||
|
this.position = position;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RegionType getRegionType() {
|
||||||
|
return RegionType.REGION_TYPE_CUBOID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vector3d getRadius(){
|
||||||
|
return radius;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRadius(Vector3d radius){
|
||||||
|
this.radius = radius;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Entity> getContainedEntities() {
|
||||||
|
return containedEntities;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -18,6 +18,9 @@ public class SaveUtils {
|
|||||||
|
|
||||||
public static String deriveSaveDirectoryPath(String saveName){
|
public static String deriveSaveDirectoryPath(String saveName){
|
||||||
String path = "./saves/" + saveName;
|
String path = "./saves/" + saveName;
|
||||||
|
if(path.charAt(path.length() - 1) != '/'){
|
||||||
|
path = path + "/";
|
||||||
|
}
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,22 +1,19 @@
|
|||||||
package electrosphere.game.server.terrain.generation;
|
package electrosphere.game.server.terrain.generation;
|
||||||
|
|
||||||
import electrosphere.game.server.terrain.models.TerrainModel;
|
|
||||||
import java.awt.event.KeyEvent;
|
import java.awt.event.KeyEvent;
|
||||||
import java.awt.event.KeyListener;
|
import java.awt.event.KeyListener;
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
|
|
||||||
|
import electrosphere.game.server.terrain.models.TerrainModel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author satellite
|
* @author satellite
|
||||||
@ -30,8 +27,8 @@ public class TerrainGen {
|
|||||||
static int verticalInterpolationRatio = 10;
|
static int verticalInterpolationRatio = 10;
|
||||||
//the interpolation ratio applied to the dynamically generated terrain per chunk
|
//the interpolation ratio applied to the dynamically generated terrain per chunk
|
||||||
static int dynamicInterpRatio = 1000;
|
static int dynamicInterpRatio = 1000;
|
||||||
static JFrame frame = new JFrame();
|
static JFrame frame;
|
||||||
static InterpolationDisplay graphics = new InterpolationDisplay();
|
static InterpolationDisplay graphics;
|
||||||
public static int brightness = 0;
|
public static int brightness = 0;
|
||||||
static int brightness_hold_incrementer = 0;
|
static int brightness_hold_incrementer = 0;
|
||||||
static boolean brightness_increasing = true;
|
static boolean brightness_increasing = true;
|
||||||
@ -616,6 +613,8 @@ public class TerrainGen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void create_Frame(){
|
static void create_Frame(){
|
||||||
|
frame = new JFrame();
|
||||||
|
graphics = new InterpolationDisplay();
|
||||||
frame.setBounds(25, 25, 300 + DIMENSION, 300 + DIMENSION);
|
frame.setBounds(25, 25, 300 + DIMENSION, 300 + DIMENSION);
|
||||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
frame.add(graphics);
|
frame.add(graphics);
|
||||||
|
|||||||
@ -26,7 +26,7 @@ public class LoggerInterface {
|
|||||||
loggerGameLogic = new Logger(LogLevel.WARNING);
|
loggerGameLogic = new Logger(LogLevel.WARNING);
|
||||||
loggerRenderer = new Logger(LogLevel.WARNING);
|
loggerRenderer = new Logger(LogLevel.WARNING);
|
||||||
loggerEngine = new Logger(LogLevel.WARNING);
|
loggerEngine = new Logger(LogLevel.WARNING);
|
||||||
loggerAuth = new Logger(LogLevel.WARNING);
|
loggerAuth = new Logger(LogLevel.INFO);
|
||||||
loggerDB = new Logger(LogLevel.WARNING);
|
loggerDB = new Logger(LogLevel.WARNING);
|
||||||
loggerStartup.INFO("Initialized loggers");
|
loggerStartup.INFO("Initialized loggers");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,84 +1,62 @@
|
|||||||
package electrosphere.main;
|
package electrosphere.main;
|
||||||
|
|
||||||
import electrosphere.renderer.light.PointLight;
|
import java.util.ArrayList;
|
||||||
import electrosphere.renderer.light.SpotLight;
|
import java.util.LinkedList;
|
||||||
import electrosphere.renderer.Material;
|
import java.util.List;
|
||||||
import electrosphere.renderer.Model;
|
|
||||||
import electrosphere.renderer.texture.Texture;
|
import org.joml.Matrix4f;
|
||||||
import electrosphere.renderer.texture.TextureMap;
|
import org.joml.Vector3d;
|
||||||
import com.google.gson.Gson;
|
import org.joml.Vector3f;
|
||||||
|
import org.lwjgl.glfw.GLFWErrorCallback;
|
||||||
|
|
||||||
import electrosphere.audio.AudioEngine;
|
import electrosphere.audio.AudioEngine;
|
||||||
import electrosphere.auth.AuthenticationManager;
|
import electrosphere.auth.AuthenticationManager;
|
||||||
import electrosphere.controls.CameraHandler;
|
import electrosphere.controls.CameraHandler;
|
||||||
import electrosphere.controls.ControlCallback;
|
import electrosphere.controls.ControlCallback;
|
||||||
import electrosphere.controls.ControlHandler;
|
import electrosphere.controls.ControlHandler;
|
||||||
import electrosphere.controls.MouseCallback;
|
import electrosphere.controls.MouseCallback;
|
||||||
|
import electrosphere.engine.LoadingThread;
|
||||||
|
import electrosphere.engine.assetmanager.AssetDataStrings;
|
||||||
|
import electrosphere.engine.assetmanager.AssetManager;
|
||||||
import electrosphere.entity.Entity;
|
import electrosphere.entity.Entity;
|
||||||
import electrosphere.entity.EntityManager;
|
import electrosphere.entity.EntityManager;
|
||||||
import electrosphere.entity.state.inventory.UnrelationalInventoryState;
|
|
||||||
import electrosphere.game.collision.CollisionEngine;
|
|
||||||
import electrosphere.entity.types.hitbox.HitboxManager;
|
import electrosphere.entity.types.hitbox.HitboxManager;
|
||||||
import electrosphere.game.client.cells.DrawCellManager;
|
import electrosphere.game.client.cells.DrawCellManager;
|
||||||
import electrosphere.game.client.player.ClientPlayerData;
|
import electrosphere.game.client.player.ClientPlayerData;
|
||||||
import electrosphere.game.client.terrain.manager.ClientTerrainManager;
|
import electrosphere.game.client.terrain.manager.ClientTerrainManager;
|
||||||
import electrosphere.game.client.world.ClientWorldData;
|
import electrosphere.game.client.world.ClientWorldData;
|
||||||
|
import electrosphere.game.collision.CollisionEngine;
|
||||||
import electrosphere.game.collision.CommonWorldData;
|
import electrosphere.game.collision.CommonWorldData;
|
||||||
import electrosphere.engine.LoadingThread;
|
|
||||||
import electrosphere.game.config.UserSettings;
|
import electrosphere.game.config.UserSettings;
|
||||||
import electrosphere.game.server.ai.AIManager;
|
import electrosphere.game.server.ai.AIManager;
|
||||||
import electrosphere.game.server.character.Character;
|
|
||||||
import electrosphere.game.data.creature.type.model.CreatureTypeMap;
|
|
||||||
import electrosphere.game.data.item.type.model.ItemTypeMap;
|
|
||||||
import electrosphere.game.data.structure.type.model.StructureTypeMap;
|
|
||||||
import electrosphere.game.server.db.DatabaseController;
|
|
||||||
import electrosphere.game.server.structure.virtual.Structure;
|
|
||||||
import electrosphere.game.server.structure.virtual.StructureManager;
|
|
||||||
import electrosphere.game.simulation.MacroSimulation;
|
|
||||||
import electrosphere.game.server.terrain.manager.ServerTerrainManager;
|
|
||||||
import electrosphere.game.server.town.Town;
|
|
||||||
import electrosphere.game.server.world.ServerWorldData;
|
|
||||||
import electrosphere.game.server.world.MacroData;
|
|
||||||
import electrosphere.game.server.datacell.DataCellManager;
|
import electrosphere.game.server.datacell.DataCellManager;
|
||||||
|
import electrosphere.game.server.db.DatabaseController;
|
||||||
|
import electrosphere.game.server.pathfinding.NavMeshManager;
|
||||||
|
import electrosphere.game.server.structure.virtual.StructureManager;
|
||||||
|
import electrosphere.game.server.terrain.manager.ServerTerrainManager;
|
||||||
|
import electrosphere.game.server.world.MacroData;
|
||||||
|
import electrosphere.game.server.world.ServerWorldData;
|
||||||
|
import electrosphere.game.simulation.MacroSimulation;
|
||||||
import electrosphere.game.simulation.MicroSimulation;
|
import electrosphere.game.simulation.MicroSimulation;
|
||||||
import electrosphere.logger.LoggerInterface;
|
import electrosphere.logger.LoggerInterface;
|
||||||
import electrosphere.menu.MenuGenerators;
|
|
||||||
import electrosphere.menu.WindowStrings;
|
|
||||||
import electrosphere.menu.WindowUtils;
|
import electrosphere.menu.WindowUtils;
|
||||||
import electrosphere.net.client.ClientNetworking;
|
import electrosphere.net.client.ClientNetworking;
|
||||||
import electrosphere.net.server.Server;
|
import electrosphere.net.server.Server;
|
||||||
import electrosphere.net.server.player.Player;
|
import electrosphere.net.server.player.Player;
|
||||||
import electrosphere.net.server.player.PlayerManager;
|
import electrosphere.net.server.player.PlayerManager;
|
||||||
import electrosphere.renderer.ModelUtils;
|
import electrosphere.renderer.Material;
|
||||||
import electrosphere.renderer.RenderUtils;
|
import electrosphere.renderer.RenderUtils;
|
||||||
import electrosphere.renderer.RenderingEngine;
|
import electrosphere.renderer.RenderingEngine;
|
||||||
import electrosphere.renderer.ShaderProgram;
|
import electrosphere.renderer.ShaderProgram;
|
||||||
import electrosphere.engine.assetmanager.AssetDataStrings;
|
import electrosphere.renderer.light.PointLight;
|
||||||
import electrosphere.engine.assetmanager.AssetManager;
|
import electrosphere.renderer.light.SpotLight;
|
||||||
import electrosphere.game.server.pathfinding.NavMeshManager;
|
import electrosphere.renderer.shader.ShaderOptionMap;
|
||||||
|
import electrosphere.renderer.texture.TextureMap;
|
||||||
import electrosphere.renderer.ui.ElementManager;
|
import electrosphere.renderer.ui.ElementManager;
|
||||||
import electrosphere.renderer.ui.WidgetUtils;
|
|
||||||
import electrosphere.renderer.ui.Window;
|
|
||||||
import electrosphere.renderer.ui.elements.ImagePanel;
|
import electrosphere.renderer.ui.elements.ImagePanel;
|
||||||
import electrosphere.renderer.ui.elements.Label;
|
|
||||||
import electrosphere.renderer.ui.font.FontUtils;
|
import electrosphere.renderer.ui.font.FontUtils;
|
||||||
import electrosphere.renderer.ui.font.RawFontMap;
|
import electrosphere.renderer.ui.font.RawFontMap;
|
||||||
import electrosphere.util.FileUtils;
|
import electrosphere.util.FileUtils;
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
import org.joml.Matrix4f;
|
|
||||||
import org.joml.Vector3d;
|
|
||||||
import org.joml.Vector3f;
|
|
||||||
import electrosphere.util.ModelLoader;
|
|
||||||
import electrosphere.util.Utilities;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
|
||||||
import org.lwjgl.glfw.GLFWErrorCallback;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -240,6 +218,8 @@ public class Globals {
|
|||||||
|
|
||||||
public static String particleBillboardModel;
|
public static String particleBillboardModel;
|
||||||
|
|
||||||
|
public static ShaderOptionMap shaderOptionMap;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -345,6 +325,9 @@ public class Globals {
|
|||||||
LoggerInterface.loggerStartup.INFO("Initialize global variables");
|
LoggerInterface.loggerStartup.INFO("Initialize global variables");
|
||||||
//load in default texture map
|
//load in default texture map
|
||||||
textureMapDefault = FileUtils.loadObjectFromAssetPath("Textures/default_texture_map.json", TextureMap.class);
|
textureMapDefault = FileUtils.loadObjectFromAssetPath("Textures/default_texture_map.json", TextureMap.class);
|
||||||
|
//load in shader options map
|
||||||
|
shaderOptionMap = FileUtils.loadObjectFromAssetPath("Shaders/shaderoptions.json", ShaderOptionMap.class);
|
||||||
|
shaderOptionMap.debug();
|
||||||
//create entity manager
|
//create entity manager
|
||||||
entityManager = new EntityManager();
|
entityManager = new EntityManager();
|
||||||
//temporary hold for skybox colors
|
//temporary hold for skybox colors
|
||||||
@ -437,6 +420,8 @@ public class Globals {
|
|||||||
// //in game ui stuff
|
// //in game ui stuff
|
||||||
// elementManager.registerWindow(WindowStrings.WINDOW_MENU_MAIN,WidgetUtils.createInGameMainMenuButton());
|
// elementManager.registerWindow(WindowStrings.WINDOW_MENU_MAIN,WidgetUtils.createInGameMainMenuButton());
|
||||||
|
|
||||||
|
Globals.assetManager.addShaderToQueue("Shaders/ui/debug/windowBound.vs", "Shaders/ui/debug/windowBound.fs");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//as these assets are required for the renderer to work, we go ahead and
|
//as these assets are required for the renderer to work, we go ahead and
|
||||||
|
|||||||
@ -1,12 +1,81 @@
|
|||||||
package electrosphere.renderer;
|
package electrosphere.renderer;
|
||||||
|
|
||||||
|
import static electrosphere.renderer.RenderUtils.createScreenTextureVAO;
|
||||||
|
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_OPENGL_CORE_PROFILE;
|
||||||
|
import static org.lwjgl.glfw.GLFW.GLFW_OPENGL_PROFILE;
|
||||||
|
import static org.lwjgl.glfw.GLFW.glfwCreateWindow;
|
||||||
|
import static org.lwjgl.glfw.GLFW.glfwGetPrimaryMonitor;
|
||||||
|
import static org.lwjgl.glfw.GLFW.glfwInit;
|
||||||
|
import static org.lwjgl.glfw.GLFW.glfwMakeContextCurrent;
|
||||||
|
import static org.lwjgl.glfw.GLFW.glfwMaximizeWindow;
|
||||||
|
import static org.lwjgl.glfw.GLFW.glfwPollEvents;
|
||||||
|
import static org.lwjgl.glfw.GLFW.glfwSwapBuffers;
|
||||||
|
import static org.lwjgl.glfw.GLFW.glfwTerminate;
|
||||||
|
import static org.lwjgl.glfw.GLFW.glfwWindowHint;
|
||||||
|
import static org.lwjgl.opengl.GL11.GL_ALWAYS;
|
||||||
|
import static org.lwjgl.opengl.GL11.GL_BLEND;
|
||||||
|
import static org.lwjgl.opengl.GL11.GL_COLOR;
|
||||||
|
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.GL_DEPTH_TEST;
|
||||||
|
import static org.lwjgl.opengl.GL11.GL_LESS;
|
||||||
|
import static org.lwjgl.opengl.GL11.GL_ONE;
|
||||||
|
import static org.lwjgl.opengl.GL11.GL_ONE_MINUS_SRC_ALPHA;
|
||||||
|
import static org.lwjgl.opengl.GL11.GL_ONE_MINUS_SRC_COLOR;
|
||||||
|
import static org.lwjgl.opengl.GL11.GL_SRC_ALPHA;
|
||||||
|
import static org.lwjgl.opengl.GL11.GL_TEXTURE_2D;
|
||||||
|
import static org.lwjgl.opengl.GL11.GL_TRIANGLES;
|
||||||
|
import static org.lwjgl.opengl.GL11.GL_ZERO;
|
||||||
|
import static org.lwjgl.opengl.GL11.glBindTexture;
|
||||||
|
import static org.lwjgl.opengl.GL11.glBlendFunc;
|
||||||
|
import static org.lwjgl.opengl.GL11.glClear;
|
||||||
|
import static org.lwjgl.opengl.GL11.glClearColor;
|
||||||
|
import static org.lwjgl.opengl.GL11.glDepthFunc;
|
||||||
|
import static org.lwjgl.opengl.GL11.glDepthMask;
|
||||||
|
import static org.lwjgl.opengl.GL11.glDisable;
|
||||||
|
import static org.lwjgl.opengl.GL11.glDrawArrays;
|
||||||
|
import static org.lwjgl.opengl.GL11.glEnable;
|
||||||
|
import static org.lwjgl.opengl.GL11.glViewport;
|
||||||
|
import static org.lwjgl.opengl.GL13.GL_TEXTURE0;
|
||||||
|
import static org.lwjgl.opengl.GL13.GL_TEXTURE1;
|
||||||
|
import static org.lwjgl.opengl.GL13.GL_TEXTURE2;
|
||||||
|
import static org.lwjgl.opengl.GL13.GL_TEXTURE3;
|
||||||
|
import static org.lwjgl.opengl.GL13.glActiveTexture;
|
||||||
|
import static org.lwjgl.opengl.GL14.GL_FUNC_ADD;
|
||||||
|
import static org.lwjgl.opengl.GL14.glBlendEquation;
|
||||||
|
import static org.lwjgl.opengl.GL20.glGetUniformLocation;
|
||||||
|
import static org.lwjgl.opengl.GL20.glUniform1f;
|
||||||
|
import static org.lwjgl.opengl.GL20.glUniformMatrix4fv;
|
||||||
|
import static org.lwjgl.opengl.GL20.glUseProgram;
|
||||||
|
import static org.lwjgl.opengl.GL30.GL_FRAMEBUFFER;
|
||||||
|
import static org.lwjgl.opengl.GL30.GL_RENDERBUFFER;
|
||||||
|
import static org.lwjgl.opengl.GL30.glBindFramebuffer;
|
||||||
|
import static org.lwjgl.opengl.GL30.glBindRenderbuffer;
|
||||||
|
import static org.lwjgl.opengl.GL30.glBindVertexArray;
|
||||||
|
import static org.lwjgl.opengl.GL30.glClearBufferfv;
|
||||||
|
import static org.lwjgl.opengl.GL40.glBlendFunci;
|
||||||
|
import static org.lwjgl.system.MemoryUtil.NULL;
|
||||||
|
|
||||||
|
import java.nio.IntBuffer;
|
||||||
|
|
||||||
|
import org.joml.Matrix4f;
|
||||||
|
import org.joml.Quaternionf;
|
||||||
|
import org.joml.Vector3d;
|
||||||
|
import org.joml.Vector3f;
|
||||||
|
import org.lwjgl.BufferUtils;
|
||||||
|
import org.lwjgl.glfw.GLFW;
|
||||||
|
import org.lwjgl.opengl.GL;
|
||||||
|
import org.lwjgl.opengl.GL15;
|
||||||
|
import org.lwjgl.opengl.GL20;
|
||||||
|
|
||||||
import electrosphere.controls.ControlCallback;
|
import electrosphere.controls.ControlCallback;
|
||||||
import electrosphere.controls.MouseCallback;
|
import electrosphere.controls.MouseCallback;
|
||||||
import electrosphere.entity.Entity;
|
import electrosphere.entity.Entity;
|
||||||
import electrosphere.entity.EntityDataStrings;
|
import electrosphere.entity.EntityDataStrings;
|
||||||
import electrosphere.entity.EntityUtils;
|
import electrosphere.entity.EntityUtils;
|
||||||
import electrosphere.entity.types.camera.CameraEntityUtils;
|
import electrosphere.entity.types.camera.CameraEntityUtils;
|
||||||
import electrosphere.entity.types.creature.CreatureUtils;
|
|
||||||
import electrosphere.entity.types.hitbox.HitboxData;
|
import electrosphere.entity.types.hitbox.HitboxData;
|
||||||
import electrosphere.entity.types.hitbox.HitboxUtils;
|
import electrosphere.entity.types.hitbox.HitboxUtils;
|
||||||
import electrosphere.game.data.creature.type.CollidableTemplate;
|
import electrosphere.game.data.creature.type.CollidableTemplate;
|
||||||
@ -15,8 +84,6 @@ import electrosphere.game.server.pathfinding.navmesh.NavMesh;
|
|||||||
import electrosphere.game.server.pathfinding.navmesh.NavShape;
|
import electrosphere.game.server.pathfinding.navmesh.NavShape;
|
||||||
import electrosphere.logger.LoggerInterface;
|
import electrosphere.logger.LoggerInterface;
|
||||||
import electrosphere.main.Globals;
|
import electrosphere.main.Globals;
|
||||||
import static electrosphere.renderer.RenderUtils.createScreenTextureVAO;
|
|
||||||
|
|
||||||
import electrosphere.renderer.actor.Actor;
|
import electrosphere.renderer.actor.Actor;
|
||||||
import electrosphere.renderer.debug.DebugRendering;
|
import electrosphere.renderer.debug.DebugRendering;
|
||||||
import electrosphere.renderer.framebuffer.Framebuffer;
|
import electrosphere.renderer.framebuffer.Framebuffer;
|
||||||
@ -27,103 +94,6 @@ import electrosphere.renderer.texture.Texture;
|
|||||||
import electrosphere.renderer.ui.DrawableElement;
|
import electrosphere.renderer.ui.DrawableElement;
|
||||||
import electrosphere.renderer.ui.Element;
|
import electrosphere.renderer.ui.Element;
|
||||||
|
|
||||||
import java.nio.FloatBuffer;
|
|
||||||
import java.nio.IntBuffer;
|
|
||||||
import java.util.ListIterator;
|
|
||||||
|
|
||||||
import org.joml.Matrix4f;
|
|
||||||
import org.joml.Quaternionf;
|
|
||||||
import org.joml.Vector3d;
|
|
||||||
import org.joml.Vector3f;
|
|
||||||
import org.lwjgl.BufferUtils;
|
|
||||||
import org.lwjgl.glfw.GLFW;
|
|
||||||
import org.lwjgl.glfw.GLFWKeyCallback;
|
|
||||||
|
|
||||||
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_CURSOR;
|
|
||||||
import static org.lwjgl.glfw.GLFW.GLFW_CURSOR_DISABLED;
|
|
||||||
import static org.lwjgl.glfw.GLFW.GLFW_OPENGL_CORE_PROFILE;
|
|
||||||
import static org.lwjgl.glfw.GLFW.GLFW_OPENGL_PROFILE;
|
|
||||||
import static org.lwjgl.glfw.GLFW.glfwCreateWindow;
|
|
||||||
import static org.lwjgl.glfw.GLFW.glfwInit;
|
|
||||||
import static org.lwjgl.glfw.GLFW.glfwMakeContextCurrent;
|
|
||||||
import static org.lwjgl.glfw.GLFW.glfwMaximizeWindow;
|
|
||||||
import static org.lwjgl.glfw.GLFW.glfwPollEvents;
|
|
||||||
import static org.lwjgl.glfw.GLFW.glfwSetInputMode;
|
|
||||||
import static org.lwjgl.glfw.GLFW.glfwSwapBuffers;
|
|
||||||
import static org.lwjgl.glfw.GLFW.glfwTerminate;
|
|
||||||
import static org.lwjgl.glfw.GLFW.glfwWindowHint;
|
|
||||||
import static org.lwjgl.glfw.GLFW.glfwGetPrimaryMonitor;
|
|
||||||
import org.lwjgl.glfw.GLFWWindowSizeCallbackI;
|
|
||||||
import org.lwjgl.opengl.GL;
|
|
||||||
import org.lwjgl.opengl.GL11;
|
|
||||||
import org.lwjgl.opengl.GL15;
|
|
||||||
import org.lwjgl.opengl.GL20;
|
|
||||||
|
|
||||||
import static org.lwjgl.opengl.GL11.GL_BLEND;
|
|
||||||
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.GL_DEPTH_TEST;
|
|
||||||
import static org.lwjgl.opengl.GL11.GL_EXP2;
|
|
||||||
import static org.lwjgl.opengl.GL11.GL_FOG;
|
|
||||||
import static org.lwjgl.opengl.GL11.GL_FOG_COLOR;
|
|
||||||
import static org.lwjgl.opengl.GL11.GL_FOG_DENSITY;
|
|
||||||
import static org.lwjgl.opengl.GL11.GL_FOG_END;
|
|
||||||
import static org.lwjgl.opengl.GL11.GL_FOG_MODE;
|
|
||||||
import static org.lwjgl.opengl.GL11.GL_FOG_START;
|
|
||||||
import static org.lwjgl.opengl.GL11.GL_LINEAR;
|
|
||||||
import static org.lwjgl.opengl.GL11.GL_NEAREST;
|
|
||||||
import static org.lwjgl.opengl.GL11.GL_LESS;
|
|
||||||
import static org.lwjgl.opengl.GL11.GL_LEQUAL;
|
|
||||||
import static org.lwjgl.opengl.GL11.GL_EQUAL;
|
|
||||||
import static org.lwjgl.opengl.GL11.GL_GREATER;
|
|
||||||
import static org.lwjgl.opengl.GL11.GL_ONE_MINUS_SRC_ALPHA;
|
|
||||||
import static org.lwjgl.opengl.GL11.GL_SRC_ALPHA;
|
|
||||||
import static org.lwjgl.opengl.GL11.GL_TEXTURE_2D;
|
|
||||||
import static org.lwjgl.opengl.GL11.GL_TRIANGLES;
|
|
||||||
import static org.lwjgl.opengl.GL11.GL_FALSE;
|
|
||||||
import static org.lwjgl.opengl.GL11.GL_ONE;
|
|
||||||
import static org.lwjgl.opengl.GL11.GL_ZERO;
|
|
||||||
import static org.lwjgl.opengl.GL11.GL_COLOR;
|
|
||||||
import static org.lwjgl.opengl.GL11.GL_ONE_MINUS_SRC_COLOR;
|
|
||||||
import static org.lwjgl.opengl.GL11.GL_ALWAYS;
|
|
||||||
import static org.lwjgl.opengl.GL11.GL_FRONT;
|
|
||||||
import static org.lwjgl.opengl.GL11.glDepthFunc;
|
|
||||||
import static org.lwjgl.opengl.GL11.glDepthMask;
|
|
||||||
import static org.lwjgl.opengl.GL11.glBindTexture;
|
|
||||||
import static org.lwjgl.opengl.GL11.glBlendFunc;
|
|
||||||
import static org.lwjgl.opengl.GL11.glClear;
|
|
||||||
import static org.lwjgl.opengl.GL11.glClearColor;
|
|
||||||
import static org.lwjgl.opengl.GL11.glDisable;
|
|
||||||
import static org.lwjgl.opengl.GL11.glDrawArrays;
|
|
||||||
import static org.lwjgl.opengl.GL11.glEnable;
|
|
||||||
import static org.lwjgl.opengl.GL11.glFogf;
|
|
||||||
import static org.lwjgl.opengl.GL11.glViewport;
|
|
||||||
import static org.lwjgl.opengl.GL11.glCullFace;
|
|
||||||
import static org.lwjgl.opengl.GL13.GL_TEXTURE0;
|
|
||||||
import static org.lwjgl.opengl.GL13.GL_TEXTURE1;
|
|
||||||
import static org.lwjgl.opengl.GL13.GL_TEXTURE2;
|
|
||||||
import static org.lwjgl.opengl.GL13.GL_TEXTURE3;
|
|
||||||
import static org.lwjgl.opengl.GL13.glActiveTexture;
|
|
||||||
import static org.lwjgl.opengl.GL14.GL_FUNC_ADD;
|
|
||||||
import static org.lwjgl.opengl.GL20.glGetUniformLocation;
|
|
||||||
import static org.lwjgl.opengl.GL20.glUniformMatrix4fv;
|
|
||||||
import static org.lwjgl.opengl.GL20.glUseProgram;
|
|
||||||
import static org.lwjgl.opengl.GL20.glUniform1f;
|
|
||||||
import static org.lwjgl.opengl.GL30.GL_FRAMEBUFFER;
|
|
||||||
import static org.lwjgl.opengl.GL30.GL_RENDERBUFFER;
|
|
||||||
import static org.lwjgl.opengl.GL30.GL_COLOR_ATTACHMENT0;
|
|
||||||
import static org.lwjgl.opengl.GL30.GL_COLOR_ATTACHMENT1;
|
|
||||||
import static org.lwjgl.opengl.GL30.glBindFramebuffer;
|
|
||||||
import static org.lwjgl.opengl.GL30.glBindRenderbuffer;
|
|
||||||
import static org.lwjgl.opengl.GL30.glBindVertexArray;
|
|
||||||
import static org.lwjgl.opengl.GL30.glBlitFramebuffer;
|
|
||||||
import static org.lwjgl.opengl.GL30.glClearBufferfv;
|
|
||||||
import static org.lwjgl.opengl.GL40.glBlendFunci;
|
|
||||||
import static org.lwjgl.opengl.GL40.glBlendEquation;
|
|
||||||
import static org.lwjgl.system.MemoryUtil.NULL;
|
|
||||||
|
|
||||||
public class RenderingEngine {
|
public class RenderingEngine {
|
||||||
|
|
||||||
|
|
||||||
@ -193,6 +163,7 @@ public class RenderingEngine {
|
|||||||
*/
|
*/
|
||||||
static ShaderProgram compositeAnimeOutline;
|
static ShaderProgram compositeAnimeOutline;
|
||||||
|
|
||||||
|
|
||||||
// public static boolean renderHitboxes = false;
|
// public static boolean renderHitboxes = false;
|
||||||
// public static boolean renderPhysics = false;
|
// public static boolean renderPhysics = false;
|
||||||
|
|
||||||
@ -522,7 +493,7 @@ public class RenderingEngine {
|
|||||||
Render boundaries of ui elements
|
Render boundaries of ui elements
|
||||||
*/
|
*/
|
||||||
if(Globals.RENDER_FLAG_RENDER_UI_BOUNDS){
|
if(Globals.RENDER_FLAG_RENDER_UI_BOUNDS){
|
||||||
DebugRendering.drawUIBounds();
|
DebugRendering.drawUIBoundsPolygon();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,22 +1,37 @@
|
|||||||
package electrosphere.renderer;
|
package electrosphere.renderer;
|
||||||
|
|
||||||
import electrosphere.logger.LoggerInterface;
|
import static org.lwjgl.opengl.GL11.GL_TRUE;
|
||||||
import electrosphere.main.Globals;
|
import static org.lwjgl.opengl.GL20.GL_COMPILE_STATUS;
|
||||||
import electrosphere.main.Main;
|
import static org.lwjgl.opengl.GL20.GL_FRAGMENT_SHADER;
|
||||||
import electrosphere.util.FileUtils;
|
import static org.lwjgl.opengl.GL20.GL_LINK_STATUS;
|
||||||
|
import static org.lwjgl.opengl.GL20.GL_VERTEX_SHADER;
|
||||||
|
import static org.lwjgl.opengl.GL20.glAttachShader;
|
||||||
|
import static org.lwjgl.opengl.GL20.glCompileShader;
|
||||||
|
import static org.lwjgl.opengl.GL20.glCreateProgram;
|
||||||
|
import static org.lwjgl.opengl.GL20.glCreateShader;
|
||||||
|
import static org.lwjgl.opengl.GL20.glDeleteShader;
|
||||||
|
import static org.lwjgl.opengl.GL20.glGetProgramInfoLog;
|
||||||
|
import static org.lwjgl.opengl.GL20.glGetProgrami;
|
||||||
|
import static org.lwjgl.opengl.GL20.glGetShaderi;
|
||||||
|
import static org.lwjgl.opengl.GL20.glGetUniformLocation;
|
||||||
|
import static org.lwjgl.opengl.GL20.glLinkProgram;
|
||||||
|
import static org.lwjgl.opengl.GL20.glShaderSource;
|
||||||
|
import static org.lwjgl.opengl.GL32.GL_GEOMETRY_SHADER;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.util.ArrayList;
|
import java.util.LinkedList;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
import javax.management.RuntimeErrorException;
|
||||||
|
|
||||||
import org.lwjgl.opengl.GL20;
|
import org.lwjgl.opengl.GL20;
|
||||||
import org.lwjgl.opengl.GL32;
|
|
||||||
import static org.lwjgl.opengl.GL20.*;
|
import electrosphere.logger.LoggerInterface;
|
||||||
import static org.lwjgl.opengl.GL32.*;
|
import electrosphere.main.Globals;
|
||||||
|
import electrosphere.util.FileUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -312,10 +327,66 @@ public class ShaderProgram {
|
|||||||
int success;
|
int success;
|
||||||
success = glGetShaderi(rVal.vertexShader, GL_COMPILE_STATUS);
|
success = glGetShaderi(rVal.vertexShader, GL_COMPILE_STATUS);
|
||||||
if (success != GL_TRUE) {
|
if (success != GL_TRUE) {
|
||||||
LoggerInterface.loggerRenderer.WARNING("Vertex Shader failed to compile!");
|
List<Object> errorLines = new LinkedList<Object>();
|
||||||
LoggerInterface.loggerRenderer.WARNING("Source is: ");
|
LoggerInterface.loggerRenderer.WARNING("Failed to load " + vertexPath + " ... attempting alternatives");
|
||||||
LoggerInterface.loggerRenderer.WARNING(GL20.glGetShaderSource(rVal.vertexShader));
|
//report failed to load shader
|
||||||
LoggerInterface.loggerRenderer.ERROR("Runtime Exception", new RuntimeException(GL20.glGetShaderInfoLog(rVal.vertexShader)));
|
errorLines.add("Vertex Shader failed to compile!");
|
||||||
|
errorLines.add("Source File is: " + vertexPath);
|
||||||
|
errorLines.add("Source is: ");
|
||||||
|
errorLines.add(GL20.glGetShaderSource(rVal.vertexShader));
|
||||||
|
errorLines.add(new RuntimeException(GL20.glGetShaderInfoLog(rVal.vertexShader)));
|
||||||
|
// LoggerInterface.loggerRenderer.WARNING("Vertex Shader failed to compile!");
|
||||||
|
// LoggerInterface.loggerRenderer.WARNING("Source File is: " + vertexPath);
|
||||||
|
// LoggerInterface.loggerRenderer.WARNING("Source is: ");
|
||||||
|
// LoggerInterface.loggerRenderer.WARNING(GL20.glGetShaderSource(rVal.vertexShader));
|
||||||
|
// LoggerInterface.loggerRenderer.ERROR("Runtime Exception", new RuntimeException(GL20.glGetShaderInfoLog(rVal.vertexShader)));
|
||||||
|
//attempt loading alternative shaders
|
||||||
|
List<String> availableAlternatives = Globals.shaderOptionMap.getAlternativesForFile(vertexPath);
|
||||||
|
int alternativesAttempted = 0;
|
||||||
|
if(availableAlternatives != null){
|
||||||
|
for(String alternative : availableAlternatives){
|
||||||
|
alternativesAttempted++;
|
||||||
|
//load file
|
||||||
|
try {
|
||||||
|
vertexShaderSource = FileUtils.getAssetFileAsString(alternative);
|
||||||
|
} catch (IOException e) {
|
||||||
|
LoggerInterface.loggerEngine.ERROR("Failed to load shader alternative " + alternative, e);
|
||||||
|
}
|
||||||
|
//Creates a new shader object and assigns its 'pointer' to the integer "vertexShader"
|
||||||
|
rVal.vertexShader = glCreateShader(GL_VERTEX_SHADER);
|
||||||
|
//This alerts openGL to the presence of a vertex shader and points the shader at its source
|
||||||
|
glShaderSource(rVal.vertexShader, vertexShaderSource);
|
||||||
|
//Compiles the source for the vertex shader object
|
||||||
|
glCompileShader(rVal.vertexShader);
|
||||||
|
//The following tests if the vertex shader compiles successfully
|
||||||
|
success = glGetShaderi(rVal.vertexShader, GL_COMPILE_STATUS);
|
||||||
|
if (success == GL_TRUE) {
|
||||||
|
LoggerInterface.loggerRenderer.WARNING("Successfully loaded alternative shader " + alternative);
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
errorLines.add("Vertex Shader failed to compile!");
|
||||||
|
errorLines.add("Source File is: " + vertexPath);
|
||||||
|
errorLines.add("Source is: ");
|
||||||
|
errorLines.add(GL20.glGetShaderSource(rVal.vertexShader));
|
||||||
|
errorLines.add(new RuntimeException(GL20.glGetShaderInfoLog(rVal.vertexShader)));
|
||||||
|
// LoggerInterface.loggerRenderer.WARNING("Vertex Shader failed to compile!");
|
||||||
|
// LoggerInterface.loggerRenderer.WARNING("Source File is: " + vertexPath);
|
||||||
|
// LoggerInterface.loggerRenderer.WARNING("Source is: ");
|
||||||
|
// LoggerInterface.loggerRenderer.WARNING(GL20.glGetShaderSource(rVal.vertexShader));
|
||||||
|
// LoggerInterface.loggerRenderer.ERROR("Runtime Exception", new RuntimeException(GL20.glGetShaderInfoLog(rVal.vertexShader)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(success != GL_TRUE){
|
||||||
|
for(Object object : errorLines){
|
||||||
|
if(object instanceof String){
|
||||||
|
LoggerInterface.loggerRenderer.WARNING((String)object);
|
||||||
|
} else if(object instanceof RuntimeErrorException){
|
||||||
|
LoggerInterface.loggerRenderer.ERROR("Runtime Exception", (RuntimeErrorException)object);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
LoggerInterface.loggerRenderer.WARNING("Attempted " + alternativesAttempted + " alternative shaders");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//Creates and opengl object for a fragment shader and assigns its 'pointer' to the integer fragmentShader
|
//Creates and opengl object for a fragment shader and assigns its 'pointer' to the integer fragmentShader
|
||||||
rVal.fragmentShader = glCreateShader(GL_FRAGMENT_SHADER);
|
rVal.fragmentShader = glCreateShader(GL_FRAGMENT_SHADER);
|
||||||
@ -326,10 +397,66 @@ public class ShaderProgram {
|
|||||||
//This tests for the success of the compile attempt
|
//This tests for the success of the compile attempt
|
||||||
success = glGetShaderi(rVal.fragmentShader, GL_COMPILE_STATUS);
|
success = glGetShaderi(rVal.fragmentShader, GL_COMPILE_STATUS);
|
||||||
if (success != GL_TRUE) {
|
if (success != GL_TRUE) {
|
||||||
LoggerInterface.loggerRenderer.WARNING("Fragment Shader failed to compile!");
|
List<Object> errorLines = new LinkedList<Object>();
|
||||||
LoggerInterface.loggerRenderer.WARNING("Source is: ");
|
LoggerInterface.loggerRenderer.WARNING("Failed to load " + fragmentPath + " ... attempting alternatives");
|
||||||
LoggerInterface.loggerRenderer.WARNING(GL20.glGetShaderSource(rVal.fragmentShader));
|
//report failed to load shader
|
||||||
LoggerInterface.loggerRenderer.ERROR("Runtime Exception", new RuntimeException(GL20.glGetShaderInfoLog(rVal.fragmentShader)));
|
errorLines.add("Fragment Shader failed to compile!");
|
||||||
|
errorLines.add("Source File is: " + fragmentPath);
|
||||||
|
errorLines.add("Source is: ");
|
||||||
|
errorLines.add(GL20.glGetShaderSource(rVal.fragmentShader));
|
||||||
|
errorLines.add(new RuntimeException(GL20.glGetShaderInfoLog(rVal.fragmentShader)));
|
||||||
|
// LoggerInterface.loggerRenderer.WARNING("Fragment Shader failed to compile!");
|
||||||
|
// LoggerInterface.loggerRenderer.WARNING("Source File is: " + fragmentPath);
|
||||||
|
// LoggerInterface.loggerRenderer.WARNING("Source is: ");
|
||||||
|
// LoggerInterface.loggerRenderer.WARNING(GL20.glGetShaderSource(rVal.fragmentShader));
|
||||||
|
// LoggerInterface.loggerRenderer.ERROR("Runtime Exception", new RuntimeException(GL20.glGetShaderInfoLog(rVal.fragmentShader)));
|
||||||
|
//attempt loading alternative shaders
|
||||||
|
List<String> availableAlternatives = Globals.shaderOptionMap.getAlternativesForFile(fragmentPath);
|
||||||
|
int alternativesAttempted = 0;
|
||||||
|
if(availableAlternatives != null){
|
||||||
|
for(String alternative : availableAlternatives){
|
||||||
|
alternativesAttempted++;
|
||||||
|
//load file
|
||||||
|
try {
|
||||||
|
fragmentShaderSource = FileUtils.getAssetFileAsString(alternative);
|
||||||
|
} catch (IOException e) {
|
||||||
|
LoggerInterface.loggerEngine.ERROR("Failed to load shader alternative " + alternative, e);
|
||||||
|
}
|
||||||
|
//Creates a new shader object and assigns its 'pointer' to the integer "vertexShader"
|
||||||
|
rVal.fragmentShader = glCreateShader(GL_FRAGMENT_SHADER);
|
||||||
|
//This alerts openGL to the presence of a vertex shader and points the shader at its source
|
||||||
|
glShaderSource(rVal.fragmentShader, fragmentShaderSource);
|
||||||
|
//Compiles the source for the vertex shader object
|
||||||
|
glCompileShader(rVal.fragmentShader);
|
||||||
|
//The following tests if the vertex shader compiles successfully
|
||||||
|
success = glGetShaderi(rVal.fragmentShader, GL_COMPILE_STATUS);
|
||||||
|
if (success == GL_TRUE) {
|
||||||
|
LoggerInterface.loggerRenderer.WARNING("Successfully loaded alternative shader " + alternative);
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
errorLines.add("Fragment Shader failed to compile!");
|
||||||
|
errorLines.add("Source File is: " + fragmentPath);
|
||||||
|
errorLines.add("Source is: ");
|
||||||
|
errorLines.add(GL20.glGetShaderSource(rVal.fragmentShader));
|
||||||
|
errorLines.add(new RuntimeException(GL20.glGetShaderInfoLog(rVal.fragmentShader)));
|
||||||
|
// LoggerInterface.loggerRenderer.WARNING("Fragment Shader failed to compile!");
|
||||||
|
// LoggerInterface.loggerRenderer.WARNING("Source File is: " + fragmentPath);
|
||||||
|
// LoggerInterface.loggerRenderer.WARNING("Source is: ");
|
||||||
|
// LoggerInterface.loggerRenderer.WARNING(GL20.glGetShaderSource(rVal.fragmentShader));
|
||||||
|
// LoggerInterface.loggerRenderer.ERROR("Runtime Exception", new RuntimeException(GL20.glGetShaderInfoLog(rVal.fragmentShader)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(success != GL_TRUE){
|
||||||
|
for(Object object : errorLines){
|
||||||
|
if(object instanceof String){
|
||||||
|
LoggerInterface.loggerRenderer.WARNING((String)object);
|
||||||
|
} else if(object instanceof RuntimeErrorException){
|
||||||
|
LoggerInterface.loggerRenderer.ERROR("Runtime Exception", (RuntimeErrorException)object);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
LoggerInterface.loggerRenderer.WARNING("Attempted " + alternativesAttempted + " alternative shaders");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//This creates a shader program opengl object and assigns its 'pointer' to the integer shaderProgram
|
//This creates a shader program opengl object and assigns its 'pointer' to the integer shaderProgram
|
||||||
rVal.shaderProgram = glCreateProgram();
|
rVal.shaderProgram = glCreateProgram();
|
||||||
|
|||||||
@ -1,110 +1,28 @@
|
|||||||
package electrosphere.renderer.debug;
|
package electrosphere.renderer.debug;
|
||||||
|
|
||||||
import electrosphere.engine.assetmanager.AssetDataStrings;
|
import static org.lwjgl.opengl.GL11.GL_DEPTH_TEST;
|
||||||
|
import static org.lwjgl.opengl.GL11.GL_FILL;
|
||||||
|
import static org.lwjgl.opengl.GL11.GL_FRONT_AND_BACK;
|
||||||
|
import static org.lwjgl.opengl.GL11.GL_LINE;
|
||||||
|
import static org.lwjgl.opengl.GL11.glDisable;
|
||||||
|
import static org.lwjgl.opengl.GL11.glPolygonMode;
|
||||||
|
|
||||||
|
import org.joml.Vector3f;
|
||||||
|
|
||||||
import electrosphere.logger.LoggerInterface;
|
import electrosphere.logger.LoggerInterface;
|
||||||
import electrosphere.main.Globals;
|
import electrosphere.main.Globals;
|
||||||
import electrosphere.renderer.Model;
|
import electrosphere.renderer.Model;
|
||||||
import electrosphere.renderer.RenderingEngine;
|
import electrosphere.renderer.RenderingEngine;
|
||||||
|
import electrosphere.renderer.ShaderProgram;
|
||||||
import electrosphere.renderer.ui.ContainerElement;
|
import electrosphere.renderer.ui.ContainerElement;
|
||||||
import electrosphere.renderer.ui.DrawableElement;
|
import electrosphere.renderer.ui.DrawableElement;
|
||||||
import electrosphere.renderer.ui.Element;
|
import electrosphere.renderer.ui.Element;
|
||||||
import electrosphere.renderer.ui.elements.ImagePanel;
|
import electrosphere.renderer.ui.elements.ImagePanel;
|
||||||
|
|
||||||
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_CURSOR;
|
|
||||||
import static org.lwjgl.glfw.GLFW.GLFW_CURSOR_DISABLED;
|
|
||||||
import static org.lwjgl.glfw.GLFW.GLFW_OPENGL_CORE_PROFILE;
|
|
||||||
import static org.lwjgl.glfw.GLFW.GLFW_OPENGL_PROFILE;
|
|
||||||
import static org.lwjgl.glfw.GLFW.glfwCreateWindow;
|
|
||||||
import static org.lwjgl.glfw.GLFW.glfwInit;
|
|
||||||
import static org.lwjgl.glfw.GLFW.glfwMakeContextCurrent;
|
|
||||||
import static org.lwjgl.glfw.GLFW.glfwMaximizeWindow;
|
|
||||||
import static org.lwjgl.glfw.GLFW.glfwPollEvents;
|
|
||||||
import static org.lwjgl.glfw.GLFW.glfwSetInputMode;
|
|
||||||
import static org.lwjgl.glfw.GLFW.glfwSwapBuffers;
|
|
||||||
import static org.lwjgl.glfw.GLFW.glfwTerminate;
|
|
||||||
import static org.lwjgl.glfw.GLFW.glfwWindowHint;
|
|
||||||
import static org.lwjgl.glfw.GLFW.glfwGetPrimaryMonitor;
|
|
||||||
import org.lwjgl.glfw.GLFWWindowSizeCallbackI;
|
|
||||||
import org.lwjgl.opengl.GL;
|
|
||||||
import org.lwjgl.opengl.GL11;
|
|
||||||
import org.lwjgl.opengl.GL15;
|
|
||||||
import org.lwjgl.opengl.GL20;
|
|
||||||
|
|
||||||
import static org.lwjgl.opengl.GL11.GL_BLEND;
|
|
||||||
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.GL_DEPTH_TEST;
|
|
||||||
import static org.lwjgl.opengl.GL11.GL_EXP2;
|
|
||||||
import static org.lwjgl.opengl.GL11.GL_FOG;
|
|
||||||
import static org.lwjgl.opengl.GL11.GL_FOG_COLOR;
|
|
||||||
import static org.lwjgl.opengl.GL11.GL_FOG_DENSITY;
|
|
||||||
import static org.lwjgl.opengl.GL11.GL_FOG_END;
|
|
||||||
import static org.lwjgl.opengl.GL11.GL_FOG_MODE;
|
|
||||||
import static org.lwjgl.opengl.GL11.GL_FOG_START;
|
|
||||||
import static org.lwjgl.opengl.GL11.GL_LINEAR;
|
|
||||||
import static org.lwjgl.opengl.GL11.GL_NEAREST;
|
|
||||||
import static org.lwjgl.opengl.GL11.GL_LESS;
|
|
||||||
import static org.lwjgl.opengl.GL11.GL_LEQUAL;
|
|
||||||
import static org.lwjgl.opengl.GL11.GL_EQUAL;
|
|
||||||
import static org.lwjgl.opengl.GL11.GL_GREATER;
|
|
||||||
import static org.lwjgl.opengl.GL11.GL_ONE_MINUS_SRC_ALPHA;
|
|
||||||
import static org.lwjgl.opengl.GL11.GL_SRC_ALPHA;
|
|
||||||
import static org.lwjgl.opengl.GL11.GL_TEXTURE_2D;
|
|
||||||
import static org.lwjgl.opengl.GL11.GL_TRIANGLES;
|
|
||||||
import static org.lwjgl.opengl.GL11.GL_FALSE;
|
|
||||||
import static org.lwjgl.opengl.GL11.GL_ONE;
|
|
||||||
import static org.lwjgl.opengl.GL11.GL_ZERO;
|
|
||||||
import static org.lwjgl.opengl.GL11.GL_COLOR;
|
|
||||||
import static org.lwjgl.opengl.GL11.GL_ONE_MINUS_SRC_COLOR;
|
|
||||||
import static org.lwjgl.opengl.GL11.GL_ALWAYS;
|
|
||||||
import static org.lwjgl.opengl.GL11.GL_FRONT;
|
|
||||||
import static org.lwjgl.opengl.GL11.GL_FRONT_AND_BACK;
|
|
||||||
import static org.lwjgl.opengl.GL11.GL_LINE;
|
|
||||||
import static org.lwjgl.opengl.GL11.GL_FILL;
|
|
||||||
import static org.lwjgl.opengl.GL11.glDepthFunc;
|
|
||||||
import static org.lwjgl.opengl.GL11.glDepthMask;
|
|
||||||
import static org.lwjgl.opengl.GL11.glBindTexture;
|
|
||||||
import static org.lwjgl.opengl.GL11.glBlendFunc;
|
|
||||||
import static org.lwjgl.opengl.GL11.glClear;
|
|
||||||
import static org.lwjgl.opengl.GL11.glClearColor;
|
|
||||||
import static org.lwjgl.opengl.GL11.glDisable;
|
|
||||||
import static org.lwjgl.opengl.GL11.glDrawArrays;
|
|
||||||
import static org.lwjgl.opengl.GL11.glEnable;
|
|
||||||
import static org.lwjgl.opengl.GL11.glFogf;
|
|
||||||
import static org.lwjgl.opengl.GL11.glViewport;
|
|
||||||
import static org.lwjgl.opengl.GL11.glCullFace;
|
|
||||||
import static org.lwjgl.opengl.GL11.glPolygonMode;
|
|
||||||
import static org.lwjgl.opengl.GL13.GL_TEXTURE0;
|
|
||||||
import static org.lwjgl.opengl.GL13.GL_TEXTURE1;
|
|
||||||
import static org.lwjgl.opengl.GL13.GL_TEXTURE2;
|
|
||||||
import static org.lwjgl.opengl.GL13.GL_TEXTURE3;
|
|
||||||
import static org.lwjgl.opengl.GL13.glActiveTexture;
|
|
||||||
import static org.lwjgl.opengl.GL14.GL_FUNC_ADD;
|
|
||||||
import static org.lwjgl.opengl.GL20.glGetUniformLocation;
|
|
||||||
import static org.lwjgl.opengl.GL20.glUniformMatrix4fv;
|
|
||||||
import static org.lwjgl.opengl.GL20.glUseProgram;
|
|
||||||
import static org.lwjgl.opengl.GL20.glUniform1f;
|
|
||||||
import static org.lwjgl.opengl.GL30.GL_FRAMEBUFFER;
|
|
||||||
import static org.lwjgl.opengl.GL30.GL_RENDERBUFFER;
|
|
||||||
import static org.lwjgl.opengl.GL30.GL_COLOR_ATTACHMENT0;
|
|
||||||
import static org.lwjgl.opengl.GL30.GL_COLOR_ATTACHMENT1;
|
|
||||||
import static org.lwjgl.opengl.GL30.glBindFramebuffer;
|
|
||||||
import static org.lwjgl.opengl.GL30.glBindRenderbuffer;
|
|
||||||
import static org.lwjgl.opengl.GL30.glBindVertexArray;
|
|
||||||
import static org.lwjgl.opengl.GL30.glBlitFramebuffer;
|
|
||||||
import static org.lwjgl.opengl.GL30.glClearBufferfv;
|
|
||||||
import static org.lwjgl.opengl.GL40.glBlendFunci;
|
|
||||||
import static org.lwjgl.opengl.GL40.glBlendEquation;
|
|
||||||
import static org.lwjgl.system.MemoryUtil.NULL;
|
|
||||||
|
|
||||||
import org.joml.Vector3f;
|
|
||||||
|
|
||||||
|
|
||||||
public class DebugRendering {
|
public class DebugRendering {
|
||||||
|
|
||||||
public static void drawUIBounds(){
|
public static void drawUIBoundsPolygon(){
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
||||||
for(Element currentElement : Globals.elementManager.getWindowList()){
|
for(Element currentElement : Globals.elementManager.getWindowList()){
|
||||||
@ -121,6 +39,29 @@ public class DebugRendering {
|
|||||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static ShaderProgram windowDrawDebugProgram = null;
|
||||||
|
static Model planeModel = null;
|
||||||
|
public static void drawUIBounds(int parentFramebufferPointer, Vector3f boxPosition, Vector3f boxDimensions, Vector3f color){
|
||||||
|
if(Globals.RENDER_FLAG_RENDER_UI_BOUNDS){
|
||||||
|
if(planeModel == null){
|
||||||
|
planeModel = Globals.assetManager.fetchModel(Globals.imagePlaneModelID);
|
||||||
|
}
|
||||||
|
if(windowDrawDebugProgram == null){
|
||||||
|
windowDrawDebugProgram = Globals.assetManager.fetchShader("Shaders/ui/debug/windowBound.vs", null, "Shaders/ui/debug/windowBound.fs");
|
||||||
|
}
|
||||||
|
if(windowDrawDebugProgram != null && planeModel != null){
|
||||||
|
Globals.renderingEngine.bindFramebuffer(parentFramebufferPointer);
|
||||||
|
Globals.renderingEngine.setActiveShader(windowDrawDebugProgram);
|
||||||
|
planeModel.pushUniformToMesh("plane", "mPosition", boxPosition);
|
||||||
|
planeModel.pushUniformToMesh("plane", "mDimension", boxDimensions);
|
||||||
|
planeModel.pushUniformToMesh("plane", "color", color);
|
||||||
|
// planeModel.drawUI();
|
||||||
|
//drawUI sets shader so overriding window bound shader
|
||||||
|
planeModel.draw(false, false, true, false, false, false, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void drawRect(int posX, int posY, int width, int height, int parentWidth, int parentHeight){
|
static void drawRect(int posX, int posY, int width, int height, int parentWidth, int parentHeight){
|
||||||
float ndcX = (float)posX/parentWidth;
|
float ndcX = (float)posX/parentWidth;
|
||||||
float ndcY = (float)posY/parentHeight;
|
float ndcY = (float)posY/parentHeight;
|
||||||
|
|||||||
@ -0,0 +1,28 @@
|
|||||||
|
package electrosphere.renderer.shader;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import electrosphere.logger.LoggerInterface;
|
||||||
|
|
||||||
|
public class ShaderOptionMap {
|
||||||
|
|
||||||
|
protected Map<String,List<String>> shaderAlternativesMap;
|
||||||
|
|
||||||
|
public List<String> getAlternativesForFile(String filePath){
|
||||||
|
return shaderAlternativesMap.get(filePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void debug(){
|
||||||
|
LoggerInterface.loggerRenderer.DEBUG("============================");
|
||||||
|
LoggerInterface.loggerRenderer.DEBUG("Debug shader alternative map");
|
||||||
|
LoggerInterface.loggerRenderer.DEBUG("============================");
|
||||||
|
for(String key : shaderAlternativesMap.keySet()){
|
||||||
|
LoggerInterface.loggerRenderer.DEBUG(key);
|
||||||
|
for(String alternative : shaderAlternativesMap.get(key)){
|
||||||
|
LoggerInterface.loggerRenderer.DEBUG(" - " + alternative);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,20 +1,27 @@
|
|||||||
package electrosphere.renderer.ui;
|
package electrosphere.renderer.ui;
|
||||||
|
|
||||||
|
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;
|
||||||
|
import static org.lwjgl.opengl.GL11.glClearColor;
|
||||||
|
import static org.lwjgl.opengl.GL30.GL_FRAMEBUFFER;
|
||||||
|
import static org.lwjgl.opengl.GL30.glBindFramebuffer;
|
||||||
|
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.joml.Vector3f;
|
||||||
|
|
||||||
import electrosphere.logger.LoggerInterface;
|
import electrosphere.logger.LoggerInterface;
|
||||||
import electrosphere.main.Globals;
|
import electrosphere.main.Globals;
|
||||||
import electrosphere.renderer.Material;
|
import electrosphere.renderer.Material;
|
||||||
import electrosphere.renderer.Model;
|
import electrosphere.renderer.Model;
|
||||||
|
import electrosphere.renderer.debug.DebugRendering;
|
||||||
import electrosphere.renderer.framebuffer.Framebuffer;
|
import electrosphere.renderer.framebuffer.Framebuffer;
|
||||||
import electrosphere.renderer.framebuffer.FramebufferUtils;
|
import electrosphere.renderer.framebuffer.FramebufferUtils;
|
||||||
import electrosphere.renderer.ui.events.Event;
|
import electrosphere.renderer.ui.events.Event;
|
||||||
import electrosphere.renderer.ui.events.NavigationEvent;
|
import electrosphere.renderer.ui.events.NavigationEvent;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
import org.joml.Vector3f;
|
|
||||||
import static org.lwjgl.opengl.GL11.*;
|
|
||||||
import static org.lwjgl.opengl.GL30.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author amaterasu
|
* @author amaterasu
|
||||||
@ -31,6 +38,8 @@ public class Window implements DrawableElement, ContainerElement, NavigableEleme
|
|||||||
|
|
||||||
NavigationEventCallback navCallback;
|
NavigationEventCallback navCallback;
|
||||||
|
|
||||||
|
static final Vector3f windowDrawDebugColor = new Vector3f(1.0f,0.0f,0.0f);
|
||||||
|
|
||||||
public Window(int positionX, int positionY, int width, int height){
|
public Window(int positionX, int positionY, int width, int height){
|
||||||
//TODO: figure out why this has to be 1920x1080
|
//TODO: figure out why this has to be 1920x1080
|
||||||
widgetBuffer = FramebufferUtils.generateTextureFramebuffer(width, height);
|
widgetBuffer = FramebufferUtils.generateTextureFramebuffer(width, height);
|
||||||
@ -78,6 +87,10 @@ public class Window implements DrawableElement, ContainerElement, NavigableEleme
|
|||||||
} else {
|
} else {
|
||||||
LoggerInterface.loggerRenderer.ERROR("Window unable to find plane model!!", new Exception());
|
LoggerInterface.loggerRenderer.ERROR("Window unable to find plane model!!", new Exception());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(Globals.RENDER_FLAG_RENDER_UI_BOUNDS){
|
||||||
|
DebugRendering.drawUIBounds(parentFramebufferPointer, boxPosition, boxDimensions, windowDrawDebugColor);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void pack() {
|
public void pack() {
|
||||||
|
|||||||
@ -1,25 +1,21 @@
|
|||||||
package electrosphere.renderer.ui.elements;
|
package electrosphere.renderer.ui.elements;
|
||||||
|
|
||||||
|
import static org.lwjgl.opengl.GL30.GL_FRAMEBUFFER;
|
||||||
|
import static org.lwjgl.opengl.GL30.glBindFramebuffer;
|
||||||
|
|
||||||
|
import org.joml.Vector3f;
|
||||||
|
|
||||||
import electrosphere.logger.LoggerInterface;
|
import electrosphere.logger.LoggerInterface;
|
||||||
import electrosphere.main.Globals;
|
import electrosphere.main.Globals;
|
||||||
import electrosphere.renderer.Material;
|
import electrosphere.renderer.Material;
|
||||||
import electrosphere.renderer.Model;
|
import electrosphere.renderer.Model;
|
||||||
import electrosphere.renderer.framebuffer.Framebuffer;
|
import electrosphere.renderer.debug.DebugRendering;
|
||||||
import electrosphere.renderer.framebuffer.FramebufferUtils;
|
|
||||||
import electrosphere.renderer.texture.Texture;
|
import electrosphere.renderer.texture.Texture;
|
||||||
import electrosphere.renderer.ui.DraggableElement;
|
import electrosphere.renderer.ui.DraggableElement;
|
||||||
import electrosphere.renderer.ui.DrawableElement;
|
import electrosphere.renderer.ui.DrawableElement;
|
||||||
import electrosphere.renderer.ui.events.DragEvent;
|
import electrosphere.renderer.ui.events.DragEvent;
|
||||||
import electrosphere.renderer.ui.events.Event;
|
|
||||||
import electrosphere.renderer.ui.events.DragEvent.DragEventType;
|
import electrosphere.renderer.ui.events.DragEvent.DragEventType;
|
||||||
|
import electrosphere.renderer.ui.events.Event;
|
||||||
import org.joml.Vector3f;
|
|
||||||
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;
|
|
||||||
import static org.lwjgl.opengl.GL11.glClearColor;
|
|
||||||
import static org.lwjgl.opengl.GL30.GL_FRAMEBUFFER;
|
|
||||||
import static org.lwjgl.opengl.GL30.glBindFramebuffer;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -42,6 +38,8 @@ public class ImagePanel implements DrawableElement, DraggableElement {
|
|||||||
DragEventCallback onDrag;
|
DragEventCallback onDrag;
|
||||||
DragEventCallback onDragRelease;
|
DragEventCallback onDragRelease;
|
||||||
|
|
||||||
|
static final Vector3f windowDrawDebugColor = new Vector3f(0.0f,0.5f,1.0f);
|
||||||
|
|
||||||
public ImagePanel(int x, int y, int width, int height, String texturePath){
|
public ImagePanel(int x, int y, int width, int height, String texturePath){
|
||||||
this.texturePath = texturePath;
|
this.texturePath = texturePath;
|
||||||
texture = Globals.assetManager.fetchTexture(this.texturePath);
|
texture = Globals.assetManager.fetchTexture(this.texturePath);
|
||||||
@ -99,6 +97,10 @@ public class ImagePanel implements DrawableElement, DraggableElement {
|
|||||||
} else {
|
} else {
|
||||||
LoggerInterface.loggerRenderer.ERROR("Image Panel unable to find plane model!!", new Exception());
|
LoggerInterface.loggerRenderer.ERROR("Image Panel unable to find plane model!!", new Exception());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(Globals.RENDER_FLAG_RENDER_UI_BOUNDS){
|
||||||
|
DebugRendering.drawUIBounds(parentFramebufferPointer, boxPosition, boxDimensions, windowDrawDebugColor);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int width = 1;
|
public int width = 1;
|
||||||
|
|||||||
@ -1,15 +1,17 @@
|
|||||||
package electrosphere.renderer.ui.elements;
|
package electrosphere.renderer.ui.elements;
|
||||||
|
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.joml.Vector3f;
|
||||||
|
|
||||||
import electrosphere.main.Globals;
|
import electrosphere.main.Globals;
|
||||||
import electrosphere.renderer.Model;
|
import electrosphere.renderer.debug.DebugRendering;
|
||||||
import electrosphere.renderer.ui.DrawableElement;
|
import electrosphere.renderer.ui.DrawableElement;
|
||||||
import electrosphere.renderer.ui.Element;
|
import electrosphere.renderer.ui.Element;
|
||||||
import electrosphere.renderer.ui.events.Event;
|
import electrosphere.renderer.ui.events.Event;
|
||||||
import electrosphere.renderer.ui.font.FontUtils;
|
import electrosphere.renderer.ui.font.FontUtils;
|
||||||
import electrosphere.renderer.ui.font.bitmapchar.BitmapCharacter;
|
import electrosphere.renderer.ui.font.bitmapchar.BitmapCharacter;
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
import org.joml.Vector3f;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -36,6 +38,8 @@ public class Label implements DrawableElement {
|
|||||||
|
|
||||||
List<BitmapCharacter> childrenElements = new LinkedList<BitmapCharacter>();
|
List<BitmapCharacter> childrenElements = new LinkedList<BitmapCharacter>();
|
||||||
|
|
||||||
|
static final Vector3f windowDrawDebugColor = new Vector3f(1.0f,1.0f,1.0f);
|
||||||
|
|
||||||
public Label(int x, int y, float fontSize){
|
public Label(int x, int y, float fontSize){
|
||||||
this.positionX = x;
|
this.positionX = x;
|
||||||
this.positionY = y;
|
this.positionY = y;
|
||||||
@ -81,6 +85,16 @@ public class Label implements DrawableElement {
|
|||||||
for(DrawableElement child : childrenElements){
|
for(DrawableElement child : childrenElements){
|
||||||
child.draw(parentFramebufferPointer, parentWidth, parentHeight);
|
child.draw(parentFramebufferPointer, parentWidth, parentHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(Globals.RENDER_FLAG_RENDER_UI_BOUNDS){
|
||||||
|
float ndcX = (float)positionX/parentWidth;
|
||||||
|
float ndcY = (float)positionY/parentHeight;
|
||||||
|
float ndcWidth = (float)getWidth()/parentWidth;
|
||||||
|
float ndcHeight = (float)getHeight()/parentHeight;
|
||||||
|
Vector3f boxPosition = new Vector3f(ndcX,ndcY,0);
|
||||||
|
Vector3f boxDimensions = new Vector3f(ndcWidth,ndcHeight,0);
|
||||||
|
DebugRendering.drawUIBounds(parentFramebufferPointer, boxPosition, boxDimensions, windowDrawDebugColor);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getWidth() {
|
public int getWidth() {
|
||||||
|
|||||||
@ -1,30 +1,26 @@
|
|||||||
package electrosphere.renderer.ui.layout;
|
package electrosphere.renderer.ui.layout;
|
||||||
|
|
||||||
|
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;
|
||||||
|
import static org.lwjgl.opengl.GL11.glClearColor;
|
||||||
|
import static org.lwjgl.opengl.GL30.GL_FRAMEBUFFER;
|
||||||
|
import static org.lwjgl.opengl.GL30.glBindFramebuffer;
|
||||||
|
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.joml.Vector3f;
|
||||||
|
|
||||||
import electrosphere.main.Globals;
|
import electrosphere.main.Globals;
|
||||||
import electrosphere.renderer.Material;
|
import electrosphere.renderer.Material;
|
||||||
|
import electrosphere.renderer.Model;
|
||||||
|
import electrosphere.renderer.debug.DebugRendering;
|
||||||
import electrosphere.renderer.framebuffer.Framebuffer;
|
import electrosphere.renderer.framebuffer.Framebuffer;
|
||||||
|
import electrosphere.renderer.framebuffer.FramebufferUtils;
|
||||||
import electrosphere.renderer.ui.DrawableElement;
|
import electrosphere.renderer.ui.DrawableElement;
|
||||||
import electrosphere.renderer.ui.Element;
|
import electrosphere.renderer.ui.Element;
|
||||||
import electrosphere.renderer.ui.events.Event;
|
import electrosphere.renderer.ui.events.Event;
|
||||||
import electrosphere.renderer.Model;
|
|
||||||
import electrosphere.engine.assetmanager.AssetDataStrings;
|
|
||||||
import electrosphere.renderer.framebuffer.FramebufferUtils;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
import org.joml.Vector3f;
|
|
||||||
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.GL_TEXTURE_2D;
|
|
||||||
import static org.lwjgl.opengl.GL11.glBindTexture;
|
|
||||||
import static org.lwjgl.opengl.GL11.glClear;
|
|
||||||
import static org.lwjgl.opengl.GL11.glClearColor;
|
|
||||||
import static org.lwjgl.opengl.GL13.GL_TEXTURE0;
|
|
||||||
import static org.lwjgl.opengl.GL13.GL_TEXTURE1;
|
|
||||||
import static org.lwjgl.opengl.GL13.GL_TEXTURE2;
|
|
||||||
import static org.lwjgl.opengl.GL13.GL_TEXTURE3;
|
|
||||||
import static org.lwjgl.opengl.GL13.glActiveTexture;
|
|
||||||
import static org.lwjgl.opengl.GL30.GL_FRAMEBUFFER;
|
|
||||||
import static org.lwjgl.opengl.GL30.glBindFramebuffer;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -41,6 +37,8 @@ public class LayoutSchemeListScrollable implements DrawableElement,LayoutScheme
|
|||||||
Vector3f texPosition = new Vector3f(0,0,0);
|
Vector3f texPosition = new Vector3f(0,0,0);
|
||||||
Vector3f texScale = new Vector3f(1,1,0);
|
Vector3f texScale = new Vector3f(1,1,0);
|
||||||
|
|
||||||
|
static final Vector3f windowDrawDebugColor = new Vector3f(0.0f,1.0f,0.0f);
|
||||||
|
|
||||||
public LayoutSchemeListScrollable(int positionX, int positionY, int width, int height, boolean draw){
|
public LayoutSchemeListScrollable(int positionX, int positionY, int width, int height, boolean draw){
|
||||||
customMat.setTexturePointer(widgetBuffer.getTexturePointer());
|
customMat.setTexturePointer(widgetBuffer.getTexturePointer());
|
||||||
// customMat.setTexturePointer(Globals.assetManager.fetchTexture("Textures/Branch.png").getTexturePointer());
|
// customMat.setTexturePointer(Globals.assetManager.fetchTexture("Textures/Branch.png").getTexturePointer());
|
||||||
@ -81,6 +79,10 @@ public class LayoutSchemeListScrollable implements DrawableElement,LayoutScheme
|
|||||||
planeModel.pushUniformToMesh("plane", "tDimension", texScale);
|
planeModel.pushUniformToMesh("plane", "tDimension", texScale);
|
||||||
planeModel.meshes.get(0).setMaterial(customMat);
|
planeModel.meshes.get(0).setMaterial(customMat);
|
||||||
planeModel.drawUI();
|
planeModel.drawUI();
|
||||||
|
|
||||||
|
if(Globals.RENDER_FLAG_RENDER_UI_BOUNDS){
|
||||||
|
DebugRendering.drawUIBounds(parentFramebufferPointer, boxPosition, boxDimensions, windowDrawDebugColor);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void pack() {
|
public void pack() {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user