Jump to content

Adventure log of a lazy programmer!

as96

I just started working on my own implementation of an OpenGL game framework, I do NOT plan to release this to the public however I'd like to post once in a while the progress I'm making (unless I decide to drop the development), the updates are not scheduled, an update post could be released every week like it could be every month or even year (unlikely though).

 

I decided to name it "Shark" simply because I was watching Jaws on the TV while I was deciding on how to structure it and thought it was a nice name for a library.

 

Unlike my usual game code this time I decided to avoid an ECS and go for an hierarcic approach so it will not force me to use ECS but it's not gonna stop me from making it if the game I want to make is gonna need it.

 

The graphics will only be 2D, at least as of now I do not plan to implement 3D since I never make 3D games so it would be a waste of time.

 

I already started to write some code (not a lot though), and here's how the syntax looks like:

int main(){	Shark::Window window(1280, 720, "Window", Shark::VideoMode::Windowed);	Shark::Shader shader;	shader.LoadFromString(vertexShaderSource, fragmentShaderSource);	shader.Use();	window.UseVSync(true);	while(!window.ShouldClose())	{		window.PollEvents();		window.Clear();		window.Display();	}	return 0;}

The Shader class is really basic and it needs to be expanded but for now it's enough:

namespace Shark{	class Shader	{	public:		Shader();		Shader(char* vertexSource, char* fragmentSource, char* geometrySource = nullptr);		~Shader();		bool LoadFromString(const char* vertexSource, const char* fragmentSource, const char* geometrySource = nullptr);		bool LoadFromFile(const char* vertexFilePath, const char* fragmentFilePath, const char* geometryFilePath = nullptr);		void Use();		GLuint GetShaderProgram();		static void DisableShaders();	private:		GLuint mProgram;	};}

I'm currently working on writing an input manager (controllers will be supported).

Link to comment
Share on other sites

Link to post
Share on other sites

Me gusta. That library name though ^_^

Speedtests

WiFi - 7ms, 22Mb down, 10Mb up

Ethernet - 6ms, 47.5Mb down, 9.7Mb up

 

Rigs

Spoiler

 Type            Desktop

 OS              Windows 10 Pro

 CPU             i5-4430S

 RAM             8GB CORSAIR XMS3 (2x4gb)

 Cooler          LC Power LC-CC-97 65W

 Motherboard     ASUS H81M-PLUS

 GPU             GeForce GTX 1060

 Storage         120GB Sandisk SSD (boot), 750GB Seagate 2.5" (storage), 500GB Seagate 2.5" SSHD (cache)

 

Spoiler

Type            Server

OS              Ubuntu 14.04 LTS

CPU             Core 2 Duo E6320

RAM             2GB Non-ECC

Motherboard     ASUS P5VD2-MX SE

Storage         RAID 1: 250GB WD Blue and Seagate Barracuda

Uses            Webserver, NAS, Mediaserver, Database Server

 

Quotes of Fame

On 8/27/2015 at 10:09 AM, Drixen said:

Linus is light years ahead a lot of other YouTubers, he isn't just an average YouTuber.. he's legitimately, legit.

On 10/11/2015 at 11:36 AM, Geralt said:

When something is worth doing, it's worth overdoing.

On 6/22/2016 at 10:05 AM, trag1c said:

It's completely blown out of proportion. Also if you're the least bit worried about data gathering then you should go live in a cave a 1000Km from the nearest establishment simply because every device and every entity gathers information these days. In the current era privacy is just fallacy and nothing more.

 

Link to comment
Share on other sites

Link to post
Share on other sites

I personally would program it for 3D even if you are only using it for 2D since from a computer graphics stand point it makes sense. 2D rendering is the exact same as 3D rendering. The only difference between 2D and 3D is that you're excluding or limiting use of the 3rd dimension.

 

Edit: I should mention that the 2D part of an engine is really more coupled with physics than anything else. The rendering engine it self really has very little to do with it. The only thing that the rendering engine would provide is a 2D lighting algorithm and shadowing (if applicable) which are really just vertex or pixel/fragment shaders. 

CPU: Intel i7 - 5820k @ 4.5GHz, Cooler: Corsair H80i, Motherboard: MSI X99S Gaming 7, RAM: Corsair Vengeance LPX 32GB DDR4 2666MHz CL16,

GPU: ASUS GTX 980 Strix, Case: Corsair 900D, PSU: Corsair AX860i 860W, Keyboard: Logitech G19, Mouse: Corsair M95, Storage: Intel 730 Series 480GB SSD, WD 1.5TB Black

Display: BenQ XL2730Z 2560x1440 144Hz

Link to comment
Share on other sites

Link to post
Share on other sites

I personally would program it for 3D even if you are only using it for 2D since from a computer graphics stand point it makes sense. 2D rendering is the exact same as 3D rendering. The only difference between 2D and 3D is that you're excluding or limiting use of the 3rd dimension.

 

Edit: I should mention that the 2D part of an engine is really more coupled with physics than anything else. The rendering engine it self really has very little to do with it. The only thing that the rendering engine would provide is a 2D lighting algorithm and shadowing (if applicable) which are really just vertex or pixel/fragment shaders. 

Yes for OpenGL everything is in 3D since that's how modern GPUs work, the key difference though is in the physics.

 

As of now 2D is the main focus, 3D may come later.

Link to comment
Share on other sites

Link to post
Share on other sites

I did another 30 min of work on Shark, the input manager is now at a good point, although it's still lacking scroll wheel and joystick support which I'm gonna add tomorrow.

 

I'm not too happy of how it's implemented (or better how it gets initialized) since I originally intended to keep the Input and the Window header files completely independent which as of now it was not possible, it will happen once I have a game manager but for the moment the window constructor is gonna take care of binding the manager to the window.

namespace Shark{	enum Key {		Unknown = -1,		Space = 32,		Apostrophe = 39,		Comma = 44,		Minus,		Period,		Slash,		N0,		N1,		N2,		N3,		N4,		N5,		N6,		N7,		N8,		N9,		Semicolon = 59,		Equal = 61,		A = 65,		B,		C,		D,		E,		F,		G,		H,		I,		J,		K,		L,		M,		N,		O,		P,		Q,		R,		S,		T,		U,		V,		W,		X,		Y,		Z,		LeftBracket,		BackSlash,		RightBracket,		GraveAccent = 96,		Escape = 256,		Enter,		Insert,		Delete,		Right,		Left,		Down,		Up,		PageUp,		PageDown,		Home,		End,		CapsLock = 280,		ScrollLock,		NumLock,		PrintScreen,		Pause,		F1 = 290,		F2,		F3,		F4,		F5,		F6,		F7,		F8,		F9,		F10,		F11,		F12,		Keypad0 = 320,		Keypad1,		Keypad2,		Keypad3,		Keypad4,		Keypad5,		Keypad6,		Keypad7,		Keypad8,		Keypad9,		KeypadDecimal,		KeypadDivide,		KeypadMultiply,		KeypadSubtract,		KeypadAdd,		KeypadEnter,		KeypadEqual,		LeftShift = 340,		LeftControl,		LeftAlt,		RightAlt,		RightSuper,		Menu	};	enum Button {		MouseLeft = 0,		MouseRight,		MouseMiddle,		MouseButton4,		MouseButton5,		MouseButton6,		MouseButton7,		MouseButton8	};	class Input	{	public:		static void BindWindow(GLFWwindow* window);		//Callbacks:		static void KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);		static void CursorPositionCallback(GLFWwindow* window, double xPosition, double yPosition);		static void CursorEnterCallBack(GLFWwindow* window, int entered);		//Keyboard:		static bool IsKeyPressed(Key key);		static bool IsKeyReleased(Key key);		//Mouse:		static Shark::Vec2d GetMousePosition();		static bool IsMouseInsideWindow();		static bool IsButtonPressed(Button button);		static bool IsButtonReleased(Button button);	private:		static GLFWwindow* mWindow;		static bool mIsMouseInside;	};}

It still needs quite a bit of work to make it as I want it although it has already a relatively clean and clear syntax:

		if (Shark::Input::IsKeyPressed(Shark::Key::A) && Shark::Input::IsMouseInsideWindow())		{			std::cout << "'A' key pressed! \n";			Shark::Vec2d mousePos = Shark::Input::GetMousePosition();			std::cout << mousePos.x << " " << mousePos.y << std::endl; 		}

The code above prints on console the mouse position if the mouse is inside the window and when the A key is pressed.

Link to comment
Share on other sites

Link to post
Share on other sites

This is not a full update since I do not have the time to write one but I'd like to share some news, I've done a bit of work, as of now I added:

  • Texture loading
  • Vector / Matrix / Transform classes
  • Sprite class
  • Added a sprite batcher

And made a few changes on the following classes:

  • Window
  • Input
  • Shader

 

When things are a bit more definitive I'm gonna post a more detailed update, and show some of the header files and probably some code.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×