Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Greece4ever committed Mar 16, 2021
2 parents 725c47b + 8bcec05 commit 876fefd
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 8 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@
*.ttf
*.o
*.key
*.crt
*.crt
/windows
*.exe
*.dll
44 changes: 37 additions & 7 deletions gl_mandel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ GLuint compileShader(GLuint type, std::string& src)
return s_id;
}


GLuint createProgram(std::string vertexShader, std::string fragmentShader)
{
GLuint program = glCreateProgram();
Expand Down Expand Up @@ -173,6 +172,7 @@ class c_map {
speed.move = 100.0f;
}


template<typename T>
sf::Vector2f toCartesian(sf::Vector2<T> pixel_pos) {
float centerX = mid.x - offset.x;
Expand Down Expand Up @@ -227,6 +227,7 @@ void initMap() {
oper[sf::Keyboard::S] = [](sf::Clock clock) {world.offset.y += world.speed.move * clock.getElapsedTime().asSeconds(); };

oper[sf::Keyboard::LShift] = [](sf::Clock clock) {
// std::cout << clock.getElapsedTime().asSeconds() << "\n";
world.ZoomIntoPoint(cur ? world.mpos : sf::Vector2i(world.mid.x, world.mid.y), world.speed.zoom * clock.getElapsedTime().asSeconds());
};

Expand Down Expand Up @@ -311,6 +312,8 @@ void main() {
int iter = 0;
const int max_iter = 50;
for (int i=0; i < max_iter; i++) {
a_2 = _z.real * _z.real;
b_2 = _z.imag * _z.imag;
Expand All @@ -328,8 +331,6 @@ void main() {
iter = i;
break;
}
}
float value = float(iter) / float(max_iter);
Expand Down Expand Up @@ -371,6 +372,12 @@ void main() {
FragColor = vec4(sin(smooth_3), sin(smooth_), cos(smooth_2), 1.0);
break;
}
case 6: {
float smooth_ = float(iter) + 1.0 - log(abs(sqrt(a_2 + b_2))) / log(2.0);
vec3 val = 0.5 + 0.5*cos( 3.0 + smooth_*0.15 + vec3(0.0, 0.6, 1.0));
FragColor = vec4( 1.0 * sin(float(iter)) * val, 1);
break;
}
}
}
)glsl";
Expand Down Expand Up @@ -422,6 +429,22 @@ void updateUniforms() {
glUniform1i(algLocation, ALGO);
}

typedef unsigned int uint;

/*
# Windows (x86 and x86_64)
function crun($file) {
$file_=python -c "print('${file}'.rsplit('.', 1)[0])"
g++ -c -O3 "${file_}.cpp" -I C:\Users\progr\Downloads\glew-2.1.0-win32\glew-2.1.0\include -I C:\Users\progr\Downloads\SFML-2.5.1-windows-vc15-32-bit\SFML-2.5.1\include
g++ "${file_}.o" -o "${file_}.exe" -L C:\Users\progr\Downloads\glew-2.1.0\glew-2.1.0\lib -L C:\Users\progr\Downloads\SFML-2.5.1-windows-gcc-7.3.0-mingw-32-bit\SFML-2.5.1\lib -lsfml-graphics -lsfml-window -lsfml-system -lglew32 -lopengl32
$exec="${file_}.exe"
& $exec
}
*/



void parseArgv(int argc, char* argv[]) {
std::map<std::string, bool*> setts = {
Expand Down Expand Up @@ -501,8 +524,11 @@ int main(int argc, char* argv[]) {
sf::Vector2u initial_pos;
bool isFullScreen = false;


GAME_CLOCK.restart();
FPS_CLOCK.restart();


while (running) {
while (window.pollEvent(event))
{
Expand Down Expand Up @@ -534,6 +560,9 @@ int main(int argc, char* argv[]) {
case sf::Keyboard::Num6:
ALGO = 5;
break;
case sf::Keyboard::Num7:
ALGO = 6;
break;
case sf::Keyboard::Enter: {
world.init(world.res.x, world.res.y);
world.rotation = 0;
Expand Down Expand Up @@ -576,7 +605,6 @@ int main(int argc, char* argv[]) {
}

}


glUseProgram(program);
glBindVertexArray(VAO); // this line is new
Expand All @@ -585,7 +613,7 @@ int main(int argc, char* argv[]) {
glDrawArrays(GL_TRIANGLES, 0, 2 * TRIANGLE_VERTICES);

world.mpos = sf::Mouse::getPosition(window);
orbitControl(GAME_CLOCK);


gltSetText(ZOOM_TEXT, to_scientic(world.zoom).c_str() );

Expand All @@ -606,11 +634,13 @@ int main(int argc, char* argv[]) {
}

}


orbitControl(GAME_CLOCK);

frames++;
// Note: On Windows Sf::Clock().restart() must be before window.display();
GAME_CLOCK.restart();
window.display();
GAME_CLOCK.restart();
}
END:
NULL;
Expand Down
4 changes: 4 additions & 0 deletions newton_software.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ function run2 {
*/

// sys/types.h
typedef unsigned int uint;
typedef unsigned char u_char;

#include <SFML/Graphics.hpp>
#include <complex>
#define WIDTH 800
Expand Down

0 comments on commit 876fefd

Please sign in to comment.