Merge branch 'dev' of ssh://git.austinwhoover.com:222/gitadmin/Renderer into dev

This commit is contained in:
austin 2021-05-16 19:00:12 -04:00
commit 631bdea776
2 changed files with 33 additions and 21 deletions

View File

@ -16,6 +16,8 @@ import electrosphere.entity.EntityUtil;
import electrosphere.entity.state.MovementTree; import electrosphere.entity.state.MovementTree;
import electrosphere.game.cell.CellManager; import electrosphere.game.cell.CellManager;
import electrosphere.game.terrain.TerrainManager; import electrosphere.game.terrain.TerrainManager;
import electrosphere.net.client.Connection;
import electrosphere.net.server.Server;
import electrosphere.renderer.ModelUtils; import electrosphere.renderer.ModelUtils;
import electrosphere.terraingen.TerrainGen; import electrosphere.terraingen.TerrainGen;
import electrosphere.terraingen.models.TerrainModel; import electrosphere.terraingen.models.TerrainModel;
@ -125,19 +127,25 @@ public class Main {
initWorld(); initWorld();
//run initialization stuff
initTerrainManager();
//Create opengl if(Globals.mainConfig.runRenderer){
RenderUtils.createOpenglContext(); //Create opengl
RenderUtils.createOpenglContext();
}
//init global variables //init global variables
Globals.initGlobals(); Globals.initGlobals();
if(Globals.mainConfig.runRenderer){
forkConnection();
}
if(Globals.mainConfig.runRenderer){
initWorld(); initCellManager();
}
initCellManager();
initSkybox(); initSkybox();
@ -157,10 +165,10 @@ public class Main {
Camera camera_player_chase = new Camera(); Camera camera_player_chase = new Camera();
Camera cam_Player_Orbit = new Camera(); Camera cam_Player_Orbit = new Camera();
boolean running = true;
//main loop //main loop
while (!glfwWindowShouldClose(Globals.window)) { while (running) {
/* /*
Frame calculation Frame calculation
@ -272,6 +280,10 @@ public class Main {
//check and call events and swap the buffers //check and call events and swap the buffers
glfwSwapBuffers(Globals.window); glfwSwapBuffers(Globals.window);
glfwPollEvents(); glfwPollEvents();
if(glfwWindowShouldClose(Globals.window)){
running = false;
}
} }
//Terminate the program. //Terminate the program.
glfwTerminate(); glfwTerminate();
@ -337,7 +349,7 @@ public class Main {
static void initWorld(){ static void initTerrainManager(){
float[][] elevation; float[][] elevation;
terrainManager = new TerrainManager(2000,200,100,0.25f); terrainManager = new TerrainManager(2000,200,100,0.25f);
@ -422,12 +434,12 @@ public class Main {
} }
public static void initServer(){ public static void forkServer(){
Server.startServerThread();
} }
public static void initClient(){ public static void forkConnection(){
Connection.startConnection();
} }
} }

View File

@ -37,18 +37,18 @@ public class Server {
ex.printStackTrace(); ex.printStackTrace();
System.exit(1); System.exit(1);
} }
try { boolean running = true;
serverSocket.bind(new InetSocketAddress(port)); while(running){
boolean running = true; Socket newSocket;
while(running){ try {
Socket newSocket = serverSocket.accept(); newSocket = serverSocket.accept();
Client newClient = new Client(newSocket); Client newClient = new Client(newSocket);
clientMap.put(newSocket.getInetAddress().getHostAddress(), newClient); clientMap.put(newSocket.getInetAddress().getHostAddress(), newClient);
new Thread(newClient).start(); new Thread(newClient).start();
} catch (IOException ex) {
System.err.println("Socket error on client socket!");
ex.printStackTrace();
} }
} catch (IOException ex){
System.err.println("Socket error on client socket!");
ex.printStackTrace();
} }
} }