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 - 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 / 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;
}

3
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]