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

Pages: [1] 2 3
1
Feature requests / Re: System cursors
« on: January 22, 2015, 12:23:06 am »
I did Linux implementation first because I'm on Linux, I wanted to be sure I did that right before moving on. I can do windows via mingw but I'd have no way of testing OS X.

The linux cursors are here:
http://tronche.com/gui/x/xlib/appendix/b/

Windows are here:
http://msdn.microsoft.com/en-us/library/ms648391%28v=vs.85%29.aspx

I haven't found anything for  OS X yet.

I wasn't sure where I should put the enum and if it should limit it to only common cursors. So I just made a basic function for now. Also I was going to write a function to set cursor to image but I wasnt sure If I should make a createcursor() or a setcursor() that takes sf::image or something...


2
Feature requests / Re: System cursors
« on: January 21, 2015, 09:54:50 pm »

3
Feature requests / Re: System cursors
« on: January 20, 2015, 05:18:13 pm »
Well I tried...

static void testCookie (xcb_void_cookie_t cookie, xcb_connection_t *connection, char *errMessage )
{  
        xcb_generic_error_t *error = xcb_request_check (connection, cookie);
        if (error) {
                std::cout << std::string(errMessage) << std::endl;
                xcb_disconnect (connection);
                exit (-1);
        }  
}  


void WindowImplX11::setMouseCursor(int cursorId)
{  
        xcb_font_t font = xcb_generate_id (m_connection);
    xcb_void_cookie_t fontCookie = xcb_open_font_checked (m_connection,
                                                                                                                  font,
                                                                                                                  strlen ("cursor"),
                                                                                                                  "cursor" );
                                                                                                                 
        testCookie (fontCookie, m_connection, "can't open font");

        xcb_cursor_t cursor = xcb_generate_id (m_connection);
        xcb_create_glyph_cursor (m_connection,
                                                         cursor,
                                                         font,
                                                         font,
                                                         cursorId,
                                                         cursorId + 1,
                                                         0, 0, 0, 0, 0, 0 );

        xcb_gcontext_t gc = xcb_generate_id (m_connection);

        uint32_t mask = XCB_GC_FOREGROUND | XCB_GC_BACKGROUND | XCB_GC_FONT;
        uint32_t values_list[3];
        values_list[0] = m_screen->black_pixel;
        values_list[1] = m_screen->white_pixel;
        values_list[2] = font;

        xcb_void_cookie_t gcCookie = xcb_create_gc_checked (m_connection, gc, m_window, mask, values_list);
        testCookie (gcCookie, m_connection, "can't create gc");

        mask = XCB_CW_CURSOR;
        uint32_t value_list = cursor;
        xcb_change_window_attributes (m_connection, m_window, mask, &value_list);

        xcb_free_cursor (m_connection, cursor);

        fontCookie = xcb_close_font_checked (m_connection, font);
        testCookie (fontCookie, m_connection, "can't close font");
        xcb_flush(m_connection);
}

I tried modifying http://xcb.freedesktop.org/tutorial/mousecursors/ but I can't get it to work. I'm not getting any changes in my cursor or any errors. I'm stumped...

4
Feature requests / Re: System cursors
« on: January 20, 2015, 05:03:47 am »
why you would support a function to handle the cursor visibility
So that we can draw a sprite in its place, or just get it out of the way of our beautiful SFML game window, maybe? ;D
Way to take that out of context. You argued that sfml doesn't handle the cursor, From it's ability to show / hide the cursor it clearly does....

5
Feature requests / Re: System cursors
« on: January 20, 2015, 05:03:26 am »
why you would support a function to handle the cursor visibility
So that we can draw a sprite in its place, or just get it out of the way of our beautiful SFML game window, maybe? ;D

Way to take that out of context. You argued that sfml doesn't handle the cursor, From it's ability to show / hide the cursor it clearly does....

6
Feature requests / Re: System cursors
« on: January 19, 2015, 10:58:13 pm »
My fault. I didn't realize default search only gave 6 or so results. Anyways that issues 3 years old. All the codes there on wiki so why isn't it added?

7
Feature requests / Re: System cursors
« on: January 19, 2015, 10:32:38 pm »
but it does handle the cursor too, although it can only currently hide it

setMouseCursorVisible()

Edit: I saw only one topic on this here in feature requests and there was no clear explanation why you would support a function to handle the cursor visibility but none to get/ handle the system's built in cursors.

8
Feature requests / Re: System cursors
« on: January 19, 2015, 10:26:27 pm »
Yet, sfml has functions to handle the mouse, including one to set the mouse cursor (to img). It seems kind of half-assed to ignore the system cursors, but whatever.

9
Feature requests / System cursors
« on: January 19, 2015, 09:43:19 pm »
I would like to be able to set the mouse cursor to the OS's built in cursors (arrow, edit wait, regular etc).

There's example here: https://github.com/SFML/SFML/wiki/Tutorial:-Change-Cursor. Is there some reason this feature isn't included in sfml?

10
Graphics / Re: BlendMode
« on: December 27, 2014, 07:19:19 pm »
Here's a demo. When you set an alpha lines turn black. Otherwise the color is correct...

#include <SFML/Graphics.hpp>

static const unsigned char colorbars_png[] = {137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,0,48,0,0,0,36,8,2,0,0,0,64,39,46,93,0,0,0,9,112,72,89,115,0,0,11,19,0,0,11,19,1,0,154,156,24,0,0,0,7,116,73,77,69,7,222,12,27,19,55,13,86,222,43,192,0,0,4,59,73,68,65,84,88,195,205,88,205,139,28,69,20,255,189,170,234,158,222,158,217,79,87,252,88,69,86,141,39,97,131,26,241,100,188,132,69,193,147,120,204,65,114,240,47,136,135,176,68,19,61,120,217,131,1,5,209,187,10,226,69,194,70,65,16,196,21,67,68,163,136,9,49,168,224,199,94,178,201,154,238,158,174,207,231,161,39,189,51,227,70,214,204,236,206,62,24,168,46,170,186,223,251,189,223,251,213,171,33,102,70,159,241,167,8,139,0,117,79,157,160,19,39,113,60,244,206,34,188,196,254,20,145,173,94,66,68,145,141,142,126,120,244,181,183,95,69,163,123,183,65,246,50,178,215,65,245,110,6,240,100,227,236,215,226,64,212,251,113,129,225,27,15,178,106,39,28,162,109,175,218,98,165,26,142,11,55,114,65,68,52,216,171,134,131,80,77,68,102,230,109,166,108,71,29,34,162,154,215,3,178,77,12,236,74,111,214,120,208,216,196,96,236,165,42,87,204,92,33,180,133,136,236,166,67,188,237,218,217,53,132,110,90,110,163,66,136,177,167,56,84,131,84,87,217,224,54,168,67,255,246,99,196,194,88,101,138,153,59,3,12,10,212,224,194,72,55,131,106,148,74,93,67,69,32,236,133,163,99,19,33,26,80,55,134,71,234,154,76,163,20,198,110,185,222,43,28,234,147,102,194,232,251,33,234,73,25,254,87,63,196,59,200,161,174,148,209,40,73,125,235,77,254,238,232,208,224,135,199,78,32,52,244,22,150,182,222,202,255,33,208,68,60,164,186,87,89,209,63,37,89,142,49,128,86,151,59,215,27,49,198,163,44,128,168,118,140,198,96,45,116,77,106,16,33,178,32,134,75,81,198,189,209,148,128,223,12,159,0,1,52,18,26,87,253,23,49,117,232,72,207,115,0,158,16,143,191,145,126,3,150,155,179,229,216,11,207,191,247,244,179,7,65,85,81,19,0,144,192,251,191,227,180,133,227,186,119,117,18,103,14,242,254,119,17,217,46,188,13,209,155,132,183,80,223,175,153,193,1,39,63,192,131,11,240,174,39,127,234,210,47,117,200,204,140,0,158,83,45,52,31,241,92,117,132,0,131,115,220,126,133,238,208,223,51,5,112,167,23,227,6,227,15,193,23,4,12,24,157,140,105,133,143,31,179,63,222,235,83,211,238,184,25,11,114,101,152,213,14,112,170,58,88,36,88,130,105,102,94,60,244,0,156,5,5,40,64,18,0,168,99,47,178,15,33,120,239,189,243,222,91,231,239,9,238,42,185,204,89,107,173,117,206,26,99,11,178,24,55,231,158,49,214,88,99,141,49,198,88,19,180,249,203,154,73,99,75,163,181,49,198,88,107,218,218,175,126,182,122,103,241,202,177,9,91,2,184,141,241,176,192,188,207,158,90,253,89,226,171,24,191,34,2,246,49,47,128,238,127,167,121,215,233,243,192,15,72,215,177,31,120,84,225,110,9,98,246,128,13,222,90,99,180,49,70,235,188,44,175,182,203,178,221,177,162,93,20,69,94,108,184,124,195,230,121,94,20,69,150,101,89,150,229,121,158,155,60,43,179,44,203,242,34,207,179,188,250,217,191,55,14,0,103,231,1,0,251,128,231,128,69,20,247,225,12,196,41,132,47,208,12,88,36,28,6,14,241,90,19,159,0,31,97,226,50,14,19,142,52,176,16,65,85,244,242,65,184,64,206,195,122,14,62,196,222,123,239,156,119,206,187,200,69,145,139,35,114,81,100,162,200,40,165,149,210,157,129,214,202,106,101,181,50,90,89,45,141,150,70,59,34,36,2,105,0,1,41,144,0,13,120,32,108,150,41,3,1,112,20,3,99,80,41,210,20,41,33,105,64,68,80,43,43,43,33,4,41,101,8,161,226,145,115,14,128,181,54,132,96,173,245,222,91,107,157,115,82,202,36,73,148,82,73,146,76,79,79,107,173,173,173,210,103,156,115,101,89,122,239,219,237,246,133,139,23,175,92,250,233,203,235,148,17,176,6,124,7,34,92,155,197,183,192,122,0,216,131,214,64,231,32,29,214,39,113,30,225,79,232,107,184,76,248,60,194,111,18,36,132,32,162,185,185,57,41,229,204,204,76,171,213,106,52,26,179,179,179,82,202,201,201,201,56,142,91,173,86,146,36,173,86,43,77,211,234,81,41,53,53,53,37,132,104,54,155,73,146,196,113,60,49,49,193,204,211,211,211,206,185,229,229,229,165,165,37,185,121,199,238,65,166,71,235,136,234,38,188,214,67,85,1,227,189,7,16,66,232,240,219,123,34,10,33,116,95,144,169,215,196,13,147,82,86,81,41,165,0,8,33,0,248,90,38,121,91,26,29,186,255,31,170,63,208,55,168,172,251,156,234,83,227,234,74,95,249,93,13,234,24,110,217,254,1,178,148,101,54,121,28,135,134,0,0,0,0,73,69,78,68,174,66,96,130};

class Grid : public sf::Drawable, public sf::Transformable
{

public:

    Grid(unsigned int Xsep, unsigned int Ysep, unsigned int CanvasW, unsigned int CanvasH)
    {

        m_vertices.setPrimitiveType(sf::Lines);
        m_vertices.clear();

        for (int i=((CanvasW/2)-Xsep); i > 0; i-=Xsep)
        {
            m_vertices.append(sf::Vector2f(i,0));
            m_vertices.append(sf::Vector2f(i,CanvasH));
            m_vertices.append(sf::Vector2f(CanvasW-i,0));
            m_vertices.append(sf::Vector2f(CanvasW-i,CanvasH));
        }

        for (int i=((CanvasH/2)-Ysep); i > 0; i-=Ysep)
        {
            m_vertices.append(sf::Vector2f(0,i));
            m_vertices.append(sf::Vector2f(CanvasW,i));
            m_vertices.append(sf::Vector2f(0,CanvasH-i));
            m_vertices.append(sf::Vector2f(CanvasW,CanvasH-i));
        }

        m_vertices.append(sf::Vector2f(0,CanvasH / 2));
        m_vertices.append(sf::Vector2f(CanvasW,CanvasH / 2));
        m_vertices.append(sf::Vector2f(CanvasW / 2, 0));
        m_vertices.append(sf::Vector2f(CanvasW / 2,CanvasH));
    }

    void setFillColor(const sf::Color &color)
    {
        unsigned vertex_count = m_vertices.getVertexCount();

        for(unsigned int i=0; i < vertex_count; i++)
            m_vertices[i].color = color;
    }


private:

    sf::VertexArray m_vertices;
    void draw(sf::RenderTarget& target, sf::RenderStates states) const
    {
        states.transform *= getTransform();
        states.blendMode = sf::BlendMode(sf::BlendMode::SrcAlpha, sf::BlendMode::One, sf::BlendMode::Subtract); //BlendMode here
        target.draw(m_vertices, states);
    }

};

int main()
{
    sf::RenderWindow window(sf::VideoMode(800, 600), "Grid Test");

    Grid grid = Grid(16,16,800,600);
    grid.setFillColor(sf::Color(255,255,255,40)); //without alpha lines are inverse

    sf::Texture texture;
    texture.loadFromMemory(colorbars_png, sizeof(colorbars_png), sf::IntRect(0,0,48,48));


    sf::Sprite sprite;
    sprite.setTexture(texture);
    sprite.setTextureRect(sf::IntRect(0, 0, 800, 600));
    sprite.setScale(16.6, 18.75);

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

        window.clear(sf::Color::Black);
        window.draw(sprite);
        window.draw(grid);
        window.display();
    }

    return 0;
}

 

11
Graphics / Re: Reset view zoom?
« on: December 25, 2014, 03:12:22 pm »
I'm looking for a way to do it without storing a zoom factor. There doesn't seem to be much in terms of get functions related to zoom though...

12
Graphics / Reset view zoom?
« on: December 25, 2014, 02:22:08 pm »
How do I reset a view that I've called zoom() on to a zoom factor of 100%  without altering it's position?

13
Graphics / Re: VertexArray repeat texture
« on: December 25, 2014, 01:13:54 pm »
Fixed. Thanks.

14
Graphics / VertexArray repeat texture [Solved]
« on: December 25, 2014, 09:17:33 am »
How do I repeat a texture without stretching it across the size of the vertex array?

I've tried this: but it seems  to stretch the checkers.

Relevant Code: (rect is area I would like to repeat texture in. the texture is 64x64 px)
sf::Texture checkers;
checkers.loadFromImage(*createChecker());
checkers.setRepeated(true);

void Checkers::setTextureRect(sf::IntRect rect)
{
        // size //
        m_vertices[0].position = sf::Vector2f(0,0);
        m_vertices[1].position = sf::Vector2f(rect.width,0);
        m_vertices[2].position = sf::Vector2f(rect.width, rect.height);
        m_vertices[3].position = sf::Vector2f(0,rect.height);
       
        m_vertices[0].texCoords = sf::Vector2f(0,0);
        m_vertices[1].texCoords = sf::Vector2f(64,0);
        m_vertices[2].texCoords = sf::Vector2f(64, 64);
        m_vertices[3].texCoords = sf::Vector2f(0,64);
}

void Checkers::draw(sf::RenderTarget& target, sf::RenderStates states) const
{
    states.transform *= getTransform();
    states.texture = checkers;

    target.draw(m_vertices, states);
}

15
Graphics / Re: BlendMode
« on: December 25, 2014, 07:21:57 am »
Also gives me black lines.

Pages: [1] 2 3