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 - LucasM

Pages: [1]
1
General / Re: Issues with tilemap system
« on: January 30, 2022, 07:57:54 pm »
I still have no idea.  What I usually find helps is to step through the code with a debugger … you know what the value of the sprite positions and texture positions should be so see if the values line up in the debugger.  Just google using the debugger in your development environment of choice.  That helps me.  You can even see if the flow path of your program is skipping a loop or if statement or not.
Also I find that I write some code… and miraculously it works.  So then it is the fun times of trying to figure out how it works and rewriting the entire thing again.  Not a fast process.

2
General / Re: Issues with tilemap system
« on: January 29, 2022, 07:34:34 pm »
Are you initializing xIterator, yIterator to zero?

3
SFML projects / Re: Quadtree based Mesh Generator for 2D Surfaces
« on: January 24, 2022, 12:47:26 am »
The quadtree mesh algorithm is kind of similar to the idea posted here: http://homepages.math.uic.edu/~jan/mcs481/quadtrees.pdf

I just divided the quadtree till each line point was on a cell 'wall' so that either a cell would contain no lines, or would contain lines cutting through the whole length of the cell.

Triangulating the empty cells was pretty trivial (just see whether the cell needed steiner points or not and create triangles based on a set of predefined triangulations).

To triangulate the cells cut through by the lines, I used a border walk polygonization strategy that I don't know the name of the algorithm as I came up with it myself (though I doubt I am the first to do so).  I uploaded a pic on github to explain that algorithm better.  https://raw.githubusercontent.com/LucasM127/QuadTreeTesselation/master/Pics/BorderWalk.jpeg

The whole point of using a quadtree vs a regular grid was to have different sized squares for variety and also to save on number of triangles rendered.  The look is also a bit 'different' than delaunay.  That's all.

4
SFML projects / Quadtree based Mesh Generator for 2D Surfaces
« on: January 22, 2022, 06:50:05 am »
Made a quadtree based mesh renderer for 2d surfaces.  You can use it for procedural terrain generation especially if you want a more blocky grid type look, or even if not.  I posted the source at https://github.com/LucasM127/QuadTreeTesselation  And made a decent looking readme there so I won't type too much more here.  Made it while developing some ideas I had for procedural terrain generation (in 2d) to make a more interesting looking surface.
I came up with the idea for triangulating convex polygons that had been sliced through on my own though so that was neat and motivated me to develop this idea further.

The examples are made with sfml.  It is not 100% finished but I don't think anything ever will be.  Not too many other examples of this that I could find on github.  Most were more oriented to making a grid for finite element analysis than for creating distinct surface regions.

The algorithm itself is not based on sfml however.

The codes not polished but I've pretty much given up on having perfect code after a while.  It gets better, but never great.

Hopefully someone may find it interesting.

5
Graphics / Re: Understanding how to create X type of Shader?
« on: January 04, 2022, 06:18:59 am »
I found some examples online by googling webgl shaders… webgl-shaders.com had a rain effect in the fragment shader.  The other site comes to mind is shadertoy not that I’ve played much with shaders personally.

6
SFML projects / Re: Screenshot Thread
« on: January 03, 2022, 01:01:13 am »
Finally figured out a tesselation algorithm based on quadtrees and integer (discrete) coordinates.  Each vertex was mapped with a random value for color.  Triangles (clockwise) to the right of the polyline are more white.

7
I have absolutely no idea.  Just make sure your bounds are set properly?  Looks like accessing data that has not been set. Either out of bounds, or you are creating a vector slightly larger than your map data and the last elements are not being initialized in any logical (to you) order.
ie. in the example if doing a vector resize, resizing bigger than needed by 2 rows.  So the renderer tries to draw two rows of unknown values.
Are you passing the right height value to load?  If you are using the same code as the example that could be it.

Edit.  Just noticed that you attached code samples, so ignore the last line.  Still have no idea.  Could be something to do with the rendering code or map loading code.

8
Graphics / Re: Struggling with some rotations
« on: April 24, 2021, 04:16:25 am »
Try using a rotational speed factor.  Change in rotation = rotationalSpeed * deltaTick towards the new rotation angle.  Just basic.  Could get fancy with inertias and acceleration and that but I think that would be overkill.

9
SFML projects / Re: Screenshot Thread
« on: March 13, 2021, 06:06:28 am »
Not necessarily an sfml project but using it for visualization in this instance.  Tilemap interpretation of environmentally sensitive  lindenmayer system strings.  Should kind of look like vines.

10
SFML projects / Pentomino Game
« on: September 19, 2020, 07:42:42 pm »
Basic pentomino game with several levels.

Can find it at https://lucasm127.itch.io/pentominos (windows compiled)
Source at https://github.com/LucasM127/Pentominos

Spent enough time on it that I'll call it done for now.

Keyboard/mouse input.


11
Feature requests / Set Window Position on Creation
« on: July 04, 2020, 05:42:36 am »
There is no option to set the sf::Window position on creation.  Have to create the window, then set its position which causes the window to 'jump'.  Seems to be coded to position in the middle of the screen according to source.  Shouldn't be too difficult to overload the constructor to optionally take in parameters for window location.

Thanks.

12
Window / Re: Controlling focus with multiple windows
« on: June 22, 2020, 12:13:24 am »
I figured out some basic code for a modal window loop.  Seemed to work ok, as was trying to figure it out and found this thread.  If it helps?

#include <SFML/Graphics.hpp>

/*
https://stackoverflow.com/questions/26741841/how-does-a-modal-dialogs-message-pump-interact-with-the-main-application-messag
They run on the same thread. The modal dialog spawns a nested message loop.
Both the nested message loop and the main application's message loop (or rather message handlers) are siamese twins in crime:
If one doesn't play by the rules, the respective other will suffer as well. – IInspectable
*/


//call from child
void mainWinMSGHandle(sf::Window &window, sf::Window &child);

void createPopUpWindow(sf::Window *parent, int num)
{
    sf::RenderWindow popUpWindow(sf::VideoMode(320,240), "HI " + std::to_string(num), sf::Style::Close);
    popUpWindow.setPosition(parent->getPosition() + sf::Vector2i(100,100));
    sf::Event event;
    while (popUpWindow.isOpen())
    {
        popUpWindow.clear(sf::Color::Cyan);
        popUpWindow.display();

        while(popUpWindow.pollEvent(event))
     {
        if(event.type == sf::Event::Closed)
            popUpWindow.close();
        if(event.type == sf::Event::LostFocus)
        {
            if(parent->hasFocus())
                popUpWindow.requestFocus();
        }
      }
        mainWinMSGHandle(*parent, popUpWindow);
       
        sf::sleep(sf::milliseconds(1));
    }

}

//child message loop blocking main window message loop so need to handle main from child
void mainWinMSGHandle(sf::Window &window, sf::Window &child)
{
    sf::Event event;
    while(window.pollEvent(event))
    {
    if(event.type == sf::Event::Closed)
    {
        child.close();
        window.close();
    }
    if(event.type == sf::Event::GainedFocus)
    {
        child.requestFocus();
    }
    }
}

int main()
{
    sf::RenderWindow window(sf::VideoMode(800,600),"Main Window");

    sf::Event event;
    int n = 0;

    while (window.isOpen())
    {
        window.clear(sf::Color::Magenta);
        window.display();

        window.waitEvent(event);
       
        if(event.type == sf::Event::Closed)
        {
            window.close();
        }
        if(event.type == sf::Event::MouseButtonPressed)
        {
            createPopUpWindow(&window, n++);
        }
    }

    return 0;
}
 

13
General / Linking to dll files windows separate file
« on: February 28, 2017, 05:12:09 pm »
It is a pain to always have to copy the dlls over to where my test sfml programs are in windows.  I dont know much about it, but is there some way, such as writing a manifest file or having the libraries load in dynamically at run time with a call to loadlibrary so i can just refer to the dll location as is installed in the sfml folder.  Using the filepath.  (When i hit rebuild project it erases the dlls).  Without changing PATH.

Dont know anything about manifests but from what i have read it seems to be an answer from what i understood.

Static linking might help too but asks for jpeg.lib which i dont have installed (I dont think)
Not sure which library that is. (Graphics module)

Tdm-gcc compiler... newer version that can use c++11 features.  5.3 off the top of my head.  Using codelite.  (Vc++ community installed though somewhat overly complicated as an ide for me)

Thank you.

Pages: [1]
anything