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

Pages: [1]
1
Graphics / [Solved] Binding real position to shader
« on: June 01, 2013, 02:34:39 am »
I'm having a small issue, maybe someone can help me.

I set a custom view on my window, then I draw a CircleShape at a certain position, using a custom vert/frag shader.

I wanted to pass the information of that position into the frag shader, in such a way that its compatible (meaning accurate) with the positional information given by gl_Vertex in the vertex shader.

When I pass just the position, exactly the same as I set it on the circle shape, it seems that the 'center' doesn't appear to be in the center of the circle shape, and even more oddly moves around when the circle shape's position changes.

I figured I'd try the getView().getTransform().transformPoint(..) on the position, but that also yields strange results. The 'center' doesn't move when the circle shape moves, but still appears to be somewhere in the far upper left of the circle shape, and not the center. Yet I have set the circle shape's origin, via setOrigin to be so that it's center appears exactly at the given position.

I realize this isn't that easy to describe, but the screenshots I took aren't really clear either... hopefully someone can figure out what I'm talking about and offer advice. Thanks.

Edit: Basically I want to take a sf::Vector2f I pass as position in c++, and then give the accurate information on where that position is to opengl's shaders, in world space (not screen space)

2
SFML projects / SimpleSprite
« on: February 01, 2013, 07:26:04 pm »
I was doing some testing yesterday on a project I'm working on, and I realized that drawing the sf::RectangleShape (which I had a lot of) wasn't performing as fast as using a sf::Sprite. However, I also wanted a setSize functionality and I was planning to do something which would have benefited from a setVertexColor function.

So, this isn't exactly a project, but I wrote a SimpleSprite class which fullfills those needs.
It should also duplicate all functionality of a sf::Sprite, so you should (in theory) be able to replace any sf::Sprite objects with SimpleSprite and would not be required to do any other code changes. I've seen a couple of posts where people were talking about stuff like this, so I decided to post this.

Here's the public functionality of SimpleSprite:
Code: [Select]

    SimpleSprite ( );

    explicit SimpleSprite ( const sf::Texture &texture );

    SimpleSprite ( const sf::Texture &texture, const sf::IntRect& rect );

    void setSize ( const sf::Vector2f &size);

    void setSize ( float size_x, float size_y );

    void setTexture ( const sf::Texture &texture, bool updateTextureRect = false );

    void setTextureRect ( const sf::IntRect &rect );

    void setColor ( sf::Color color );

    void setVertexColor ( unsigned int index, sf::Color color );

    // getters

    const sf::Vector2f& getSize () const;

    const sf::Texture* getTexture () const;

    const sf::IntRect& getTextureRect () const;

    // Warning: This function may not return correct results if you have used setVertexColor(..)
    // This function is the equivalent of calling getVertexColor(0)
    const sf::Color& getColor () const;

    const sf::Color& getVertexColor ( unsigned int index ) const;


The .hpp and .cpp are attached.
Edit: Updated - the default behavior of setTexture so that updateTextureRect is false by default.

[attachment deleted by admin]

3
Feature requests / Support for OpenGL Array Texture in future SFML2.x
« on: January 18, 2013, 01:54:26 pm »
I don't think this will be the easiest thing to integrate with the current setup of image/texture/sprite - but I think it may be beneficial to add support for http://www.opengl.org/wiki/Array_Texture - or at least, support for the array of 2D textures (the 1D variant has its uses, but i think is not nearly as commonly used)

By support, I mean allowing the creation of something like sf::ArrayTexture and allowing sprites/shapes to have their texture set in the form of  Sprite::SetTexture ( ArrayTexture &arrayTexture, unsigned int level )
This, as far as I know, would also require that all drawing be done with a custom shader.

The main reason for this request is that it would provide possibilities for speed optimizations in certain, though not very common, cases.

For example, and what caused me to think of this request:
I currently have a tile-based game, where there are 34 different tile types. Each tile type has its own texture, for a specific 'theme' - i.e. dirt tiles, concrete tiles, glass tiles, metal tiles etc.
Currently, each theme is stored 1536x1536px texture atlas, and drawing a variety of tile types that all have the same 'theme' (i.e. they're all dirt tiles) is quick.
However, drawing tiles that all have different themes still requires a number of texture switching between the texture atlas for each theme. (a workaround to minimize this would be to sort the tiles by type when drawing, but it's still not as efficient as using a array texture)

Since all of my texture atlases are the same size, it would ideal to stick them in an Array Texture - and I would, except there's no easy way to supply this information to the sf::Sprite class.

Thanks!

4
SFML projects / Human Skeleton Animator
« on: January 23, 2011, 08:05:44 pm »
Hi everyone, I found SFML right before new years, and I decided to use it for a project I had JUST started.

In brief, the project is an attempt to create an easy to use character animation, based on a rigid skeleton structure.

It uses OpenGL for 3d graphics.
SFML for the window and event handling, and I further plan to use it for the loading textures.

The project site can be found Here
Or if you're just interested in a quick view, there's a video here

On the site you can find links to download the win32 release, and the source code, as well as a far more detailed description and instructions on how to animate.

The project is a little over 3 weeks old at this point, and I've reached a snag that I don't have the ability to create a human model for the project.
There's also a larger project which this is the first part of.
So, besides comments and criticism, if anyone's interested in helping me, you can find a place to talk on the project's site.

Thanks.

5
Window / fullscreen and opengl
« on: January 09, 2011, 05:34:40 am »
Hi, simple question:

I have an OpenGL application. To toggle fullscreen i use window.create(..).
Especially switching TO fullscreen this doesn't seem to work too well (i get a green screen, which is the color i clear with glClearColor())

Do I have to reload all OpenGL related resources (such as settings and textures) when I switch to full-screen?
If so, is there another way?

Thanks
- Zenon

Pages: [1]
anything