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

Pages: [1]
1
Graphics / Re: Window transparency problem - SFML 2
« on: September 20, 2012, 03:10:46 am »
Does sfml expose any of the os specific windows functions, like the x window lib?

** Update
Ive been looking through the sfml source while reading about the X window library, what I found is this:

It seems that  for what I want to do, I would have to modify my windows background pixmap and either set it to the parent (unmodifiable image of my desktop) or copy from parent (would allow me to do image filtering etc.).

In the sfml source (src/SFML/Window/Linux/WindowImplX11.cpp) I found this:

    // Define the window attributes
    XSetWindowAttributes attributes;
    attributes.event_mask = eventMask;
    attributes.override_redirect = fullscreen;
 

If I modified it so that I add...
(I would have to ensure that my window has the same depth as the parent too...)

    // Define the window attributes
    XSetWindowAttributes attributes;
    attributes.event_mask = eventMask;
    attributes.override_redirect = fullscreen;
   
    // My code
    attributes.background_pixmap = ParentRelative    // I believe ParentRelative is the x11 const / enum?
 

I intend to test this myself when I have more time (since Ill probably be recompiling sfml a lot to test it Ill probably save it for the weekend  ;D)

In the mean time; do you believe this is the solution im looking for?
Would I even have to recompile sfml, could I just modify the X windows attributes from the window handle provided by sfml?

2
Graphics / Re: Window transparency problem - SFML 2
« on: September 19, 2012, 05:35:57 am »
Thanks for the help, Im going to look more into this when I have time.

Im using linux so if anyone has any information on what Im trying to do using x11 windows Id much appreciate it.

3
Graphics / Re: Using OpenGL with SFML 2.0
« on: September 18, 2012, 07:45:49 am »
Im pretty sure you have to set OpenGL's model view matrix before listing the verticies.

something like...

...

glClear(...);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

glBegin(GL_TRIANGLES);

...
 

Its been a while since I used the direct rendering pipeline.

You might want to consider switching over to VBOs and VAOs
theyre a little more in depth to set up but they give you a lot better control and performance.

http://www.opengl.org/wiki/Vertex_Specification

------------
**update

In case it helps I dug up some of my old code where I loaded a cube (its in SFML 1.6)
Its pretty similar to what youre trying to do.
http://pastebin.com/jXe88BtJ


4
Graphics / Window transparency problem - SFML 2
« on: September 18, 2012, 07:09:21 am »
Im trying to create a simple splash screen which:

1. loads an image (.png that has transparent parts)
2. renders the image and its transparency by itself (no window, titlebar, etc)

My image.png loads fine but the transparency isn't transferring over to the window.
ie. If I load 2 images and position one behind the image with transparency. The second image is shown through the transparent parts of the first image.

If I load the single transparent image and render it my desktop and other windows behind the RenderWindow aren't showing through the image's transparent parts.
It just displays black in those areas.

I have the clear color set to (0, 0, 0, 0), so it has a 0 alpha channel but its not as simple as that.

Im not sure if what Im wanting is even possible.

My code:
// Inside int main()
splashWindow.create(sf::VideoMode(splashTextureSize.x, splashTextureSize.y, 32),
        "None",
        sf::Style::None);

splashWindow.clear(sf::Color(0, 0, 0, 0));
splashWindow.draw(splashSprite);
splashWindow.display();
 

splashShprite is the .png image which contains transparent sections.

Ive also tried messing with different ContextSettings (using different gl versions from 2.0 to 4.3) to no avail.

Any Ideas,
Thanks in advance!

5
Graphics / Re: Problem rendering any sf::Drawable*
« on: August 12, 2012, 11:25:16 pm »
Thanks for the advice.

It turns out the problem was I never set the text color to black (I guess it defaults to white and because my clear color is white I couldn't see it, duh  ::))

Im glad I got it working, and thanks for the information from Laurent about slicing (it helped me understand parts of my code better).
I am going to change my draw code back to what it was before by passing a RenderWindow reference to a member function of titleScreen in order to draw the text as Laurent suggested.

6
Graphics / Problem rendering any sf::Drawable*
« on: August 12, 2012, 07:25:26 pm »
Ive been trying to work out the best way to manage the drawing of all sprites, text or any sf::Drawable for that matter within my game.

I wanted all the drawables to be displayed stored in a vector so that I can draw them all at once within the main function instead of passing around a reference to the RenderWindow.

To solve this I created a vector of sf::Drawable pointers so that I can fill the vector with the any object that is derived from sf::Drawable

Here is my solution:

main.cpp
#include <vector>
#include "title_screen.h"

int main()
{
    sf::RenderWindow window(...);
    std::vector<sf::Drawable*> drawBuffer;

    TitleScreen titleScreen(window.getSize());
    titleScreen.pushDrawablesToVector(drawBuffer);

    // Event Handler
    while (window.isOpen) {...}

    window.clear(sf::Color::White);
    for (std::vector<sf::Drawable*>::iterator i = drawBuffer.begin(); i < drawBuffer.end(); i++)
    {
        window.draw(**i);
    }
    window.display();
}
 

title_screen.h
#include <vector>
#include <SFML/Graphics.hpp>

class TitleScreen
{
    sf::Text title;
    sf::Text newGame;

public:
    // Constructor which sets text position using winSize and strings
    TitleScreen(sf::Vector2u winSize) {...}
   
    void pushDrawablesToVector(std::vector<sf::Drawable*> &dB)
    {
        dB.push_back(&title);
        dB.push_back(&newGame);
    }
};
 

The code compiles and runs fine, the problem is I get a black white screen without any text.

Im assuming this has something to do with the size of sf::Drawable* vs sf::Text* (and sf::Text private member data not inherited from sf::Drawable).

Any ideas or suggestions?
Thanks in advance

Pages: [1]