Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Mortal

Pages: [1] 2 3 ... 17
1
General / Re: Help with basic fragment-shadered full-screen sprite
« on: February 12, 2019, 06:25:58 pm »
hi

no need to use sprite and texture to draw fragment shader. just use sf::RectangleShape to get fullscreen to draw on it. also, no need to provide the vertex shader. like so:

#include <SFML/Graphics.hpp>


#define GLSL120(src) "#version 120 core\n" #src

static const char* frag = GLSL120(

uniform float time;
uniform vec2 resolution;

float h(float i) {
        return fract(pow(3., sqrt(i / 2.)));
}

void main(void) {

        vec2 p = gl_FragCoord.xy*2. - resolution;

        float a = floor(degrees(4. + atan(p.y, p.x))*2.) / 4.;

        float d = pow(2., -10.*fract(0.1*time*(h(a + .5)*-.1 - .1) - h(a)*1000.));

        if (abs(length(p) - d*length(resolution)) < d*35.) {
                gl_FragColor = vec4(d*(h(a + .5)*3.));
        }
        else {
                gl_FragColor = vec4(0.);
        }
}

);

int main()
{
        sf::RenderWindow window({ 800, 600 }, "SFML Shader Example");
        window.setMouseCursorVisible(false);

        sf::RectangleShape fullscreen({ 800, 600 });
        sf::Shader shader;
        if (!shader.loadFromMemory(frag, sf::Shader::Fragment))
                return -1;

        shader.setUniform("resolution", sf::Vector2f({ 800, 600 }));

        sf::Clock clock;
        while (window.isOpen()) {
                sf::Event event;
                while (window.pollEvent(event)) {
                        if (event.type == sf::Event::Closed)
                                window.close();
                }

                shader.setUniform("time", clock.getElapsedTime().asSeconds());

                window.clear();
                window.draw(fullscreen, &shader);
                window.display();
        }
}

2
Graphics / Re: Problem with drawing from a vector.
« on: January 29, 2019, 02:18:04 pm »
sfml does't copy the transform if you want sorting them, so you have to swap the positions too like so:
if (rods.at(j).getSize().y > rods.at(j + 1).getSize().y)
{
        swap(rods[j], rods[j + 1]);
        auto p1 = rods[j].getPosition();
        auto p2 = rods[j + 1].getPosition();
        rods[j].setPosition(p2);
        rods[j + 1].setPosition(p1);
        swapped = true;
}

3
General / Re: Pause
« on: December 27, 2017, 01:20:08 pm »
to make a pause for your game you need to skip the update section in your game loop

here a pseudo code:

while (mWindow.isOpen())
{
        processEvents();
        if (!pause) {
                update();
        }
        render();
}

4
SFML projects / Re: Tic Tac Toe
« on: December 27, 2017, 12:55:48 pm »
i'm back to my first GUI game that i made few years ago. i implement minimax algorithm to improve AI now the game become unbeatable  :P

source code: https://gist.github.com/MORTAL2000/c8014042a65985a568b5dd7c2f635cab


5
SFML projects / Re: Screenshot Thread
« on: June 07, 2017, 08:27:59 pm »
inspired from Hapax works .. i made a matrix rains in 3D  ;D ;D


6
SFML projects / Re: Tower Defence
« on: May 15, 2017, 05:43:12 am »
thanks for compliment. but i'm still a beginner in both C++/OpenGL. all i have done is adding sfml extend (window creation and input handling) to that engine.

i would recommend SFML Game Development book. if you were interesting to learn how to make 2D/3D game engine from scratch.

7
SFML projects / Re: Tower Defence
« on: May 13, 2017, 11:05:09 am »
thanks roccio  :)

8
SFML projects / Re: Tower Defence
« on: May 13, 2017, 08:07:00 am »
update
fixed minor bug within sfml input. event mouse position gives sometime wrong values.

i've included exe file.here link if someone wants to try it.

9
SFML projects / Tower Defence
« on: May 11, 2017, 08:59:27 pm »
i was planning to begin with 3D game as my first 3D project, but i have found an old game called Starports when i was looking for assets to make simple tower defence. but unfortunately it doesn't support SFML.

i wrote SFML extension to that engine. since it does exactly what i want to achieve for now.

here game-play video:


EXE file

10
SFML projects / Re: Screenshot Thread
« on: May 06, 2017, 12:19:01 pm »
thanks eXpl0it3r  :)

my plan to create simple 3D game like space-shooter or perhaps tower defense. haven't decided yet.
all i had done so far are implemented 3D render engine and basic collusion detection as first step to to go with 3D physics.

11
SFML projects / Re: Screenshot Thread
« on: May 06, 2017, 11:25:58 am »
finally, i implemented oriented bounding box (OBB) correctly.

here test

12
SFML projects / Re: "Our Dear Paper Fighters" - Top down shooter
« on: April 17, 2017, 08:10:49 pm »
awesome, i really like your work.

13
General / Re: Inverting velocity to bounce an object (along x-axis)
« on: April 15, 2017, 09:57:04 pm »
i think you need to check this link for 2D physics.
http://trederia.blogspot.co.uk/2016/02/2d-physics-101-pong.html

14
Graphics / Re: How to change pixels on a big map
« on: April 14, 2017, 06:36:58 pm »
first think comes to my mind is using polygon shape for each country. did you consider it?

15
SFML projects / Re: experiment on Terrains
« on: April 13, 2017, 02:52:19 pm »
yes,they used Geomipmapping for load of details which used real-time block-based terrain rendering algorithm as alternative of Quadtree rendering to reduce CPU processing time which is a common bottleneck in level of detail approaches to terrain rendering. here link to original paper of Geomipmapping https://www.flipcode.com/archives/article_geomipmaps.pdf

i've created grid 4096x4096 to compare with brutal force approach. the result is noticeable. i have made video to demonstrate the Geomipmapping in action.

Pages: [1] 2 3 ... 17
anything