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

Pages: [1]
1
Graphics / Drawing points
« on: September 06, 2019, 07:39:47 pm »
Hello everyone, I am trying to draw around 10,000 points. So instead of calling window.draw(...) 10,000 times I was thinking of putting into a vertex array, and drawing with single draw call.

But how can I increase the point size? I know the OpenGL function that does this, which is glPointSize(...). But is there another way?

Here is a example image: https://imgur.com/Va6GYXK

2
Network / Re: HTML setHost
« on: July 18, 2018, 05:57:31 am »
The next obvious step would be to Google "HTTP status code 301" and understand what it does and what it means and then you can handle it. ;)

Alright I got everything working lol, is there way to get a specific part of the html?

I tried messing around with setField and setBody. They dont seem to work. I know that getBody returns one big string, and one way I know is to read the string and get data from it. Is there a better way or should i just continue with my way?

3
Network / Re: HTML setHost
« on: July 17, 2018, 04:52:09 pm »
The tutorial and API documentation are quite explicit about how to build a request, especially what goes in the HTTP host and what goes into the request. Have you read it first? If so, can you show us what you tried, and tell us what kind of error you get?

Yea, i first tried to set the host to the full link like this.
http.setHost("https://samples.openweathermap.org/data/2.5/weather?q=London,uk&appid=b6907d289e10d714a6e88b30761fae22&mode=html");
 

I get the error 1001, which is ConnectionFailed error.

Then I figured out that anything after .org / should be in the uri. So i put that in setUri function, and here is the code.
request.setUri("/data/2.5/weather?q=London,uk&appid=b6907d289e10d714a6e88b30761fae22&mode=html");
http.setHost("http://samples.openweathermap.org/");
 

After that I get the error 301, which states its MovedPermanently.
So i dont know what that means.

4
Network / HTML setHost
« on: July 17, 2018, 07:36:53 am »
Hello, I was just wondering why i get response error on some webpages and others not. My project is focused on weather, so I want to gather data from the website and read from it. For example, if i set the host to "http://www.google.com/" the program outputs the entire HTML of google.com. But I want it to output the html from the website below...

https://samples.openweathermap.org/data/2.5/weather?q=London,uk&appid=b6907d289e10d714a6e88b30761fae22&mode=html

How do i set the host to that website so it outputs the HTML from the new host?
Here is my code.
#include <SFML/Graphics.hpp>
#include <SFML\Network.hpp>
#include <iostream>

using namespace std;
int main() {
        sf::Http http;
        sf::Http::Request request;
        sf::Http::Response response;
        sf::RenderWindow window(sf::VideoMode(10, 10), "Weather");
        request.setMethod(sf::Http::Request::Get);
        http.setHost("http://www.google.com/");
        response = http.sendRequest(request);
        cout << "status: " << response.getStatus() << endl;

        if (response.getStatus() == sf::Http::Response::Ok) {
                cout << response.getBody() << endl;
        }
        else {
                cout << "request failed" << endl;
        }
        while (window.isOpen()) {
                sf::Event event;
                while (window.pollEvent(event)) {
                        if (event.type == sf::Event::Closed)
                                window.close();
                }

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

        return 0;
}

5
General / Values are still zero after "changing".
« on: June 21, 2018, 08:47:11 pm »
Hello, so i am trying to do "sf::Vector2f getSize();" function. I assign the x and y values in the CPP file, but when I call the function outside of the class it's still zero. I tested out by cout ing the values in class CPP file, it outputs the current values. But cout ing outside is zero.

This the class function cpp file.
Note: When i draw a rectangle shape border around the text, it covers the text. So its sizes are correct. So i pass in those sizes to getSize() value.
void Label::setValues() {
        if (firstRun) {
                labelText.setPosition(position);
                labelText.setCharacterSize(fontSize);
                labelText.setString(labelName);
                labelText.setFillColor(fontColor);

                labelBorder.setPosition(sf::Vector2f(position.x + labelText.getLocalBounds().left, position.y + labelText.getLocalBounds().top));
                labelBorder.setSize(sf::Vector2f(labelText.getLocalBounds().width, labelText.getLocalBounds().height));
                labelBorder.setOutlineThickness(2);
                labelBorder.setOutlineColor(borderColor);
                labelBorder.setFillColor(sf::Color::Transparent);

                //**** HERE IS THE PROBLEM *****
                labelSize = labelBorder.getSize();
                cout << labelSize.x << "|" << labelSize.y << endl;
                //correct outputs ^ of "74|11"
                firstRun = false;
        }
}

//for label size its "sf::Vector2f labelSize";

sf::Vector2f Label::getSize() {
        return labelSize;
}
 

This is where i call the function outside the file.

void WindowManager::startUp() {
        window.create(sf::VideoMode(windowWidth, windowHeight), "Windows Form");
        label.setBorderColor(sf::Color::Magenta);
        label.setLabelName("Hello Button");
        label.setFontSize(15);
        label.setPosition(0, button.getSize().y/2);

        //**** HERE IS THE PROBLEM *****
        button.setPosition(label.getSize().x + 10, button.getPosition().y);
        cout << label.getSize().x << "|" << label.getSize().y << endl;
        //wrong outputs ^ its "0|0"
}
 

Pages: [1]