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 4 ... 19
SFML projects / practice exercises on 2D/3D Physics - SAT algorithm
« on: March 16, 2020, 08:16:55 pm »
This is going to be a bit longer thread dedicated to SAT algorithm and its MTV and SH clipping[for impulse response].

here a simple demo to test the projection of the quad/box onto an arbitrary axis.

every single time i thought that i grasp the dot-product math-vector-entity i end up being was actually fooling myself. I have had to study this elusive entity in depth for once and for good. and here the introduction demo of incoming demos regarding the SAT algorithm.


I'm glad it helped what you were looking for.

by the way, do you know what is CLR for C++? It seems to have additional libraries of .NET (?), which are not in C++, but they are easy, - graphics objects etc. But I was unable to make them work with very same source (if I make a project to support CLR). have no idea why.
No i didn't work with CLP

Also, I want to know is the "console window" and any other window in Windows basically same or not from point of view of graphics - how it is rendered? I mean, maybe all these graphical modes are just nothing but same text-consoles, but with text-cursor hidden, and all (most) control is transferred to mouse-input...?
In general, the console screen “black box” window is not made for graphics, true it’s tiled grid, it can do some basic drawing shapes like square or rectangle,  but it can’t draw complex shapes like circle or capsule or even a polygon.

It’s better to use a windows base app to draw those shapes, in a window environment there are many graphics libraries, like Win32 GDI, Win32 GDI+ and many more. Or even more better, you may choose a multi-platformer graphic library like SFML of-course. This will allow your application to run in every platform window, mac, linux..etc

true, it failed with VS2019. it complains about missing “std::string” file in “Cosole.h” file, i added it it runs on my PC [windows 10 / VS-2019].

i updated the main repo at github, check it out.

Yes you change the image or upload the txt file to “Image::loadFromFile()”. This project was made when i was learning the drawing of Ascii arts from this site: https://www.randygaul.net/2012/07/03/windows-console-game-asciiengine/

SFML does not have ASCII version, i made a win32 console library that has similar code structure and design as SFML while ago.
here the link: https://github.com/MORTAL2000/MSLIB

SFML projects / Re: SAT collision algorithm
« on: March 12, 2020, 08:29:42 am »
excellent, nice work,  :)

i can't give you any useful hint about MTV with SAT, i never knew about MTV of SAT, from what i have learned on those subjects, SAT mostly were introduced for detecting collision. no one really used SAT for more than that. you just unlocked a new level of collision detection worlds. ;D

thanks for sharing.

really i like it, gotta dig deep with those projection based collision detection methods.

SFML projects / Re: Screenshot Thread
« on: March 05, 2020, 04:02:35 pm »
i just found an old wishlist note that i made it to myself when i was learning C++/SFML/English-Language dated on 2015 lol.
i couldn't imagine how fast the days passing.

one of which is to make an analog clock. i got time to work on this and fulfil my old wishes. i recently had another example as well for simple and naive rope simulation. i decided to share them with you guys.

here the analog clock example:

still working on the analog clock, i think it is a bit nicer this way, isn't it?

here the rope semulation example:

Graphics / Re: Simple Isometric tileMAP but ugly result
« on: February 23, 2020, 05:32:39 pm »
i had similar problem with this, it turns out that it is happened due to float point precision problem.

i have solved it here in this link: https://en.sfml-dev.org/forums/index.php?topic=21048.msg150470#msg150470

Graphics / Re: GL_INVALID_OPERATION messages pop up when loading textures.
« on: February 23, 2020, 05:16:47 pm »
what SFML version do you use? i remember that the "glFlush()" were removed!!.

also, there is a potential bug in "loadTextures()", the sf::Texture object has tobe inside the nested for-loops. try to change it and see what gonna happen.

SFML projects / Titanion Clone
« on: February 22, 2020, 09:41:29 pm »
Remake of an old game called Titanion, it's a strike down super high-velocity swooping insects game-like somehow similar to the famous Space Invaders. i have been working on this game for sometime, it is part of my 3D OpenGL FrameWork Demos,

i added colours, text and sounds, no textures involved in this game ;D, this is one of many reasons, why i chose to spend sometime to re-create it from scratch.

here game-play demo:

General / Re: basic text box
« on: February 15, 2020, 10:01:30 pm »
excellent point Laurent.
yes, indeed, it's quite useful, gotta update my code example.

General / Re: basic text box
« on: February 15, 2020, 07:51:53 am »
The for-loop will tell you all information you need, the printable ASCII characters and its index position For example:If i run the for-loop in my PC it will print something like this:

30 �
31 �
33 !
34 "
35 #
36 $
37 %
122 z
123 {
124 |
125 }
126 ~
128 �
129 �

From the output, we can easily now detect all of printable chars and its indices which is clearly the printable chars start from index 32 upto 127. now, we need to add this boundary check to SFML event-loop:

//if (event.text.unicode >= 32 && event.text.unicode <= 127)
if (std::isprint(event.text.unicode)) // thanks to Laurent
    input_text += event.text.unicode;

Don't worry about if user press BackSpace or Return/Enter keys, sf::Text will take care for these inputs internally, just supply the string to sf::Text::setString with escape char in event-loop:

if (event.key.code == sf::Keyboard::BackSpace) {
    if (!input_text.empty())
        input_text.pop_back();// as Laurent pointed out
if (event.key.code == sf::Keyboard::Return){
        input_text += '\n';

That's it, we have accomplished a minimal text editor.

I added a simple blinking effect to “cursor”. It was a part of my early demos when I was working out with the SFML library. ;D

Here the complete source source:
#include <SFML/Graphics.hpp>
#include <locale>

int main()
    sf::RenderWindow window({ 640 ,480 }, "test");

    std::string input_text;
    sf::Font font;
    sf::Text text("", font);

    sf::Clock clock;

    while (window.isOpen())
        sf::Event event;
        while (window.pollEvent(event))
            if (event.type == sf::Event::Closed)
            else if (event.type == sf::Event::TextEntered) {
                if (std::isprint(event.text.unicode))
                    input_text += event.text.unicode;
            else if (event.type == sf::Event::KeyPressed) {
                if (event.key.code == sf::Keyboard::BackSpace) {
                    if (!input_text.empty())
                if (event.key.code == sf::Keyboard::Return) {
                        input_text += '\n';

        static sf::Time text_effect_time;
        static bool show_cursor;

        text_effect_time += clock.restart();

        if (text_effect_time >= sf::seconds(0.5f))
            show_cursor = !show_cursor;
            text_effect_time = sf::Time::Zero;

        text.setString(input_text + (show_cursor ? '_' : ' '));


General / Re: basic text box
« on: February 14, 2020, 08:00:12 am »
it quite easy to retrieve all ASCII characters programmatically, just run a for-loop to print out all characters that range from 0 to 255. unless i misunderstood what you are trying to achieve.

for (int i = 0; i < 255; i++)
    std::cout << i << ' ' << (char)i << '\n';

Graphics / Re: Inherit from sf::Shape (sf::CircleShape)
« on: February 05, 2020, 05:28:57 am »
your code looks fine, there is no problem with it, but, making the asteroid's radius 10 pixels is quite small. give it higher value like 200 or 300 pixels, it's okay, also set the asteroid's position at center of screen for debugging, to make sure,the asteroid is visible and it's lay within viewport of window. also, make sure of the texture rect is mapped to a valid spot in that texture, means it does't picked transparent or color similar to window's background color or perhaps, the texture itself is corrupted or fully transparent. if that the case then change it with a valid texture or better, use "sf::Image" to create an image with opaque or solid color like "sf::Color::Red". and feed it to the texture update method "sf::Texture::update()". check the official documentation for texture update method.

General / Re: Noise when using threads
« on: February 02, 2020, 04:30:26 pm »
hmm, interesting i haven't thought about drawing the pixels as points with sf::VertexArray, i think this worth testing. gotta make my own mandelbrot demo  ;D

General / Re: Noise when using threads
« on: February 01, 2020, 01:01:40 pm »
since all threads using same resource you need to lock the current thread by using "std::mutex" or even better "std::lock_guard<std::mutex>".

to fix the processor usage consumed, you have to make the current active thread to sleep for sometime. there is a function already made for this purpose: "std::this_thread::sleep_for(std::chrono::microseconds(1))"

in general sf::Image was not made to do a heavy image processing, alternatively you you may look for computing shader and indirect draw commands, it is available in both opengl and D3D.
it will help you if you need to boost your application further.

this is what i know as common advises maybe there is better way to handle the image processing efficiently that i'm not aware of.

Pages: 1 [2] 3 4 ... 19