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

Pages: [1]
1
General / Re: SFML doesn't work on my laptop
« 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.

2
General / 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;
}
 

Pages: [1]