Failure to fix mac rendering
This commit is contained in:
parent
236eb59274
commit
f862c104cc
@ -2,13 +2,13 @@
|
||||
"gameplayGenerateWorld" : false,
|
||||
"gameplayPhysicsCellRadius" : 2,
|
||||
|
||||
"displayWidth" : 1920,
|
||||
"displayHeight" : 1080,
|
||||
"displayWidth" : 2560,
|
||||
"displayHeight" : 1600,
|
||||
|
||||
"graphicsFOV" : 90.0,
|
||||
|
||||
|
||||
"graphicsPerformanceLODChunkRadius" : 5,
|
||||
"graphicsPerformanceLODChunkRadius" : 2,
|
||||
"graphicsPerformanceEnableVSync" : true,
|
||||
"graphicsPerformanceDrawShadows" : true,
|
||||
|
||||
|
||||
@ -1,69 +0,0 @@
|
||||
package electrosphere.renderer.light;
|
||||
|
||||
import org.joml.Vector3f;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author amaterasu
|
||||
*/
|
||||
public class ItsBroken_DirectionalLight {
|
||||
Vector3f direction;
|
||||
|
||||
Vector3f ambient;
|
||||
Vector3f diffuse;
|
||||
Vector3f specular;
|
||||
|
||||
public void setDirection(Vector3f direction) {
|
||||
this.direction = direction;
|
||||
}
|
||||
|
||||
public void setAmbient(Vector3f ambient) {
|
||||
this.ambient = ambient;
|
||||
}
|
||||
|
||||
public void setDiffuse(Vector3f diffuse) {
|
||||
this.diffuse = diffuse;
|
||||
}
|
||||
|
||||
public void setSpecular(Vector3f specular) {
|
||||
this.specular = specular;
|
||||
}
|
||||
|
||||
public Vector3f getDirection() {
|
||||
return direction;
|
||||
}
|
||||
|
||||
public Vector3f getAmbient() {
|
||||
return ambient;
|
||||
}
|
||||
|
||||
public Vector3f getDiffuse() {
|
||||
return diffuse;
|
||||
}
|
||||
|
||||
public Vector3f getSpecular() {
|
||||
return specular;
|
||||
}
|
||||
|
||||
public ItsBroken_DirectionalLight(Vector3f direction){
|
||||
this.direction = direction;
|
||||
ambient = new Vector3f(0.05f, 0.05f, 0.05f);
|
||||
diffuse = new Vector3f(0.4f, 0.4f, 0.4f);
|
||||
specular = new Vector3f(0.5f, 0.5f, 0.5f);
|
||||
this.direction.normalize();
|
||||
ambient.normalize();
|
||||
diffuse.normalize();
|
||||
specular.normalize();
|
||||
}
|
||||
|
||||
public ItsBroken_DirectionalLight(Vector3f direction, Vector3f color){
|
||||
this.direction = direction;
|
||||
ambient = new Vector3f( color.x * 0.05f, color.y * 0.05f, color.z * 0.05f);
|
||||
diffuse = new Vector3f( color.x * 0.4f, color.y * 0.4f, color.z * 0.4f);
|
||||
specular = new Vector3f(color.x * 0.5f, color.y * 0.5f, color.z * 0.5f);
|
||||
this.direction.normalize();
|
||||
ambient.normalize();
|
||||
diffuse.normalize();
|
||||
specular.normalize();
|
||||
}
|
||||
}
|
||||
@ -1,23 +0,0 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package electrosphere.renderer.light;
|
||||
|
||||
import static org.lwjgl.opengl.GL15.*;
|
||||
import static org.lwjgl.opengl.GL31.GL_UNIFORM_BUFFER;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author amaterasu
|
||||
*/
|
||||
public class LightBuffer {
|
||||
int light_uniform_buffer_address;
|
||||
|
||||
public LightBuffer(){
|
||||
light_uniform_buffer_address = glGenBuffers();
|
||||
glBindBuffer(GL_UNIFORM_BUFFER,light_uniform_buffer_address);
|
||||
//glBufferData(GL_UNIFORM_BUFFER, <my_data>, GL_STATIC_DRAW);
|
||||
}
|
||||
}
|
||||
@ -1,42 +0,0 @@
|
||||
package electrosphere.renderer.light;
|
||||
|
||||
import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.EntityDataStrings;
|
||||
import electrosphere.main.Globals;
|
||||
import org.joml.Vector3d;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author amaterasu
|
||||
*/
|
||||
public class LightEntityUtils {
|
||||
|
||||
public static Entity createDirectionalLight(Vector3f position, Vector3f ambient, Vector3f diffuse, Vector3f specular){
|
||||
Entity rVal = new Entity();
|
||||
Globals.entityManager.registerEntity(rVal);
|
||||
Globals.entityManager.registerLightEntity(rVal);
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_LIGHT_TYPE, EntityDataStrings.DATA_STRING_LIGHT_TYPE_DIRECTIONAL);
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_POSITION, new Vector3d(position.x,position.y,position.z));
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_LIGHT_AMBIENT, ambient);
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_LIGHT_DIFFUSE, diffuse);
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_LIGHT_SPECULAR, specular);
|
||||
return rVal;
|
||||
}
|
||||
|
||||
public static Entity createPointLight(Vector3f position, Vector3f ambient, Vector3f diffuse, Vector3f specular, float constant, float linear, float quadratic){
|
||||
Entity rVal = new Entity();
|
||||
Globals.entityManager.registerEntity(rVal);
|
||||
Globals.entityManager.registerLightEntity(rVal);
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_LIGHT_TYPE, EntityDataStrings.DATA_STRING_LIGHT_TYPE_POINT);
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_POSITION, new Vector3d(position.x,position.y,position.z));
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_LIGHT_AMBIENT, ambient);
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_LIGHT_DIFFUSE, diffuse);
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_LIGHT_SPECULAR, specular);
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_LIGHT_CONSTANT, constant);
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_LIGHT_LINEAR, linear);
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_LIGHT_QUADRATIC, quadratic);
|
||||
return rVal;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,9 +0,0 @@
|
||||
package electrosphere.renderer.light;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author amaterasu
|
||||
*/
|
||||
public class LightManager {
|
||||
|
||||
}
|
||||
@ -1,106 +0,0 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package electrosphere.renderer.light;
|
||||
|
||||
import org.joml.Vector3f;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author amaterasu
|
||||
*/
|
||||
public class PointLight {
|
||||
Vector3f position;
|
||||
float constant;
|
||||
float linear;
|
||||
float quadratic;
|
||||
Vector3f ambient;
|
||||
Vector3f diffuse;
|
||||
Vector3f specular;
|
||||
|
||||
public void setPosition(Vector3f position) {
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
public void setConstant(float constant) {
|
||||
this.constant = constant;
|
||||
}
|
||||
|
||||
public void setLinear(float linear) {
|
||||
this.linear = linear;
|
||||
}
|
||||
|
||||
public void setQuadratic(float quadratic) {
|
||||
this.quadratic = quadratic;
|
||||
}
|
||||
|
||||
public void setAmbient(Vector3f ambient) {
|
||||
this.ambient = ambient;
|
||||
}
|
||||
|
||||
public void setDiffuse(Vector3f diffuse) {
|
||||
this.diffuse = diffuse;
|
||||
}
|
||||
|
||||
public void setSpecular(Vector3f specular) {
|
||||
this.specular = specular;
|
||||
}
|
||||
|
||||
public Vector3f getPosition() {
|
||||
return position;
|
||||
}
|
||||
|
||||
public float getConstant() {
|
||||
return constant;
|
||||
}
|
||||
|
||||
public float getLinear() {
|
||||
return linear;
|
||||
}
|
||||
|
||||
public float getQuadratic() {
|
||||
return quadratic;
|
||||
}
|
||||
|
||||
public Vector3f getAmbient() {
|
||||
return ambient;
|
||||
}
|
||||
|
||||
public Vector3f getDiffuse() {
|
||||
return diffuse;
|
||||
}
|
||||
|
||||
public Vector3f getSpecular() {
|
||||
return specular;
|
||||
}
|
||||
|
||||
public PointLight(Vector3f position){
|
||||
this.position = position;
|
||||
constant = 1.0f;
|
||||
linear = 0.01f;
|
||||
quadratic = 0.01f;
|
||||
ambient = new Vector3f(0.05f, 0.05f, 0.05f);
|
||||
diffuse = new Vector3f(0.8f, 0.8f, 0.8f);
|
||||
specular = new Vector3f(1.0f, 1.0f, 1.0f);
|
||||
this.position.normalize();
|
||||
ambient.normalize();
|
||||
diffuse.normalize();
|
||||
specular.normalize();
|
||||
}
|
||||
|
||||
public PointLight(Vector3f position, Vector3f color){
|
||||
this.position = position;
|
||||
constant = 1.0f;
|
||||
linear = 0.01f;
|
||||
quadratic = 0.01f;
|
||||
ambient = new Vector3f(color.x * 0.05f, color.y * 0.05f, color.z * 0.05f);
|
||||
diffuse = new Vector3f(color.x * 0.8f, color.y * 0.8f, color.z * 0.8f);
|
||||
specular = new Vector3f(color.x, color.y, color.z);
|
||||
this.position.normalize();
|
||||
ambient.normalize();
|
||||
diffuse.normalize();
|
||||
specular.normalize();
|
||||
}
|
||||
}
|
||||
@ -1,143 +0,0 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package electrosphere.renderer.light;
|
||||
|
||||
import org.joml.Vector3f;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author amaterasu
|
||||
*/
|
||||
public class SpotLight {
|
||||
Vector3f position;
|
||||
Vector3f direction;
|
||||
float cutOff;
|
||||
float outerCutOff;
|
||||
|
||||
float constant;
|
||||
float linear;
|
||||
float quadratic;
|
||||
|
||||
Vector3f ambient;
|
||||
Vector3f diffuse;
|
||||
Vector3f specular;
|
||||
|
||||
public void setPosition(Vector3f position) {
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
public void setDirection(Vector3f direction) {
|
||||
this.direction = direction;
|
||||
}
|
||||
|
||||
public void setCutOff(float cutOff) {
|
||||
this.cutOff = cutOff;
|
||||
}
|
||||
|
||||
public void setOuterCutOff(float outerCutOff) {
|
||||
this.outerCutOff = outerCutOff;
|
||||
}
|
||||
|
||||
public void setConstant(float constant) {
|
||||
this.constant = constant;
|
||||
}
|
||||
|
||||
public void setLinear(float linear) {
|
||||
this.linear = linear;
|
||||
}
|
||||
|
||||
public void setQuadratic(float quadratic) {
|
||||
this.quadratic = quadratic;
|
||||
}
|
||||
|
||||
public void setAmbient(Vector3f ambient) {
|
||||
this.ambient = ambient;
|
||||
}
|
||||
|
||||
public void setDiffuse(Vector3f diffuse) {
|
||||
this.diffuse = diffuse;
|
||||
}
|
||||
|
||||
public void setSpecular(Vector3f specular) {
|
||||
this.specular = specular;
|
||||
}
|
||||
|
||||
public Vector3f getPosition() {
|
||||
return position;
|
||||
}
|
||||
|
||||
public Vector3f getDirection() {
|
||||
return direction;
|
||||
}
|
||||
|
||||
public float getCutOff() {
|
||||
return cutOff;
|
||||
}
|
||||
|
||||
public float getOuterCutOff() {
|
||||
return outerCutOff;
|
||||
}
|
||||
|
||||
public float getConstant() {
|
||||
return constant;
|
||||
}
|
||||
|
||||
public float getLinear() {
|
||||
return linear;
|
||||
}
|
||||
|
||||
public float getQuadratic() {
|
||||
return quadratic;
|
||||
}
|
||||
|
||||
public Vector3f getAmbient() {
|
||||
return ambient;
|
||||
}
|
||||
|
||||
public Vector3f getDiffuse() {
|
||||
return diffuse;
|
||||
}
|
||||
|
||||
public Vector3f getSpecular() {
|
||||
return specular;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public SpotLight(Vector3f position, Vector3f direction){
|
||||
this.position = position;
|
||||
this.direction = direction;
|
||||
cutOff = (float)Math.toRadians(12.5f);
|
||||
outerCutOff = (float)Math.toRadians(15.0f);
|
||||
constant = 1.0f;
|
||||
linear = 0.01f;
|
||||
quadratic = 0.01f;
|
||||
ambient = new Vector3f(0.05f, 0.05f, 0.05f);
|
||||
diffuse = new Vector3f(0.8f, 0.8f, 0.8f);
|
||||
specular = new Vector3f(1.0f, 1.0f, 1.0f);
|
||||
this.position.normalize();
|
||||
this.direction.normalize();
|
||||
ambient.normalize();
|
||||
diffuse.normalize();
|
||||
specular.normalize();
|
||||
}
|
||||
|
||||
public SpotLight(Vector3f position, Vector3f direction, Vector3f color){
|
||||
this.position = position;
|
||||
this.direction = direction;
|
||||
constant = 1.0f;
|
||||
linear = 0.01f;
|
||||
quadratic = 0.01f;
|
||||
ambient = new Vector3f(color.x * 0.05f, color.y * 0.05f, color.z * 0.05f);
|
||||
diffuse = new Vector3f(color.x * 0.8f, color.y * 0.8f, color.z * 0.8f);
|
||||
specular = new Vector3f(color.x, color.y, color.z);
|
||||
this.position.normalize();
|
||||
this.direction.normalize();
|
||||
ambient.normalize();
|
||||
diffuse.normalize();
|
||||
specular.normalize();
|
||||
}
|
||||
}
|
||||
@ -37,11 +37,13 @@ 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 org.lwjgl.glfw.GLFWWindowSizeCallbackI;
|
||||
import org.lwjgl.opengl.GL;
|
||||
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_NEAREST;
|
||||
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;
|
||||
@ -67,6 +69,7 @@ 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.glBlitFramebuffer;
|
||||
import static org.lwjgl.system.MemoryUtil.NULL;
|
||||
|
||||
public class RenderingEngine {
|
||||
@ -107,6 +110,14 @@ public class RenderingEngine {
|
||||
LoggerInterface.loggerEngine.ERROR("Failed to make window.", new Exception("Renderer Creation Failure"));
|
||||
glfwTerminate();
|
||||
}
|
||||
//set resize callback
|
||||
GLFW.glfwSetWindowSizeCallback(Globals.window, new GLFWWindowSizeCallbackI(){
|
||||
@Override
|
||||
public void invoke(long window, int width, int height){
|
||||
Globals.WINDOW_HEIGHT = height;
|
||||
Globals.WINDOW_WIDTH = width;
|
||||
}
|
||||
});
|
||||
//Makes the window that was just created the current OS-level window context
|
||||
glfwMakeContextCurrent(Globals.window);
|
||||
//Maximize it
|
||||
@ -516,6 +527,8 @@ public class RenderingEngine {
|
||||
|
||||
|
||||
//render full screen quad
|
||||
// glBlitFramebuffer(0, 0, Globals.WINDOW_WIDTH, Globals.WINDOW_HEIGHT, 0, 0, Globals.WINDOW_WIDTH, Globals.WINDOW_HEIGHT,
|
||||
// GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
||||
Globals.renderingEngine.setActiveShader(screenTextureShaders);
|
||||
glBindVertexArray(screenTextureVAO);
|
||||
glBindTexture(GL_TEXTURE_2D, screenFramebuffer.getTexture());
|
||||
|
||||
@ -22,6 +22,7 @@ import static org.lwjgl.opengl.GL11.glReadBuffer;
|
||||
import static org.lwjgl.opengl.GL11.glTexImage2D;
|
||||
import static org.lwjgl.opengl.GL11.glTexParameterfv;
|
||||
import static org.lwjgl.opengl.GL11.glTexParameteri;
|
||||
import static org.lwjgl.opengl.GL12.GL_CLAMP_TO_EDGE;
|
||||
import static org.lwjgl.opengl.GL13.GL_CLAMP_TO_BORDER;
|
||||
import static org.lwjgl.opengl.GL30.GL_COLOR_ATTACHMENT0;
|
||||
import static org.lwjgl.opengl.GL30.GL_DEPTH24_STENCIL8;
|
||||
@ -54,6 +55,9 @@ public class FramebufferUtils {
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, Globals.WINDOW_WIDTH, Globals.WINDOW_HEIGHT, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
//these make sure the texture actually clamps to the borders of the quad
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
buffer.setTexture(texture);
|
||||
//bind texture to fbo
|
||||
int mipMapLevel = 0;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user