#include #include #include #include "PerlinNoise.hpp" #include "textures.h" #include "mainloop.h" #include "random.h" #include "math.h" int cloud_tex; char* cloud_data; int cloud_dimentions[2] = {100, 100}; double cloud_fade_distance = 25; double cloud_frequency = 32; double cloud_time = 0; double frequency = 10; const siv::PerlinNoise perlin; void clouds_init() { // Setup the cloud data cloud_data = new char[cloud_dimentions[0]*cloud_dimentions[1]*4]; // Fill the clouds with data for(int x=0;x 1) noise = 255; else noise = n*255; // Is the distance greater than 10 if(distance > cloud_dimentions[0]/2.0-cloud_fade_distance) { // Set distance opacity cloud_data[id+3] = 255- (distance-(cloud_dimentions[0]/2.0-cloud_fade_distance))/cloud_fade_distance*255; } else { // Set normal opacity cloud_data[id+3] = 255; } // Set some noise cloud_data[id+0] = noise; cloud_data[id+1] = noise; cloud_data[id+2] = noise; } else { // Set the opacity to zero cloud_data[id+3] = 0; } } } // Load the clouds texture as linear cloud_tex = loadPixels(cloud_data, cloud_dimentions[0], cloud_dimentions[1], 'L', false); // Start rendering the clouds glBegin(GL_QUADS); // Draw the clouds above the player glTexCoord2i(0,0); glVertex3d(-10, 1,-10); glTexCoord2i(1,0); glVertex3d( 10, 1,-10); glTexCoord2i(1,1); glVertex3d( 10, 1, 10); glTexCoord2i(0,1); glVertex3d(-10, 1, 10); // Stop rendering the clouds glEnd(); // Unbind the texture glBindTexture(GL_TEXTURE_2D, cloud_tex); // Clear the depth glClear(GL_DEPTH_BUFFER_BIT); }