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

Pages: [1]
1
For sf::Key::Subtract, that only works for number pads. My laptop does not have one, so is there any way I can scan for a keypress in ASCII form or something so I can use the minus key next to backspace?

2
Graphics / [SFML 1.6] Drawing an sf::Image over OpenGL Rendering
« on: May 15, 2012, 11:56:16 pm »
Whenever I use App.Draw(sprite) over my window, it doesn't render to the screen.

Just a snippet...

while (App.IsOpened())
    {
        App.SetActive();

        PollInput();
        PositionCamera();

        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();
        gluLookAt(camx, camy, camz, 0, 0, 0, 0, 1, 0);

        gl_draw_axes(-50.0, 50.0, -50.0, 50.0, -50.0, 50.0, .5*(Distance/70)); // Draw axes

        Bar_sprite.SetPosition(30, 30);

        App.Draw(Bar_sprite);

        App.Display();
    }

In my headers, I load the image and it loads correctly. I have PreserveOpenGLStates(true) set at the top. What am i doing wrong?

3
General / Rotate using mouse without constraint of the window
« on: April 21, 2012, 09:08:23 pm »
I have a program where the camera rotates around an origin and that part works fine. My problem is that whenever I move the mouse off the screen, It stops rotating and loses the mouse handle. Then moving the mouse back into the window, whether clicked or not, causes SFML to believe that it is clicked. I would like to know if there is any way to reset the mouse position or some form of mouse grabbing where it won't move the mouse around the window, but merely detect the difference in movement between frames and reset the pointer location.

4
General / SFML cube rotation bug
« on: January 19, 2012, 05:37:18 pm »
I have placed removed the ambiguous resize check code outside the event loop and have placed my CheckEvents function inside the event loop, and the issue is still apparent. But thank you for the quick info.

5
General / SFML cube rotation bug
« on: January 18, 2012, 04:30:52 pm »
I've made a rotating colored cube using OpenGL and SFML. I've made it so that the size of the cube can be changed by using the up and down arrows, and the speed of rotation can be changed by using the left and right arrows. The issue I am having is that the speed of the cube rotating is faster/slower than it should be ONLY when i'm holding the keys. Can you guys figure out what's wrong?

Code: [Select]

#include <SFML/Window.hpp>
#include <iostream>
using namespace std;

void gl_init(void);
void gl_DrawCube(float size);
void CheckEvents(void);

sf::Clock Clock;
sf::Event Event;
sf::WindowSettings Settings;

int size = 10;
float speed = 1.f;

int main(int argc, char* argv[])
{
    Settings.AntialiasingLevel = 4;
    sf::Window App(sf::VideoMode(800, 600, 32), "SFML OpenGL", sf::Style::Close, Settings);

    App.SetFramerateLimit(90);
    App.UseVerticalSync(true);

    gl_init();


    while (App.IsOpened())
    {
            while (App.GetEvent(Event))
            {
            // Close window : exit
            if (Event.Type == sf::Event::Closed)
                App.Close();

            // Escape key : exit
            if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
                App.Close();

            // Resize event : adjust viewport
            if (Event.Type == sf::Event::Resized)
                glViewport(0, 0, Event.Size.Width, Event.Size.Height);
            }


                if (Event.Type == sf::Event::Resized)
                {
                    glViewport(0, 0, Event.Size.Width, Event.Size.Height);
                }

                App.SetActive();

                glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

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

                CheckEvents();

                glRotatef(speed*(Clock.GetElapsedTime() * 30), 1.f, 0.f, 0.f);
                glRotatef(speed*(Clock.GetElapsedTime() * 60), 0.f, 1.f, 0.f);
                glRotatef(speed*(Clock.GetElapsedTime() * 90), 0.f, 0.f, 1.f);

                gl_DrawCube(size);

         App.Display();
    }


    return EXIT_SUCCESS;
}


void gl_init(void)
{
    glClearDepth(1.f);
    glClearColor(0.5f, 0.25f, 0.5f, 0.f);

    glEnable(GL_DEPTH_TEST);
    glDepthMask(GL_TRUE);

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(90.f, 1.f, 1.f, 500.f);
}

void gl_DrawCube(float size)
{
    glBegin(GL_QUADS);

    glColor3f( 1.f, 0.f, 0.f);
    glVertex3f(-size, -size, -size);
    glVertex3f(-size,  size, -size);
    glVertex3f( size,  size, -size);
    glVertex3f( size, -size, -size);

    glColor3f( 0.f, 1.f, 0.f);
    glVertex3f(-size, -size, size);
    glVertex3f(-size,  size, size);
    glVertex3f( size,  size, size);
    glVertex3f( size, -size, size);

    glColor3f( 0.f, 0.f, 1.f);
    glVertex3f(-size, -size, -size);
    glVertex3f(-size,  size, -size);
    glVertex3f(-size,  size,  size);
    glVertex3f(-size, -size,  size);

    glColor3f( 1.f,0.5f, 0.5f);
    glVertex3f(size, -size, -size);
    glVertex3f(size,  size, -size);
    glVertex3f(size,  size,  size);
    glVertex3f(size, -size,  size);

    glColor3f( 1.f, 0.5f, 0.25f);
    glVertex3f(-size, -size,  size);
    glVertex3f(-size, -size, -size);
    glVertex3f( size, -size, -size);
    glVertex3f( size, -size,  size);

    glColor3f( 0.5f, 0.25f, 0.f);
    glVertex3f(-size, size,  size);
    glVertex3f(-size, size, -size);
    glVertex3f( size, size, -size);
    glVertex3f( size, size,  size);

    glEnd();
}


void CheckEvents(void)
{

            if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Up))
                {
                    size = size += 1;
                    cout << "Size is " << size << endl;
                }
            if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Down))
                {
                    size = size -= 1;
                    cout << "Size is " << size << endl;
                }
            if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Left))
                {
                    speed = speed -= 0.0025f;
                    cout << "Speed is " << speed << endl;
                }
            if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Right))
                {
                    speed = speed +=0.0025f;
                    cout << "Speed is " << speed << endl;
                }
}

Pages: [1]