Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: SFML doesn't work on my laptop  (Read 1591 times)

0 Members and 1 Guest are viewing this topic.

danielmarg

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
SFML doesn't work on my laptop
« on: December 28, 2012, 02:28:18 pm »
Hi guys,

this code won't work on my laptop. I've a Lenovo x220 with an Intel HD graphics card and I'm working on Windows 8. I tried SFML on my PC with Windows 8 and it worked but unfortunately I have no access to my PC right now.
I can run the code and the program starts but the window isn't shown. The window is in the task bar but I cannot move it to the foreground. The command line is visible.

#include "GLSL.h"

#include <SFML\OpenGL.hpp>
#include "Importer.hpp"
#include "mesh.h"
#include "scene.h"
#include "postprocess.h"
#include "glm.hpp"
#include "gtc/matrix_transform.hpp"

#include "glutil.h"

#include <iostream>
#include <string>
#include <vector>

#include "PhongNormalMapModel.h"
#include "ToonModel.h"
#include "SimpleModel.h"
#include "Arcball.h"

using namespace std;
using namespace cg2;

string          modelDirectory;
string          modelName = "angry";
float           shininess = 2;
aiVector3D      lightPos;
aiLight         light;

float scale;

void filterArguments(unsigned argc, char** args);
void setUpLight(aiVector3D const & position);
bool importModel(string filepath, string shaderpath, GLuint &normalAttributeLocation, GLuint &vertexAttributeLocation, GLuint &normalBufferObject, GLuint &vertexBufferObject, GLuint &indexBufferObject, unsigned &indicesCounter, Program &program);

int main( int argc, char** argv )
{
        scale = 1;

        sf::Window window(      sf::VideoMode( 800, 800, 32 ),
                                                "non gaudeamus igitur",
                                                sf::Style::Default,
                                                sf::ContextSettings( 16, 0, 8, 3, 3 )   );

        GLenum status = glewInit();
        if ( status != GLEW_OK )
        {
                cout << "GLEW initialization failure: " << glewGetErrorString( status ) << endl;
                return -1;
        }

        /*try
        {
                filterArguments(argc, argv);
        }
        catch (string& exception)
        {
                cout    << "Invalid arguments: " << exception << endl
                                << "Please use the program with the following argument list:" << endl
                                << "-d abs_path_to_model_directory -l lightX lightY lightZ" << endl;
                return -1;
        }*/


        //ToonModel model("..\\models\\stemcell.obj", "..\\models\\stemcell.png", "..\\toon", light, shininess);

        //SimpleModel lightModel("..\\models\\sphere.ply", "..\\simple");

        //ArcBall arcBall(model, window.getSize().x, window.getSize().y);

        /// construct view matrix
        glm::vec3 eyePosition( 0.f, 0.f, 5.f );
        glm::vec3 centerOfInterest( 0.f, 0.f, 0.f );
        glm::vec3 upVector( 0.f, 1.f, 0.f );
        glm::mat4 matView = glm::lookAt( eyePosition, centerOfInterest, upVector );

        /// construct projection matrix
        float aspectRatio = 800 / static_cast< float >( 800 );
        glm::mat4 matProjection = glm::perspective( 45.f, aspectRatio, 1.f, 10.f );

        /// timer (used for animation)
        sf::Clock timer;
       
        /// flag indicating whether mesh is displayed in wireframe mode
        bool bUseWireframeMode = false;

        glEnable(GL_DEPTH_TEST);

        //lightModel.m_matModel = glm::scale(lightModel.m_matModel, glm::vec3(0.125, 0.125, 0.125));
        //lightModel.m_matModel = glm::translate(lightModel.m_matModel, glm::vec3(light.mPosition.x, light.mPosition.y, light.mPosition.z));

        while( 1 )
        {
                sf::Event ev;
                bool exit = false;
                while (window.pollEvent(ev))
                {
                        if (ev.type == sf::Event::Closed)
                        {
                                exit = true;
                                break;
                        }
                        else if (ev.type == sf::Event::Resized)
                        {
                                glViewport( 0, 0, ev.size.width, ev.size.height );
                        }
                        else if (ev.type == sf::Event::KeyPressed)
                        {
                                if (ev.key.code == sf::Keyboard::W)
                                {
                                        //model.m_bUseWireframeMode = !model.m_bUseWireframeMode;
                                }
                        }
                        else if(ev.type == sf::Event::MouseWheelMoved)
                        {
                                if(ev.mouseWheel.delta > 0)
                                {
                                        //model.m_matModel = glm::scale(model.m_matModel, glm::vec3(2, 2, 2));
                                }
                                else if(ev.mouseWheel.delta < 0)
                                {
                                        //model.m_matModel = glm::scale(model.m_matModel, glm::vec3(0.5, 0.5, 0.5));
                                }
                        }
                        else if(ev.type == sf::Event::MouseButtonPressed)
                        {
                                auto actualPos = sf::Mouse::getPosition() - window.getPosition();
                                cout << actualPos.x << ", " << actualPos.y << endl;
                                //arcBall.onMouseButtonAction(actualPos.x, actualPos.y, true);
                        }
                        else if(ev.type == sf::Event::MouseButtonReleased)
                        {
                                //arcBall.onMouseButtonAction(sf::Mouse::getPosition().x, sf::Mouse::getPosition().y, false);
                        }
                        else if(ev.type == sf::Event::MouseMoved)
                        {
                                auto actualPos = sf::Mouse::getPosition() - window.getPosition();
                                //arcBall.onMouseMove(actualPos.x, actualPos.y);
                        }
                }
                if ( exit ) break;

                glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

                //model.draw(matView, matProjection);

                //lightModel.draw(matView, matProjection);



                //arcBall.update(matView);

                //model.update(timer.getElapsedTime().asSeconds());

                //lightModel.update(timer.getElapsedTime().asSeconds());

                timer.restart();


                window.display();
        }

        return 0;
}
 

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: SFML doesn't work on my laptop
« Reply #1 on: December 28, 2012, 08:18:21 pm »
Just because your code doesn't work like you expect it to work, doesn't mean that SFML doesn't work.
What I suspect is that your screen resolution height is smaller than 800px, thus the window 800x800 is too big to fit on the screen and it just doesn't show.
Afaik there's already a issue open on the SFML tracker, to give some feedback if the resolution is too big. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

danielmarg

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
Re: SFML doesn't work on my laptop
« Reply #2 on: December 28, 2012, 09:45:26 pm »
OMG. Thanks!!!!
Yeah I forgot to ask if I'm doing something wrong or it is a sfml issue.

 

anything