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

Pages: [1]
1
Graphics / Starting With OpenGL
« on: January 06, 2014, 12:00:42 am »
I am attempting to run the first example on the openGL tutorial.

http://sfml-dev.org/tutorials/2.1/window-opengl.php

I receive errors as follows:

Quote
1>main.obj : error LNK2019: unresolved external symbol __imp__glClear@4 referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__glViewport@16 referenced in function _main

I believe there is a file named opengl32.lib that I have to do something with. Some of the guides tell me the location, so maybe I need to copy it to my project? Some tell me things about other libraries like glu and ones I obviously don't need like glut. And finally there are a few tutorials telling me that I can put a linker option (which I assume goes in Linker command line options). Nothing I try is working and I'm getting very frustrating and I have over a hundred tabs of tutorials I've tried and I don't know why this is so complicated.

I am using Microsoft Visual C++ 2010.

2
Graphics / Build a Realistic Sphere
« on: January 05, 2014, 07:44:48 pm »
I am currently able to build nice beautiful circles like this:

void resetPlanetVertexes (sf::VertexArray* planet, sf::Vector2f* center, float size, sf::Color* color)
{
        int i;
        int count = (int)(planet->getVertexCount());
        for (i = 1; i < count-1; i ++) {
                float angle = ((float)(i) / (float)(count-2) * 360.f) * 3.14f / 180.f;
                ((*planet)[i]).position = *center + sf::Vector2f(
                        (float)(std::cos(angle) * size),
                        (float)(std::sin(angle) * size)
                );
                ((*planet)[i]).color = *color;
        }
        ((*planet)[count-1]).position = ((*planet)[1]).position;
        ((*planet)[count-1]).color = ((*planet)[1]).color;
}

void buildPlanet (sf::VertexArray* planet, sf::RenderWindow* window)
{
        int width = (int)(window->getSize().x);
        int height = (int)(window->getSize().y);
        sf::Color planetcolor = getPlanetColor();
        float size = getPlanetSize();
        std::cout << "Planet Size: " << size << std::endl;
        sf::Vertex* planetcenter = &((*planet)[0]);
        planetcenter->position = sf::Vector2f
                                ((float)(rand() % (width + (PLANET_BORDER<<1)))-PLANET_BORDER,
                                (float)(rand() % (height + (PLANET_BORDER<<1)))-PLANET_BORDER);
        planetcenter->color = planetcolor;
        resetPlanetVertexes(planet, &(planetcenter->position), size, &(planetcenter->color));
}

However, they look obviously flat and not like planets at all. They look like someone cut perfect circles out of construction paper.



If we look at a planet like Neptune, we see that the bottom right fades towards black, while the top left fades towards a slightly brighter color to create the appearance of a sphere and not a circle.

I think I can probably do something with the coloring to darken or lighten it. (Not sure the best way to do that.) Do I really have to modify each of the three rgb values to lighten/darken a colour?

I also thought there might be a way to build a 3D planet or something similar to that as well.

I want to make each planet random and different so I don't want to use a standard sprite.

3
SFML website / Think This Is A Typo
« on: January 03, 2014, 11:28:06 pm »
On this page:
http://www.sfml-dev.org/tutorials/2.0/graphics-draw.php

You have this text in the Off-screen drawing section:
sf::Texture& texture = renderTexture.getTexture();

// draw it to the window
sf::Sprite sprite(texture);

I think the ampersand is a typo.

4
Graphics / Failing To Load Font
« on: January 03, 2014, 10:52:12 pm »
My program:

int main()
{
        sf::Font font;
        if (!font.loadFromFile("Xolonium-Regular.otf"))
        {
                // error...
        }
    sf::RenderWindow window(sf::VideoMode::getDesktopMode(), "SFML works!", sf::Style::Fullscreen);
        window.setVerticalSyncEnabled(true);

        sf::Text title;
        title.setFont(font); // font is a sf::Font
        title.setString("Hello World!");
        title.setCharacterSize(64); // in pixels, not points!
        title.setColor(sf::Color::White);

    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
                        switch (event.type)
                        {
                                case sf::Event::KeyPressed: //Key pressed
                                        switch (event.key.code)
                                        {
                                        case sf::Keyboard::Escape:
                                                window.close();
                                                break;
                                        }
                                        break;
                        }
        }

        // clear the window with black color
        window.clear(sf::Color::Black);
               
        window.draw(title);
        window.display();
    }

    return 0;
}

Displays this weird text in the command prompt:



And displays this dialog:



According to this thread, OTF format should be supported:
http://en.sfml-dev.org/forums/index.php?topic=72.0

When I open the font it works fine to view in Windows. It's a font that's available on this site here:
http://www.fontspace.com/severin-meyer/xolonium

The font is in the same directory as sfml-graphics-2.dll and others... which I assume is the correct directory. It seems awfully strange if this is simply failing to find the file.

5
Graphics / Creating Large Number Of Stars Efficiently
« on: January 03, 2014, 10:15:23 pm »
I'm hoping to create a background which is randomized with lots of stars for a space-themed game. The stars all move in the same direction at the same time to simulate motion. There will be a lot of them, and I'd really like to create an efficient system.

I want it randomized, so it's not the same graphic over and over. What is the most efficient way to do this?

Do I want to create an array of star objects, similar to this code which doesn't work:

Quote
sf::CircleShape stars[] = sf::CircleShape[500];

Or is it recommended to do something more fancy, such as creating a random Image on the fly which is then moved in one piece?

Pages: [1]