NEngine - Nishu Game Engine

Definitely! That’s the whole reason I only used LibGDX once or twice; it just wasn’t flexible enough for me and I hate not knowing exactly what everything does. A utility library seems to suit me well because you can abstract them and do whatever you want with them. I don’t need to pass in a texture as a parameter for that sprite because I can create a new constructor that doesn’t require a texture. You simply just can’t do that in engines that don’t support it. I can quite honestly say I think I’m done with engines unless I absolutely need them because a teacher says I do or a job says I need to. I just don’t like using code I haven’t written!

I await the people who will bash on me for not taking the easy way out of things :smiley:

Huge update!

I decided to turn this into a utility library instead of an engine. So, here’s my first update of the new library. Please note that some of the code I’m using I’ve taken from other people over the years. Basically, code hoarding. It’s temporary until I decide to re-write it, but oh well.


Changelog:
------------
Now have:

Camera (interface for easy creation of different types of cameras)

Camera3D (as the name implies, this camera, which implements Camera, is a 3D camera

Color4f (Small color class, nothing special besides pre-made primary colors)

ErrorHandler (the start to my errorhandler class, just prints out statements and will later allow the creation of custom Java errors)

GameLoop (Utility class (dependent upon Time.class) that creates, and runs, a gameloop at a fixed FPS rate. Still needs a little work (pausing and resuming)

Model (Small utility class that holds vertex and normal information for a model)

ModelFace (Small utility class that creates new model face out of triangles)

OBJLoader (Loads an .obj file and is dependent upon Model and ModelFace)

ResourceManager (took the general idea of this class from wessles' engine (sorry!), it holds hashmaps that store data. I added support for adding in your own custom hashmaps, so you aren't stuck with my hard coded ones. Still need to work on it a little and add more stock maps.)

Screen (implements ScreenObject, its an abstract class that holds methods for things such as initialization, rendering updating and disposing. Required by the GameLoop class)

ScreenObject (interface that holds the above mentioned methods, nothing special)

Shader (Reads and stores into memory a vertex and fragment shader. Need to update some more)

ShaderProgram (Dependent upon Shader.class, creates and allows for the usage and deletion of shaders. Need to add the ability to push uniforms, that's coming soon!)

SpriteBatch (Large class, only half complete, that batches geometry together for rendering. It utilizes VBOs and VAs to render static geometry and dynamic geometry, respectfully.)

Texture (Utility class to load and bind textures. Only half done)

Time (Small utility class that gets the current time and handles the delta)

Vector2f (Two dimensional vector. All the math is complete!)

Vector3f (Same as above just three dimensional and with more complex math)

Window (Static utility class that creates, updates and destroys the current OpenGL/Window context. Still need to add support for different display modes and other stuff.)


So, that was a huge list (Looks significantly smaller when actually looking at! it, oh well!) I’ll probably release the first version once the sprite batcher is finished, so maybe in a few days. For now, here’s the repo to go look at all the code! Sorry, its very undocumented!

NEngine

The current code is under GLUtils! Any suggestions are greatly appreciated!

I wanted to show off a little, so I decided to create a new program that has a 3D camera in place, a game loop that lets you limit the FPS and a Window. I was able to do this all in 45 lines of code (not including the extra spaces and imports)! I’m pretty happy with it, and I can further reduce the amount of lines by wrapping all the low level OpenGL functions into a separate class. Here’s the example code:


package com.nishu.idk;

import static org.lwjgl.opengl.GL11.*;
import static org.lwjgl.util.glu.GLU.gluPerspective;

import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.Display;

import com.nishu.utils.Camera;
import com.nishu.utils.Camera3D;
import com.nishu.utils.GameLoop;
import com.nishu.utils.Screen;
import com.nishu.utils.Window;

public class Main extends Screen{
	
	public static final int WIDTH = 1280;
	public static final int HEIGHT = 720;
	
	private GameLoop loop;
	private Camera camera;
	
	public Main(){
		loop = new GameLoop();
		loop.setScreen(this);
		loop.start(60);
	}

	@Override
	public void init() {
		camera = new Camera3D.CameraBuilder().setAspectRatio((float) Display.getWidth() / Display.getHeight()).setRotation(0, 0, 0).setPosition(0, 0, 0).setFieldOfView(67).build();
		camera.applyProjection();
	}

	@Override
	public void initGL() {
		glViewport(0, 0, Display.getWidth(), Display.getHeight());
		glMatrixMode(GL_PROJECTION);
		glLoadIdentity();
		
		gluPerspective((float) 67, WIDTH / HEIGHT, 0.001f, 1000f);
		glMatrixMode(GL_MODELVIEW);
		
	}

	@Override
	public void render() {
		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
		glClearColor(0, 0, 0.75f, 0);
		glLoadIdentity();
		camera.applyTranslations();
	}

	@Override
	public void update() {
		camera.updateMouse(1, 90, -90);
		camera.updateKeys(32, 1);
		if(Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)){
			loop.stop();
		}
	}
	
	@Override
	public void dispose() {
	}
	
	public static void main(String[] args){
		Window.createWindow(1280, 720, "IDK3D", false);
		new Main();
	}
}

And a little update on the spritebatcher; Its pretty much finished, I just need to add color and texture support. Furthermore, I need to remove any dependencies (or allow you to not use the class with any dependencies) on the other classes in the library. Should be pretty easy to do!