Salomonsson.se
Sep 14 2017

Metro Siberia - part 2

Matrices!

Small progress. Started porting over my matrix implementations from haxe. At the moment it actually looks more like C-code than C++.

Been playing a lot with arrays and pointers. Even some memcpy!

Aug 24 2017

Metro Siberia - part 1

intersecting triangles

Started a re-make of my old game Metro Siberia in C++. This is the big plan:

  • Custom rendering methods in it’s own header file
  • Game code is platform independent
  • To start with, only draw lines and simple fills
  • Currently using OpenFrameworks as “backend”, because it is almost zero hassle to get working
  • Plan is to change from OpenFrameworks later on… but we’ll see. At least the structure will allow it.

Currently nothing more than a window that renders the picture above.

Sep 21 2015

Playing with shaders - Part 3

My recent days of night dev has been a bit fragmented due to the fact that I have two newborn kids that require a lot of attention. But whenever I get a spare moment I try to do a little bit of programming, so todays post is actually the result of several short days of work.

First of all I needed to read up on plasma effects again. Haven’t done that in several years, and it turned out I did not fully remember how it was done.
But I did find the excellent tutorial I used several years ago, I highly recommend reading it!!! It is ugly, but very interesting read:
http://lodev.org/cgtutor/

After that I started playing with shaderToy, trying to get a plasma shader running.

And lastly, I implemented that shader into my c++ sandbox project.
Something seems to be a bit off though, it is way to bright. I think it is because the range of each sine/cos-effect (that is merged together to form the plasma) has an incorrect range (not 0-1), or perhaps the area is too zoomed in – but it’s too late to start bug-hunting now so this will have to do for now.

Next up: colors and bitmaps!

Sep 10 2015

Playing with shaders - Part 2

Spent several hours rewriting my setup code to play with shaders.
This is a tutorial that explains it very nice and cleanly: https://open.gl/introduction

I also found a library for loading png files from disc, that don’t require you to invoke make-scripts and all that madness. Just add one .h and one .cpp-file to your project and you’re done! The name is LodePNG. However, did not come far enough to read textures into my shader.

However I managed to get uniforms working, so I could pass the current time to my shader and animate it. I guess that’s something.
That’s all for tonight.

Sep 08 2015

Playing with shaders - Part 1

Since I became a father of two twins, two months ago, I haven’t been able to do much coding at all. Any opportunity I get I have to make sure I do something really small since my work time gets very fragmented.

So I started a c++ project, open a window with an openGL context, and started playing with some really basic shader code. As I said, I didn’t get very far before I had to abort. But it’s something.

Just wanted to save the links to some pages that helped me setting up GLFW on windows in Visual Studio 1013.
http://www.41post.com/5178/programming/opengl-configuring-glfw-and-glew-in-visual-cplusplus-express

http://www.codeincodeblock.com/2013/05/introduction-to-modern-opengl-3x-with.html

https://github.com/smokindinesh/Modern-OpenGL-Series

#version 420 core

out vec4 color;
void main() {
float x = mod(gl_FragCoord.x, 100.0) / 100.0;
float y = mod(gl_FragCoord.y, 100.0) / 100.0;
color = vec4(x,y,1.0,1.0); }
Mar 10 2015

C++ and openGL... creating a window

Took a short break from the Unity project to go into C++land. Decided I wanted to play around a little with some C++ and openGL.

I wanted to develop on my Linux partition (why make it easy for yourself?) but make the code cross platform so I’ll still be able to run it on my windows machine. I decided I wanted to use glfw for all the window, input and timer hassle. It seems light weight, and it is used in this tutorial by my colleague at Isotop (he named the blog series “I’m not a smart man” for some reason. Trust me that it is very far from being true!)

So, did it go smooth? Not at all. I’ve spent a bit over three days trying to figure out how in *#¤% you manage to tell Code::Blocks how to find and link the libraries I want to use. I’ve covered it in a blog post, mostly for my own convenience. Probably full of incorrectness.

Well, now I have a spinning triangle in a window. Time to make something more interesting!

Mar 10 2015

C++ and openGL - Part 2

Continued with the C++ project.
Noticed that the sample code for my triangle was in the older glBegin…glEnd format and changed it to the new opengl 3 standard with shaders, only to get a totally black window.
Turned out you need to add the following code to enable opengl 3 and core profile:

glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);

Which gave me a triangle once more.

The rest of the evening was spent re-reading about matrix operations, and the Model-View-Projection matrices. It was a long time since I last played around with this. You quickly forget if you do not keep working with it.

Mar 09 2015

Linking Libraries in C++ (Linux)

(Disclaimer: I am not an experienced C++ developer, there might be inaccuracies in the following text. I will correct any mistakes I’ll find as I progress. This article is mainly targeting myself for future references).

READ MORE >>
Feb 02 2015

handmade tommy part 1

Since the Christmas Holidays I’ve started watching the fairly new stream Handmade Hero, where we get to follow Casey Muratori, as he builds a game in C, from scratch, without any libraries, and streaming and explaining every single line of code that he writes.

I’ve been struggling with C++ for a while now, but it’s very difficult to find answers when you get into a situation where you need help with a specific problem. There are endless ways of solving the same problem in C and C++, and very often you will get contradictionary or incomplete solutions. And a lot of times people just answering “You shouldn’t do it like that” and then nothing more.

So I enjoy this video stream very much. Casey explains every single line of code he writes. And also sometimes explain other ways to solve a task, and why he prefers the one or the other. He also tackles some very advanced topics, like how to structure your code to get a good foundation for platform independance. And he does it very elegantly.

The stuff he teaches is not something you wouldn’t easily find in any text book, and corresponds to years experience, so I highly recommend watching.

At this point I’ve watched Episode 13, and coded up to episode 5.
I Haven’t anything more interesting to show right now than a simple window, with a simple animated buffer (rendered in software) in Windows. All I have to show for it right now is a simple Screenshot.