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

Pages: [1]
1
Graphics / sf::VertexArray change color
« on: July 23, 2016, 03:19:31 pm »
/.../
std::list<sf::VertexArray*>   path_to_stars;
std::list<sf::VertexArray*>::iterator   it_path;

/.../

path_to_stars.push_back(new sf::VertexArray(sf::Lines, 2));

path_to_stars.back()->append(sf::Vector2f((*it)->star.getPosition()));
path_to_stars.back()->append(sf::Vector2f((*it2)->star.getPosition()));
path_to_stars.back()[1]->color(sf::Color(255, 255, 255, 255)) //wrong
path_to_stars.back()->color(sf::Color(255, 255, 255, 255)) //wrong
 

I know only how to change the color of the line by points, but hove i can change color in this situation?

2
General / Need help to connect OpenGl project with SFML
« on: April 07, 2016, 09:48:17 pm »
I have OpenGl project, but I can't connect it to sfml in any way, could someone help me to connect them?

#include <SFML/OpenGL.hpp>
#include <glut.h>

#include <cmath>

float f(float x, float y)
{
        return sin(x*y*0.0001)*100;
}

void display()
{
        glClear(GL_COLOR_BUFFER_BIT);
        for (float x = -480; x < 480; x += 10)
        {
                glBegin(GL_LINE_STRIP);
                for (float y = -480; y < 480; y += 10)
                        glVertex3f(x, y, f(x, y));
                glEnd();
        }
        for (float y = -480; y < 480; y += 10)
        {
                glBegin(GL_LINE_STRIP);
                for (float x = -480; x < 480; x += 10)
                        glVertex3f(x, y, f(x, y));
                glEnd();
        }
        glutSwapBuffers();
}

void timer(int = 0)
{
        display();
        glutTimerFunc(10, timer, 0);
}

int main(int argc, char **argv)
{
        glutInit(&argc, argv);
        glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
        glutInitWindowSize(480, 480);
        glutInitWindowPosition(20, 86);
        glutCreateWindow("3d plot");
        glClearColor(0, 0, 0, 1.0);

        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        glFrustum(-100, 100, -100, 100, 100, 2000);
        glMatrixMode(GL_MODELVIEW);
        glTranslatef(0, 0, -800);
        glRotatef(-30, 1, 0, 0);
        glutDisplayFunc(display);
        timer();
        glutMainLoop();
}

#include <SFML/Graphics.hpp>
 
int main()
{
        sf::RenderWindow window(sf::VideoMode(800, 600), "sdfs");
 
        while (window.isOpen())
        {
                sf::Event event;
                while (window.pollEvent(event))
                {
                        if (event.type == sf::Event::Closed)
                                window.close();
                }
 
                window.clear();

                window.display();
        }
 
        return 0;
}

I try to do this but only get errors such as screenshot in attachment. The project without sfml is completely working.
Sorry for my bad English

Pages: [1]
anything