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.


Topics - achpile

Pages: [1] 2
1
Audio / [SOLVED, i am idiot] Music stops playing sometimes
« on: January 20, 2021, 02:48:35 pm »
Good day. I've encountered a weird bug, which I have no idea how to reproduce in "small example"...
It happened in windows (built with mingw 32bit).

So I start music like this:

track->stop();
track->openFromFile(...);
track->setLoop(loop);
track->play();
track->setPlayingOffset(cache->musics[current]);
 

After this I added the log:
Loop = true
Offset = 4739
Length = 96000
 

So the output is getLoop(), getPlayingOffset() and getDuration().

And sometimes it just stops playing... I added a log:

Track loop = true
Offset = 0
Length = 96000
Status = Stopped
 

Have anyone had this bug, or have any ideas what could cause it? Thanks

2
Graphics / OSX - failed to compile fragment shader
« on: December 29, 2020, 09:32:16 am »
Good day. I'm not expirienced OSX user, so have no idea about it.

I'm getting this error:
Failed to compile fragment shader:
ERROR: 0:1: 'f' : syntax error: syntax error

Failed to compile fragment shader:
ERROR: 0:1: 'f' : syntax error: syntax error

Failed to compile fragment shader:
ERROR: 0:1: 'f' : syntax error: syntax error
 

SFML version is 2.5.1

There's no such error on Linux 32/64 nor Windows 32/64

Shaders are:

#define SHADER_INVERT                                         \
        "uniform sampler2D texture;                             " \
        "                                                       " \
        "void main() {                                          " \
        "    vec4 pixel = texture2D(texture, gl_TexCoord[0].xy);" \
        "                                                       " \
        "    pixel.r = 1.0f - pixel.r;                          " \
        "    pixel.g = 1.0f - pixel.g;                          " \
        "    pixel.b = 1.0f - pixel.b;                          " \
        "                                                       " \
        "    gl_FragColor = pixel;                              " \
        "}                                                      "



#define SHADER_WHITE                                          \
        "uniform sampler2D texture;                             " \
        "                                                       " \
        "void main() {                                          " \
        "    vec4 pixel = texture2D(texture, gl_TexCoord[0].xy);" \
        "                                                       " \
        "    pixel.r = 1.0f;                                    " \
        "    pixel.g = 1.0f;                                    " \
        "    pixel.b = 1.0f;                                    " \
        "                                                       " \
        "    gl_FragColor = pixel;                              " \
        "}                                                      "



#define SHADER_GREY                                           \
        "uniform sampler2D texture;                             " \
        "                                                       " \
        "void main() {                                          " \
        "    vec4 pixel = texture2D(texture, gl_TexCoord[0].xy);" \
        "                                                       " \
        "    gl_FragColor.r = (pixel.r+pixel.g+pixel.b) / 3.0f; " \
        "    gl_FragColor.g = gl_FragColor.r;                   " \
        "    gl_FragColor.b = gl_FragColor.r;                   " \
        "    gl_FragColor.a = pixel.a;                          " \
        "}                                                      "

 

Loading code:
        shaders.white.loadFromMemory (SHADER_WHITE , sf::Shader::Fragment);
        shaders.grey.loadFromMemory  (SHADER_GREY  , sf::Shader::Fragment);
        shaders.invert.loadFromMemory(SHADER_INVERT, sf::Shader::Fragment);
 

Bonus question bonus not related to graphics, but related to Mac OS X:
After app start i got this:
"We got a keyboard without any keys (1)"

I use Mac mini with standart usb keyboard attached

3
SFML projects / Dispersio 3
« on: April 09, 2019, 01:00:37 pm »
Actually it's 3, but i renamed the 2 to 3, so it's 2 now  ;D
So i decided to take a short break on my previous project and i will probably release this one earlier - so I had to rename them  :D

This game will be very similar to the first one, but instead of different abilities on each level you will face different obstacles. I hope to make it as good as first one - and same hard as well  ;D

http://www.youtube.com/watch?v=fSVzTsDdxMg

4
Graphics / sf::Rect
« on: September 10, 2018, 08:24:07 pm »
Hey guys! Just got an issue with rect class.... Can someone explain this please?
Commit:

commit 082a928555125e37cc52a80c11cf286f0b03dee5
Author: LaurentGom <LaurentGom@4e206d99-4929-0410-ac5d-dfc041789085>
Date:   Fri Apr 9 13:04:49 2010 +0000

    *important* sf::Rect now uses Width/Height instead of Right/Bottom
    Removed Offset, GetSize and GetCenter functions from sf::Rect
    Added a sf::Rect constructor taking two Vector2 parameters
    Updated the API documentation of the sf::Rect class
 

 template <typename T>
 bool Rect<T>::Contains(T x, T y) const
 {
-    return (x >= Left) && (x <= Right) && (y >= Top) && (y <= Bottom);
+    return (x >= Left) && (x < Left + Width) && (y >= Top) && (y < Top + Height);
 }
 

Why changed "<=" to "<"?

5
SFML projects / Neural Network + Genetic Algorithm
« on: December 06, 2017, 03:23:09 pm »
After watching a lot of videos on YouTube I had some fun playing with neural networks + genetic algorithm. Don't know what else to say  :D

Source code: https://github.com/achpile/neural

http://www.youtube.com/watch?v=cAr90JQVxaI

http://www.youtube.com/watch?v=oeJ7Gw_vO_8

6
Graphics / Mac OS X - High Sierra - RenderTexture::clear
« on: November 13, 2017, 03:58:50 pm »
Hey guys! I have some troubles with clearing render textures (or may be RenderWindow). And made some investigations. Here's the code:

#include "include/SFML/Graphics.hpp"

int main() {
        sf::RenderWindow app(sf::VideoMode(400,400), "test");
        sf::RectangleShape a(sf::Vector2f(10,10)), b(sf::Vector2f(1,1));

        sf::RenderTexture tex;
        sf::Sprite spr;

        tex.create(400,400);
        tex.setActive();
        tex.clear(sf::Color(0,0,0,0));
        int pos = 10;
        spr.setTexture(tex.getTexture());

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

                pos += 1;
                a.setPosition(sf::Vector2f(pos, 10));

                app.clear();

                // Uncomment this to fix
                //app.draw(b);

                tex.draw(a);
                tex.display();
                app.draw(spr);

                tex.clear();
                app.display();
        }
}

 

If there's no draw calls on RenderWindow except the one with drawing RenderTexture it leads to some artifacts.
I attached the image from my game and from the example. As you can see - there's kinda trail, but it is not the same as without "clear" call.

And there were no such issues before High Sierra update.

7
SFML website / SFMLProjects
« on: November 04, 2017, 12:21:02 pm »
I can't remember if i saw a topic here or just was talking about it with Exploiter long ago, but maybe it's a good idea to provide a link to sfmlprojects.org at Community page.  :)

8
Graphics / sf::RenderTexture without 'display' call.
« on: October 30, 2017, 02:21:56 pm »
Don't know if it's a bug, but if I don't call 'display' function - render texture draws upside down.

#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>

int main() {
        sf::RenderWindow window(sf::VideoMode(800, 600), "My window");
        sf::Event event;
        sf::Font font;
        sf::Text text;
        sf::RectangleShape shape;
        sf::Sprite spr;
        sf::RenderTexture tex;

        font.loadFromFile("font.ttf");

        text.setFont(font);
        text.setString("HELLO");
        text.setCharacterSize(200);
        text.setFillColor(sf::Color::Black);

        shape.setSize(sf::Vector2f(100,100));
        shape.setPosition(100, 300);
        shape.setFillColor(sf::Color::Black);

        tex.create(800,600);
        tex.setActive(true);

        tex.clear(sf::Color::White);
        tex.draw(text);
        tex.draw(shape);
        //tex.display();

        spr.setTexture(tex.getTexture());

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

                window.clear(sf::Color::White);
                window.draw(spr);
                window.display();
        }

        return 0;
}
 

1.png - with 'display' call
2.png - without

9
Graphics / sf::Text and Outline
« on: October 24, 2017, 10:30:38 am »
Hello  :) Is there a way to make outline only outer space with text? As you can see it works fine with shapes, but text outlined inside and outside.

#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>

int main() {
        sf::RenderWindow window(sf::VideoMode(800, 600), "My window");
        sf::Event event;
        sf::Font font;
        sf::Text text;
        sf::RectangleShape shape;

        font.loadFromFile("font.ttf");

        text.setFont(font);
        text.setString("HELLO");
        text.setCharacterSize(200);
        text.setFillColor(sf::Color(255,0,0,128));
        text.setOutlineColor(sf::Color(0,0,0,128));
        text.setOutlineThickness(5);

        shape.setSize(sf::Vector2f(100,100));
        shape.setPosition(100, 300);
        shape.setFillColor(sf::Color(255,0,0,128));
        shape.setOutlineColor(sf::Color(0,0,0,128));
        shape.setOutlineThickness(5);

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

                window.clear(sf::Color::White);
                window.draw(text);
                window.draw(shape);
                window.display();
        }

        return 0;
}
 


10
SFML projects / AchBall is now available on Steam
« on: September 27, 2017, 06:38:19 pm »
I decided to remaster a game I made 7-8 years ago :D Gameplay is very simple - you must hit the target by the ball. Each wall hit gives you 10 points. Yeah, that's all ;D

To make gameplay more interesting there are different achievements, leaderboards and some different things on stages, like moving platforms, fragile blocks etc.

Steam store page: http://store.steampowered.com/app/739180

http://www.youtube.com/watch?v=CUZGqqZisF8

11
SFML projects / Dispersio 2
« on: June 28, 2017, 02:38:20 pm »
Engine is almost finished, so here's a tech-demo :) Now it's time to start making content: locations, enemies, bosses etc. Probably I will post here screenshots later :)

http://www.youtube.com/watch?v=PRJwGcadf_U

12
SFML projects / Dispersio is now available on Steam!
« on: June 16, 2016, 11:17:29 pm »
Dispersio is now available on steam!

http://store.steampowered.com/app/563180

Story
After a disastrous geological experiment, the Earth was ruptured into dozens of asteroids, some of which hold remnants of what humanity had left behind. Many space travelers explore these asteroids in search of treasures and ancient relics. It took approximately twenty years to gather information about the location of the mysterious ancient crystal, which will give arcane power to whoever first obtains it - and so our brave hero seizes the chance to go on a perilous adventure and be the one to unearth the crystal. Who knows where it will lead?

Gameplay
Dispersio is a retro-styled action platformer. As you progress through the game, you will have to use and combine special abilities, such as dashing, wall-jumping and more.

There's even a hard mode for hardcore players. Can you beat each level without dying?

Features
  • Precisely tuned platforming mechanics
  • Interesting, detailed and challenging maps
  • 7 different abilities
  • Lots of secrets
  • A great unique soundtracks
  • Achievements
  • Gamepad support

http://www.youtube.com/watch?v=Jx254GyFb5I

Greenlight message:
(click to show/hide)

Old message:
(click to show/hide)

13
Feature requests / More Events
« on: April 18, 2016, 01:39:26 pm »
What about to add some more events? For example: DROPFILES and HOTKEY.

14
SFML projects / Timer for speedruns "Stopwatch"
« on: April 18, 2016, 12:02:09 am »
Made it just for one day  :D Coding speedrun  ;D

Well, after browsing web for a good speedrun timer didn't find anything nice for linux and decided to write my own.

More detailed description can be found here: https://github.com/achpile/asplit/releases/tag/v1.0-rc1


15
Window / Joystick axes
« on: April 21, 2015, 10:07:06 am »
This is the strangest thing I ever seen. I have a joystick "EXEQ Spitfire" and tested it on 4 different systems:

  • Linux 32bit laptop ASUS X200CA
  • Linux 64bit (Ubuntu 14.10) at home
  • WinXP 32bit at home
  • Linux 64bit (Ubuntu 14.10) at work

All the linux systems throw me two messages to console:
Unable to get joystick attribute. Could not find USB device for joystick at index 0.
Unable to get joystick attribute. Could not find USB device for joystick at index 0.
 

This code:
printf("[%u : %u] %s\n", sf::Joystick::getIdentification(0).vendorId,
    sf::Joystick::getIdentification(0).productId,
    sf::Joystick::getIdentification(0).name.toAnsiString().c_str());
 

Gives me:
[0 : 0] Microntek              USB Joystick
 

Well, about the problem:

Linux 64bit (Ubuntu 14.10) at work works properly.

WinXP 32bit at home gives me (-0.78, -0.78) on X and Y axes when nothing is pressed.

Linux 32bit on laptop and Linux 64bit (Ubuntu 14.10) at home got same results on following sequence:
1. I connect joystick
2. Run application
3. Get axes positions (-100, -100) on X and Y
4. Pressing D-pad on X and Y
5. Releasing D-pad and got (0, 0)
6. Run application again
7. Get axes positions (0, 0) on X and Y

So the initial state is wrong.

Can anyone help me, what could be the reason of this strange behavior?  :-\

Tested on this:

#include <SFML/Window.hpp>
#include <stdio.h>
#include <unistd.h>

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

        while (window.isOpen()) {
                sf::Event event;

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

                printf("(%3.2f, %3.2f)\n", sf::Joystick::getAxisPosition(0, sf::Joystick::X),
                                           sf::Joystick::getAxisPosition(0, sf::Joystick::Y));
        }
        return 0;
}
 

gcc main.cpp -o test -lsfml-window -lsfml-system -lstdc++

Pages: [1] 2
anything