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 - 10kw10

Pages: [1]
1
SFML projects / I am searching for people to sfml project - Grand Killer
« on: December 14, 2018, 10:54:02 pm »
I started project in SFML called Grand Killer a year ago. I am searching for people who just help me with this project. If you want to ask me about project just email me: jwolsza@gamesture.com

Some screenshots are below.
Link for download: http://www.mediafire.com/file/jaxcf0wc1xk9a08/Grand+Killer.rar

2
General / SFML View and OpenGL
« on: January 05, 2018, 10:31:12 pm »
I have code:
#include <SFML/Graphics.hpp>
#include <SFML/OpenGL.hpp>
#include <GL/glut.h>
int main()
{
        sf::ContextSettings contextSettings;
        contextSettings.depthBits = 24;
        contextSettings.sRgbCapable = false;

        sf::RenderWindow window(sf::VideoMode(800, 600), "SFML graphics with OpenGL", sf::Style::Default, contextSettings);
        window.setVerticalSyncEnabled(true);

        sf::View view(sf::Vector2f(0, 0), sf::Vector2f(400, 300));

        sf::Texture texture;
        if (!texture.loadFromFile("texture.jpg"))
                return EXIT_FAILURE;

        glEnable(GL_DEPTH_TEST);
        glDepthMask(GL_TRUE);
        glClearDepth(1.f);

        glViewport(0, 0, window.getSize().x,window.getSize().y);

        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        glLoadMatrixf(view.getTransform().getMatrix());

        sf::RectangleShape shape(sf::Vector2f(100, 100));

        static const GLfloat cube[] =
        {
                -20, -20, -20,  0, 0,
                -20,  20, -20,  1, 0,
                -20, -20,  20,  0, 1,
                -20, -20,  20,  0, 1,
                -20,  20, -20,  1, 0,
                -20,  20,  20,  1, 1,

                20, -20, -20,  0, 0,
                20,  20, -20,  1, 0,
                20, -20,  20,  0, 1,
                20, -20,  20,  0, 1,
                20,  20, -20,  1, 0,
                20,  20,  20,  1, 1,

                -20, -20, -20,  0, 0,
                20, -20, -20,  1, 0,
                -20, -20,  20,  0, 1,
                -20, -20,  20,  0, 1,
                20, -20, -20,  1, 0,
                20, -20,  20,  1, 1,

                -20,  20, -20,  0, 0,
                20,  20, -20,  1, 0,
                -20,  20,  20,  0, 1,
                -20,  20,  20,  0, 1,
                20,  20, -20,  1, 0,
                20,  20,  20,  1, 1,

                -20, -20, -20,  0, 0,
                20, -20, -20,  1, 0,
                -20,  20, -20,  0, 1,
                -20,  20, -20,  0, 1,
                20, -20, -20,  1, 0,
                20,  20, -20,  1, 1,

                -20, -20,  20,  0, 0,
                20, -20,  20,  1, 0,
                -20,  20,  20,  0, 1,
                -20,  20,  20,  0, 1,
                20, -20,  20,  1, 0,
                20,  20,  20,  1, 1
        };

        glEnableClientState(GL_VERTEX_ARRAY);
        glEnableClientState(GL_TEXTURE_COORD_ARRAY);
        glVertexPointer(3, GL_FLOAT, 5 * sizeof(GLfloat), cube);
        glTexCoordPointer(2, GL_FLOAT, 5 * sizeof(GLfloat), cube + 3);

        glDisableClientState(GL_NORMAL_ARRAY);
        glDisableClientState(GL_COLOR_ARRAY);

        while (window.isOpen())
        {
                sf::Event event;
                while (window.pollEvent(event))
                {
                        if (event.type == sf::Event::Closed)
                                window.close();

                        if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Escape))
                                window.close();
                }

                if (sf::Keyboard::isKeyPressed(sf::Keyboard::W))
                        view.move(0, 5);
                else if (sf::Keyboard::isKeyPressed(sf::Keyboard::S))
                        view.move(0, -5);

                window.setView(view);

                window.clear();

                window.pushGLStates();

                window.popGLStates();

                glClear(GL_DEPTH_BUFFER_BIT);

                glMatrixMode(GL_MODELVIEW);
                glLoadIdentity();
                glTranslatef(40, 0, -50.f);

                glEnable(GL_TEXTURE_2D);
                sf::Texture::bind(&texture);
                glDrawArrays(GL_TRIANGLES, 0, 36);

                window.pushGLStates();
                window.draw(shape);
                window.popGLStates();

                window.display();
        }

        return EXIT_SUCCESS;
}
 
and have problem because i want to move view and Opengl stuff move too.
I know that there is a problem
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glLoadMatrixf(view.getTransform().getMatrix());

After add this line:
glLoadMatrixf(view.getTransform().getMatrix());
object OpenGL just fade away.

Can u tell me how exactly i can do this ? 3D effect will be still visible ?
Thanks
PS. sorry for my english ;)

Pages: [1]
anything