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

Pages: [1] 2 3
1
General / Re: White square issue after accesing resource from std::map
« on: October 05, 2016, 09:19:09 pm »
In your first example

        void createGrassTitle( void ) {
            sf::Texture texture;
            texture.loadFromFile("media/textures/titles.png"); //one texture for simplicity

            LocalTitle title;
            title.create();
            title.setTexture( texture ); //YOU GIVE THE FUNCTION A REFERENCE, but texture will be destroyed when this function returns

            titles[LocalTitleType::Grass] = title;
        } //texture gets destroyed here! Now there is "no more texture in memory"...
 

Your texture is just available inside the function. After leaving the scope, it get's destroyed.

In your 2nd example:
void loadTextures( void ) {
            sf::Texture texture;
            texture.loadFromFile("title.bmp");
            textures[LocalTitleType::Grass] = texture; //YOUR texture will live on beyond the scope.
        }

//......
    private:
        std::map< LocalTitleType, LocalTitle > titles;
        std::map< LocalTitleType, sf::Texture > textures;
 

        void createGrassTitle( void ) {
            LocalTitle title;
            title.create();
            title.setTexture( textures.at(LocalTitleType::Grass) ); //Here you access the stored texture and use it. And as long as your map exists, it will be able to use it.

            titles[LocalTitleType::Grass] = title;
        }
 

You store the texture in your map. The map lives as long as the instance of your LocalTitleManager class. If you destroy your manager before drawing, you will have the same problem again.

2
General / Re: is there any good SFML 2.0 C++ Video tutorial?
« on: October 05, 2016, 09:04:51 pm »
Just a quick note:

If you really want to delve into software development or even game development, then the best resources are found in English. I myself am from Germany and a software developer (game stuff is just a hobby) and when I compare the resources on the internet, most good informations are found in English (stackoverflow.com for example is THE site on the internet, where you can find quick help. They have a lot of sub pages for specific topics, like Game Development).

The books from Packt are available in print and PDF format. Sometimes both is cheaper then just digital  :o

But make sure to work through the SFML tutorial on this site :) Anyway, good luck!

3
General / Re: is there any good SFML 2.0 C++ Video tutorial?
« on: October 05, 2016, 05:24:18 pm »
Hi,

I would suggest that you go through the official tutorials first (they are really good!):
http://www.sfml-dev.org/tutorials/2.4/

There are some video tutorials on YouTube, but I did not watch them. Maybe they are okay:


Then of course there are some more or less good books on packt:
https://www.packtpub.com/all?search=sfml

Some of the authors are or were active in this forum too or are part of the SFML Dev Team.

And also packt offers a Video course, but it's not worth the $70+ imho. Why? Computer generated voice and a little out of concept. I had the chance to get it for < $25 ...

4
Graphics / Re: CPU/Pixel based "Post processing"
« on: February 21, 2016, 08:45:08 pm »
Mhh I think this could work.

- I take the texture from my RenderWindow
- Pass it to my xBRZ scaling function
- And pass the new Pixels to the texture.

I guess the update() method will not resize the texture so I would have to create a bigger image (i.e. 1920x1080) and pass only 660x330 to my scaler (where the actual game graphics are placed). This could work and should be faster.

Thanks eXpl0it3r, I will try it :D

Edit: Meh doesn't help, since I still have to call copyToImage() to get access to the RenderWindow texture pixels.

Oh an this does not work, since getTexture is const:
        sf::Uint8 bla[10];
        renderTex.getTexture().update(bla);
 

Too bad m_Texture is private and not protected in RenderTexture x_X

5
Graphics / CPU/Pixel based "Post processing"
« on: February 21, 2016, 07:18:28 pm »
I wonder if there's a more performant way of doing this:
        //Draw everything
        renderTex.clear(sf::Color(200,200,200));
        renderTex.draw(shape);
        renderTex.display();
       
        //Do "Post-Processing"
        window.clear();
       
        sf::Image img = renderTex.getTexture().copyToImage();
       
        //Manipulate the pixels in any way, this is just an example
        for(unsigned int i=0; i < img.getSize().x; i+=8)
        {
            for(unsigned int j=0; j < img.getSize().y; j++)
            {
                img.setPixel(i,j,sf::Color::White);
            }
        }
       
        //Draw result
        postTexture.loadFromImage(img);
        sf::Sprite sprite(postTexture);
        window.draw(sprite);
        window.display();
 

Full code:
(click to show/hide)

I am drawing everything to a RenderTexture, then I retrieve a copy of the underlying texture as an Image.
Then I manipulate the image (e.g. do xBRZ scaling) and render the result to the screen.

Rendering resolution will be around 660x360px.

The pixel manipulation will be done using the Uint8 array, not with setPixel.

And yes, I am not able to create the GLSL shader to do the resizing ... lack of knowledge atm  ::)

6
SFML projects / Re: Cendric: An RPG Platformer
« on: February 21, 2016, 12:24:12 am »
Oh my god, you recognized it! He really was my inspiration, this monster is a mix between him and Kirara ;)

Hehe, that explains the stripes, i guess :D I remember playing Inuyasha:  A Feudal Fairy Tale on the PS1 ... the series and games gave me some ideas back then, great to see I am not alone with this :D too bad I suck @ pixeling ...  :(

Can't wait to see this "monster" in action ê.ê

It is the recording software (screen to gif), its compression also messes a bit with the colors. The fps in this scene on my computer is still 60 (limited by vsync)

Okay, I see, maybe switching to YouTube (Fraps/DxTory + MeGui h.256) to get rid of the stuttering is an idea?
Anyway, I like how your game evolves!!!

7
SFML projects / Re: Cendric: An RPG Platformer
« on: February 21, 2016, 12:04:53 am »
I am really impressed!!!

And reading that you are writing the physics stuff yourself makes it even more awesome!

I like the idea, and the graphics! I am jealous  :-[ ;D

Keep up the good work!

PRE-EDIT:
I just wanted to post this and you just updated this thread!...WTF, the AI algorithm looks awesome :D
The "Ghost" thing is something I always wanted to implement myself, but never had time for it! Looks great!

The "Cat" looks cool :D Reminds me of Sesshomaru  :D

Does the AI calculation slow down the game or is it just the recording software or my computer?! Seems laggy a bit...

8
SFML projects / Re: Screenshot Thread
« on: February 20, 2016, 11:54:38 pm »
Thumb up for Wolfenstein!  ;)

Just added a debug draw overlay to my simple game framework. Needs some tweakin though to not go out of the view (see right paddle)

...

(and yes I'm still working on a Pong clone, it makes adding features to the framework more simple)

May I ask how you implement this debug feature? Using preprocessor directives, so this won't affect the final build?! I like the idea!

If you do so, how does your approach look like?

Regards,
AncientGrief

9
General discussions / [Script] Auto-Update SFML windows batch script
« on: February 20, 2016, 11:45:28 pm »
Hi,

I just set up a batch script to check for SFML updates on git Master and to auto build all the libraries I maybe need (Debug/Release, both static and dynamic).
I thought this could maybe come in handy for anyone, so I share it.

The script builds the MinGW Makefiles. If you want other Makefiles, you have to exchange the specific lines.
Type
cmake --help
to see all the options and call the specific commands for your build environment.

Git, compiler and cmake should be in the PATH  of your OS to work out of the box.
Tested with Windows 10.

The batch script
(click to show/hide)

Usage:
- Open git bash
- Clone SFML via git:
git clone https://github.com/SFML/SFML.git
 

- This will create a new folder "SFML" with all the sources in the working directory.
- Copy this batch file in the working directory (same level as the SFML folder!!!)

Anytime you want to check for updates, run the script.
After pulling the latest version, the script will ask you, if you want to build all the libraries.
Type "y" or "n" to do it or not :)
If you are "up-to-date" you don't need to build the libs, unless you didn't already.

Hope it helps!

Regards,
AncientGrief

10
Graphics / Re: sf:Glsel::Vec2 won't compile
« on: February 20, 2016, 02:44:42 pm »
Quote
What is the best way to stretch the sprite to the window resolution (with shaders)?!
Not with a fragment shader, which only deals with individual pixels.
Hardly with a vertex shader, which can only handle vertices one by one (you'd have to find a way to tell which corner is each vertex).
Possibly with a geometry shader, but I can't tell more about this subject ;D

The best way is to do it in on C++ side.

Thanks Laurent :)

I guess I will stick to SFML's features to achieve this, at least I can now continue to learn GLSL without headaches, I hope  ;D

11
Graphics / Re: sf:Glsel::Vec2 won't compile
« on: February 20, 2016, 12:12:57 pm »
...
What am I missing?!
The first parameter -- the uniform name.

Don't use setParameter(), it's deprecated. Upgrade SFML to the latest master if necessary and use setUniform().

Okay now I feel really stupid ... I shouldn't have coded yesterday ... thank you Nexus

iResolution being 800x600 is clearly wrong (and why declared as a vec3?), given that you use it as normalized coordinates in the shader.

Yes you're right, I orientated the iResolution to Shadertoys variable:
vec3    iResolution     image   The viewport resolution (z is pixel aspect ratio, usually 1.0)

But I figured it out, the shader variable names were wrong:

fragColor must be gl_FragColor

fragCoord.xy must be gl_TexCoord[0].xy
 

What is the best way to stretch the sprite to the window resolution (with shaders)?!

12
Graphics / Re: sf:Glsel::Vec2 won't compile
« on: February 20, 2016, 12:52:32 am »
Thanks for the answer. yes it's the master trunk I am using...

Just reset to 2.3.2 Release (thanks @ IRC @ Eremiell) ... seems to work with setParameter() ...at least it compiles :)

EDIT:
But it still doesn't work ...
My GLSL fragment shader:
Code: [Select]
uniform sampler2D iChannel0;
uniform vec3 iResolution;

void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
    vec2 xy = iResolution.xy;
    xy.y = 1.0 - xy.y;
   
    vec4 texColor = texture2D(iChannel0, xy);
    texColor.b = xy.x;
   
    fragColor = texColor;
}

Edit: But it still does not work:

The shader code:
    text.loadFromFile("texture.png");
    sprite.setTexture(text);
    shader.loadFromFile("shader.frag", sf::Shader::Type::Fragment))

    shader.setParameter("iResolution", 800.0f, 600.0f);
    shader.setParameter("iChannel0",sf::Shader::CurrentTexture);

//....

window.draw(sprite,&shader);
 

Edit2: I just want the texture to be stretched to the window size, like in the tutorial...

13
Graphics / [SOLVED] sf:Glsel::Vec2 won't compile
« on: February 20, 2016, 12:24:32 am »
Hi,

I am trying to learn GLSL with SFML, but this line won't compile:

shader.setUniform(sf::Glsl::Vec2(800.0f,600.0f));
 

What am I missing?!

This is the error I get form MinGW on Windows 10
Code: [Select]
main.cpp:22:52: error: no matching function for call to 'sf::Shader::setUniform(sf::Glsl::Vec2)'

Regards
AncientGrief

P.S. This is the tutorial I am going through:
http://gamedevelopment.tutsplus.com/tutorials/a-beginners-guide-to-coding-graphics-shaders--cms-23313

14
General / Re: Which branch is the next major release?!
« on: January 15, 2016, 11:20:02 am »
We don't have a branch for the next major release, i.e. SFML 3.0. Which also means there has been no development for that. Whenever we talk about SFML 3 it's mostly due to API breaking changes that we can not implement in SFML 2.x or C++11 support which we can neither mix into SFML 2.x.

All the latest development can be found on the master branch.

Then I will stick to the master branch :) Thanks for clarification, eXpl0it3r!

15
SFML projects / Re: Simple Snake Game
« on: January 15, 2016, 01:40:42 am »
Nice game, I like the idea to not be 90° orientated :)
I somehow think this is a more complicated version OrderNexus offers in his new book ;))))))
(http://en.sfml-dev.org/forums/index.php?topic=19565.0)


Pages: [1] 2 3
anything