Welcome to Jekyll! Fuck Yeah!!
I have a blog again! After having stepped away from the very idea of blogging due to a number of shitty experiences with wordpress I am finally back in the saddle. While I’m putting this together for a school assignment, if this new platform ends up being fun (and it has been so far, despite the fact that I’ve been struggling to understand most of it for hours upon hours) I might actually end up keeping up with it for a while! (Read; 1 post per year at my best.)
For anyone who can manage to be interested in this sort of thing the blogging platform I’m using this time is called Jekyll. You can check it out here but be warned windows isn’t a supported platform (but isn’t too hard to setup via this amazing thingy), and you WILL have to dive into a CLI in order to get the thing working.
Two cool things for the price of one:
One main reason I liked the look of Jekyll is the highlighting of code snippets. This is after all meant to be a ‘programming portfolio website’ whatever the hell that means.
So as an example of that here are some functions out of my shader assignment:
void Terrain::Render(Camera * cam, bool usePerlinNoise, vec3 lightDirection)
{
//----animation timers---------------------
double lastFrame = 0.0;
double currentFrame = (double)glfwGetTime();
double deltaTime = currentFrame - lastFrame;
lastFrame = currentFrame;
//---- bind the deltaTime uniform--------------------------------
glUseProgram(GetProgID());
unsigned int deltaTime_Uniform = glGetUniformLocation(GetProgID(), "deltaTime");
glUniform1f(deltaTime_Uniform, (float)deltaTime);
//---- bind the camera uniforms----------------------------------
unsigned int view_proj_uniform = glGetUniformLocation(GetProgID(), "ProjectionView");
glUniformMatrix4fv(view_proj_uniform, 1, GL_FALSE, (float*)&cam->getProjectionView());
mat4 camTrans = cam->getTransform();
vec3 camPos = (vec3)camTrans[3]; //get pos vector from trans matrix
int loc_cameraPosition = glGetUniformLocation(GetProgID(), "cameraPosition");
glUniform3fv(loc_cameraPosition, 1, (float*)&camPos);
//---- bind the lightdirection uniform----------------------------
int loc_lightdirection = glGetUniformLocation(GetProgID(), "lightDirection");
glUniform3fv(loc_lightdirection, 1, (float*)&lightDirection);
//----bind the world matrix uniform-------------------------------
int loc_worldmat = glGetUniformLocation(GetProgID(), "World");
glUniformMatrix4fv(loc_worldmat, 1, GL_FALSE, (float*)&m_worldTransform);
//----Set Main texture---------------------------------------
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, m_texture_Main);
int loc_grass = glGetUniformLocation(GetProgID(), "MainTex");
glUniform1i(loc_grass, 0);
//-----Set Noise map---------------------------------------------
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, m_texture_Perlin);
int loc_noise = glGetUniformLocation(GetProgID(), "noise_disp");
glUniform1i(loc_noise, 1);
//-----bind our vertex array and call draw elements--------------
unsigned int indexCount = (rows() - 1) * (cols() - 1) * 6;
//glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); // wireframe view
BindVAO();
glDrawElements(GL_TRIANGLES, indexCount, GL_UNSIGNED_INT, nullptr);
}
void Terrain::generateTerrainGrid(unsigned int rows, unsigned int cols)
{
for (unsigned int r = 0; r < rows; r++)
{
for (unsigned int c = 0; c < cols; c++)
{
m_Vertices[r * cols + c].position = vec4((float)c, 0, (float)r, 1);
// create some random colour values - only used in testing
vec3 colour = vec3(randFloat01(), randFloat01(), randFloat01());
m_Vertices[r * cols + c].colour = vec4(colour, 1);
vec3 neighbour1 = vec3((float)c + 1, 0, (float)r);
vec3 neighbour2 = vec3((float)c, 0, (float)r + 1);
vec3 tangent = neighbour1 - m_Vertices[r * cols + c].position.xyz;
vec3 bitangent = neighbour2 - m_Vertices[r * cols + c].position.xyz;
vec3 norm = glm::normalize(glm::cross(tangent, bitangent));
m_Vertices[r * cols + c].normal = vec4(norm.x, norm.y, norm.z, 1);
//------ make texcoords a percentage of grid size
float v = ((float)r / (float)(rows - 1));
float u = ((float)c / (float)(cols - 1));
m_Vertices[r * cols + c].texCoord = vec2(u, v);
}
}
}
So far I’m not super excited about the way the snippets wrap. I think I’ll try to set it up so that the snippet box will just stretch wider to fit the code. The colouring however I do like; have been trying to get it to match visual studio’s colouring and its looking pretty nice to me so far.