Thursday, July 6, 2017

Playing with LWJGL 3

Recap & Update

I have been very busy lately. Got a new job, moved, had a kid, ya know the usual life stuff. I must admit blogging has never been something I have been good at. As is evident by my infrequent posting and sporadic change in directions. I have ultimately discovered that my personal projects that I talk about here, work on for a little while and then abandon are my method of learning. I am not sure whether this is indicative of us as human beings or if its just me. I can never stick with any of my "fun" side projects very long. Perhaps I have not put enough effort in or none have reached a good enough point to be released creating a sense of responsibility to continue working on it.

It is probably one of the reasons some of my more useful programs stay unreleased since I do not want to have to support them and can just use them for the purpose they were created for. For instance I have made at least 3 different tilemap makers, and a small image editor that I use often. Perhaps another reason is that most of them were made with Java Swing and those apps are not particularly fun to modify after a while or pleasing to utilize.

now on to the goodies...

LWJGL 3 and Vertex Arrays

So navigating the options available to different opengl versions is almost nightmareish. So the basics are pretty simple for working with these arrays. You gen the array glGenBuffers you bind the gen'd buffer glBindBuffer. Then you fill the buffer with your data, from using JOGL for this and switching to LWJGL I must say having only to send a FloatBuffer object to the glBufferData call is kind of nice. The included screenshot is rendered from a single vertex array with a single texture array for the 3d geometry. As you can see by the render quads though that is the texture used to render the individual blocks. Yes omg another block game, whatever man its a good way to expirement and learn so sue me if I generated a 100x10x100 block world and culled 76832 blocks that are not open to the sky or surrounded by others leaving 23168 blocks to generate a buffer of 10008576 floats. 


For the geometry I am using 36 vertices per cube (108 floats) and rendering without culling (omg I know, but hey I was debugging). I am using a glsl shader with a simple projection * view * model matrix multiplication to transform the three dimensional coordinates to the camera 2D plane. Currently I am using the nice JOML library for the projection but quaternions for the camera.

Triangle Strips

Now as for the 4 quads...ooops the heading gave it away. They are rendered as triangle strips in a single vertex/texture and index buffer. In order to get them to be rendered as triangle strips I used GL_PRIMITIVE_RESTART setting the restart index glPrimitiveRestartIndex. I had to use 0xFF to set the short constant in java as well as enable the behavior using glEnable(GL_PRIMITIVE_RESTART). There are a lot of optimizations to be made here.


Next I want to get up a decent FPS counter to track the effectiveness of the optimizations. Also put in a number of performance tracking logs.

Thats all for now...

Sunday, September 18, 2016

Green Algae: Dev Update pathfinding

Finding the way

So just implemented a brute-force pathfinding method implementing a basic Flood-Fill (Breadth first search) algorithm. It's wasteful but effective. I plan to improve the pathfinding method to a more practical implementation for use in other areas. It's enough to get started integrating it more abstractly into the basic game world for easier use when characters want to move around. It was pretty fun seeing it work.

Other work

On top of the pathfinding, I reworked the map generation which is hopefully more efficient, reliable, and is making more evenly distributed islands. If you noticed from previous screenshots the islands were all generating on an angle moving to the top-left while generating. Was due to the infamous off by one error, though I was kind of digging the realistic nature of some of the island strips. Perhaps that could be a useful generation permutation in the future.


Where's the build?

I wish I had something playable that you could check out but it's just too rough right now. And I do not have any process for putting together a public release yet. But things are moving along getting some basic AI and decision making system set up is probably my number one priority. Once I have a solid extendable task based system for controlling units assignments it will open the gates to adding all kinds of content. Right now it's just reworking and molding the current code into a more effective structure.


Suggestions welcome

By the way the game concept is very much flexible at this point in time. Not much at all has been solidified. That being said, I am completely open to suggestions or ideas that you may have to help guide some of the gameplay. 

Comments to any update post or to the Project Page are strongly encouraged.

P.S. You can find updates to the Roadmap on the project page. I'll get a description of the game there too since there is no dev version yet.

ttfn