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

Pages: [1] 2 3 ... 6
1
OK... So, I'm using sf::View to create a view of a graph. At present, I am able to zoom in and out and move the the view in all directions. Currently, the graph generates four nodes and the view is at the default,

Graph_Camera.reset(sf::FloatRect(0.0f, 0.0f, Window.getSize().x, Window.getSize().y));

Graph_Camera.setViewport(sf::FloatRect(0.0f, 0.0f, 1.0f, 1.0f));

How would I resize the view in such a way that when more nodes are added, the view zooms out to display all nodes that are initially out of bounds at default? Also, an important point to note is that the change in number of nodes is not dynamic. It is predetermined before the window is rendered.

I tried setSize() but it is not centering on the Window center. Here's what I did,

Graph_Camera.setSize(Node_List.size() * 200, Node_List.size() * 200);

Graph_Camera.setViewport(sf::FloatRect(0.0f, 0.0f, 1.0f, 1.0f));

Please help me on this. Thanks.

2
Window / Re: Qt and SFML Window
« on: April 11, 2015, 12:38:47 am »
Well... That depends on the tone you infer it in. My implication was positive, though. You know that. Thanks anyway, Laurent.

3
Window / Re: Qt and SFML Window
« on: April 09, 2015, 11:01:15 pm »
Well, it works all right. Only thing is if I open multiple windows, I am only able to close the latest window first. Clicking on the 'x' close button on the older windows won't do anything but if I click on the latest window's close button, all of them close at once. But it's only minor and I guess it's OK. I don't think the admission committee will scrutinize it that deeply. I hope they don't. After all, I am going there to learn programming. This is just to test if I know the basics. Thanks anyway, Laurent.

Quote
A previous post in this topic even has me appreciating Laurent.
:-\

Hehe...  ;D
What was that supposed to mean? I was just trying to prove that I have to no hatred towards the SFML community. Is there some strict 'no-praise' policy I don't know about? If then, sorry for praising you.  :)

4
Window / Re: Qt and SFML Window
« on: April 09, 2015, 09:32:31 pm »
Because my life is taking this prestigious opportunity to shit on me. I have 4 days left to submit a project for admission and I am on a very tight schedule. Every time I try to find a solution and I think I found it, something or the other puts me back at square one. So, one step forward, three steps back.

I am a slow learner, but I'm enthusiastic to learn. I got no one to teach me in real life and the internet is my only chance of learning. Problem is, people on the internet... Not really the kindest people in the world. I am not talking about people at SFML forums. You guys are great. A previous post in this topic even has me appreciating Laurent.

However, others... Specifically Stack Overflow (yeah, Stack Overflow, I said it)... not so kind. Sure, I don't understand right away. Sure, I'm a slow learner. But at least I'm asking politely. Nope! Just downvote the question and move on without giving any reason why. Is my question really not that worth answering? Sure, the answer to my question could be obvious and in plain sight but I'll still need to be pointed in the right direction. Google can only get you so far that you should know what exactly you're looking for.

Even then, I try not to ask more than what I should because I want to figure it out on my own and also, I don't want to be criticized for being ignorant. Even now, I'm scared to ask which part of the code is the update code that Laurent mentioned because I don't have a clue. But, I'm trying to figure it out on my own. You people are nice but I can't ask every single thing, even those unrelated to SFML. And the rest of the internet is... well, I told you. So, this is what I'm feeling right now.

Sorry for the long post, but I had to speak my mind. To answer your question, A) It's relevant as explained above and B) Is it productive if I don't say it? It doesn't make a difference.

5
Window / Re: Qt and SFML Window
« on: April 09, 2015, 04:45:51 pm »
OH... MY... GOD...!

Fuck my life, man! Fuck my life! -_-

6
Window / Re: Qt and SFML Window
« on: April 09, 2015, 01:21:37 am »
UPDATE: I researched a little bit and found out that the window loop is blocking the Qt event processing. I was suggested a solution and it worked perfectly.

while(Window.isOpen())
{
        qApp->processEvents();
               
        while(Window.pollEvent(Window_Event))
        {
                //event loop
        }

        //rest of the stuff
}

Apparently, I have to call this function, qApp->processEvents(), in order to continue the Qt event processing even while the window is running. Easy solution, easy fix.  ;D

I am posting this here so that it might help any other lost sheep like me out there in future. Cheers.  :)

7
Window / Re: Qt and SFML Window
« on: April 07, 2015, 05:44:13 pm »
Thanks for that, Laurent. I'll try to work with that. I'm not sure how much I'll understand all that but I'm pretty sure I'll hit a snag somewhere, so I'm gonna post in this topic if I have any problem. Thanks for your help. You're the only API creator around the web that actively participates in interactions with the users. Kudos!  ;D

By the way, before trying such complicated things, you should really learn a little more about Qt and its core systems (signal / slots, meta-objects, event loop).

I know. But this is for a submission to a college admission and I'm really low on time. So I'm, um... let's use the word half-assedly... Yeah, I'm half-assedly learning only what is needed for the program in order to meet deadlines. So, if any anomaly occurs outside the scope of that, I become a lost sheep. But, yeah... Once this is over and I'm freelancing and such, I would definitely go deeper to learn more. Thanks for your advice.  :)

P. S. : I have observed most of the questions here (including some of mine) are asked by people who are too lazy to read the documentation. Most of them can be avoided and solved just by going through the documentation - something I learned later on when I was going through my earlier questions. Imagine that embarrassment.  :-\

8
Window / Re: Qt and SFML Window
« on: April 07, 2015, 04:35:06 pm »
OK... So,

1) I haven't really worked with threads before and I don't have time to start learning it now. Time is really of the essence here. Also, dabbertorres says he doesn't recommend using threads.

2) I can try this out, although I have no clue on what to do here. So far, I only used Qt signals for simple button clicks.

I did try out dabbertorres's solution and I got the white screen problem and subsequently the program crashed. I created the sf::Window Window variable on a global scope and called Window.create in the button click slot. And the update loop was placed in main. I am able to open multiple windows without the Widget GUI crashing, but conversely now the SFML window is crashing.  :-\

9
Window / Re: Qt and SFML Window
« on: April 07, 2015, 11:07:43 am »
OK... So, what do you reckon I should do? Should I follow the method suggested by dabbertorres? I don't know whether I have control of main. How would I know that? Should I run a printf statement in main while the window is running or something like that?

10
Window / Re: Qt and SFML Window
« on: April 07, 2015, 03:57:14 am »
The code is the same as the example of the tutorials for opening a window. And the code for the button click is created when I attach a slot to a GUI button. So, it's auto generated code. I'm just putting the tutorial code in a function instead of main so that the function is called whenever the button is clicked. If you still insist on seeing the code, then,

void Widget::on_Generate_Button_clicked()
{
        Open_Window();
}

void Widget::Open_Window()
{
        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();
                }

                window.clear();
                window.display();
        }
}

However, there is no point in me posting this since this is the same tutorial code copy pasted to my program copy pasted here. I'm pretty sure the error is not Qt or SFML specific. It's more about the general C++ concept of passing of control from a function to another function within its scope. I thought I'd post it here because, usually, the SFML window function does not return the control until the window is closed. Is there any way to bypass it?

Here's what I what:

At 3:58, the person opens one window and while this window is running, opens another at 4:46. He is able to use the button on the Qt Widget even though the window is running (He uses DirectX). That's what I want exactly. To have control of the button while the window is running. As of now, my program is not doing that, and crashing if I try to do that.

11
Window / Re: Qt and SFML Window
« on: April 06, 2015, 08:49:20 am »
No... I didn't! Because I am not putting the SFML Window inside the Qt Window. I am separately creating a new window on the button click.

12
Window / Qt and SFML Window
« on: April 06, 2015, 01:18:58 am »
Hi... I am using SFML with Qt and I am creating a GUI where the button click will open an SFML window. Here's what I did. I created a function which opens an SFML window (the same generic SFML opening window example, except its not written in main but a separate function). Then, I made a Qt button click slot which, on clicking, calls this function. It runs perfectly. However, the button becomes frozen on clicked mode until the window is closed. And I can see why this is occuring, because the function does not return control back to the button until the window is closed. Furthermore, clicking on the button while the window is open causes the application to crash.

How would I fix this? How would I return control back to the button so that I can click on it while a window is open? Doing so, I would be able make the button create multiple windows in this way. I know this is possible because I've seen it being done with DirectX windows and Qt. I'm pretty sure this is not an error on part of SFML, but I thought I'd post here anyway because since it has been done with DirectX, it should be possible for SFML too. Please help. Thanks.

13
General / Re: Loading textures from Qt resource
« on: March 21, 2015, 08:58:08 pm »
I meant the error message, which says that there's something wrong with the passed data. You should store both the data pointer and the size into variables and check their values with a debugger.

OK, I'll try that... I'll see what comes up and update this post accordingly. Thanks.

EDIT: **FIXED** I ran it through the debugger, and it showed zeros. The QResource is returning empty. I tested on another project and it worked. Apparently, this project was corrupted. Now it works perfectly. Thank you guys for the help. :)

14
General / Re: Loading textures from Qt resource
« on: March 21, 2015, 08:43:53 pm »
Quote
Failed to load image from memory, no data provided
Have you read that? Is your image empty?

And don't specify the third argument, the default parameter exists for a reason ;)

I don't understand what you mean by "Have you read that?" Are you asking, have I read that sentence or have I read the image into memory? The image file is perfect, not corrupted in any way. And that file does exist in the .qrc file. I don't know why it isn't loading.

P.S. : I initially did not have the third argument in. But I later put it in because I thought people might criticize me for not putting it in. I read the docs and saw it was default, but I was being on the safe side anyway.  ;D

EDIT: @Laurent I went according to the Qt Docs and did exactly what it mentioned to do for loading a file into QResource from the .qrc file. The file in the .qrc works fine, and is perfectly usable by the QWidget. Everything else also works fine. I don't know why this is occuring. I assumed it was the loadFromMemory(). Now, I know I didn't do anything wrong there. Thanks for clearing that up.

15
General / Loading textures from Qt resource
« on: March 21, 2015, 07:45:38 pm »
Hi... I am trying to load a texture from a .qrc file which contains my texture file. I tried to google for it but I got no relevant search result so I'm posting it here. Here's what I did.

QResource Image(":/test.bmp");

sf::Texture Tex;

Tex.loadFromMemory(Image.data(), Image.size(), sf::IntRect());

The texture is not being loaded and fails to show. I checked and found that loadFromMemory() takes const void* for data, and std::size_t for size and the QResource's data() returns a const unsigned char* as return value and size() returns long long int as return value. So I tried the following two methods.

Tex.loadFromMemory((const void*)Image.data(), (std::size_t)Image.size(), sf::IntRect());

Tex.loadFromMemory(static_cast<const void*>(Image.data()), static_cast<std::size_t>(Image.size()), sf::IntRect());

Still the same result. The image does not load. Here's the application output.
Starting C:\Users\WDR\Documents\Qt\test\debug\test.exe...
Failed to load image from memory, no data provided
C:\Users\WDR\Documents\Qt\test\debug\test.exe exited with code 0

Please tell me the right way to do this. Thank you.  :)

Pages: [1] 2 3 ... 6