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

Pages: [1]
1
Graphics / Drawing with resetGLstates
« on: September 30, 2014, 05:48:51 am »
I'm using in my project SFGUI. And for drawing I'm using following code:
void render()
{
        glDisableClientState(GL_COLOR_ARRAY);
        m_rWindow->pushGLStates();

        glTranslatef(m_pos.x, m_pos.y, 0.0f);
        glPointSize(1.0f);
        glColor3f(0.7f, 0.7f, 1.0f);
        glDisableClientState(GL_COLOR_ARRAY);
        glDisableClientState(GL_TEXTURE_COORD_ARRAY);
        float vertData[] = {20.0f, 20.0f, 50.0f, 50.0f };
        glEnableClientState(GL_VERTEX_ARRAY);
                glVertexPointer(2, GL_FLOAT, 0, vertData);
                glDrawArrays(GL_POINTS, 0, 2);
        glDisableClientState(GL_VERTEX_ARRAY);
        m_rWindow->popGLStates();

        m_rWindow->resetGLStates();
        m_sfgui.Display(*m_rWindow);

}

glDrawArrays(GL_POINTS, 0, 2); - is drawed nothing

Why? What can I do for correct it?

2
Graphics / Re: Error load Image
« on: January 15, 2014, 09:32:23 am »
As stated in the tutorials, you should not mix debug and release modes, i.e. you're linking the release libraries (without -d suffix) in debug mode. Change all the suffix to for example sfml-graphics-d.lib and it should work. :)
You're right! It works!

3
Graphics / Re: Error load Image
« on: January 15, 2014, 07:45:32 am »
#include <SFML\Graphics.hpp>
#include <iostream>

int main(int argc, char* argv[])
{
        sf::RenderWindow window(sf::VideoMode(640, 480), "SFML Render");
        sf::Image image;
        sf::Texture texture;
        sf::Sprite sprite;

        image.loadFromFile("D:/Project/Sprites/bt1.png");
        texture.loadFromImage(image);
        sprite.setTexture(texture);
        sprite.setPosition(100.0f, 100.0f);

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

                window.clear();
                window.draw(sprite);
                window.display();
        }

        return 0;
}

My configurations



code above is also crashes. Where I could go wrong?

4
Graphics / Re: Error load Image
« on: January 15, 2014, 07:22:11 am »
If even I use following:
DoRender.cpp
#include "TApp.h"

void TApp::DoRender()
{
        sf::Texture texture;
        texture.loadFromFile("D:/Project/CPP/Game_Engine/Debug/sprites/first.bmp");

        sf::Sprite sprite(texture);
        sprite.setPosition(100.0f, 100.0f);


        m_Window.clear();
        m_Window.draw(sprite);
        m_Window.display();
}
occurs only a crash program. I tried use different kinds of path:
  • D:/Project/CPP/Game_Engine/Debug/sprites/first.bmp
  • D:\\Project\\CPP\\Game_Engine\\Debug\\sprites\\first.bmp
  • d:\\Project\\CPP\\Game_Engine\\Debug\\sprites\\first.bmp
I use different files:
  • D:/Project/Sprites/bt.png
  • D:/Project/Sprites/anim.bmp
  • D:/Project/Sprites/boy.jpg
Compiler indicates at following line:
texture.loadFromFile("D:/Project/CPP/Game_Engine/Debug/sprites/first.bmp");
More precisely, Program crashes on this line.

5
Graphics / Re: Error load Image
« on: January 15, 2014, 05:59:24 am »
Okay. In this way, I tried to correct following:
TApp.h
#pragma once
#include <SFML\Graphics.hpp>


class TApp
{
public:
        TApp();

        int DoExecute();

private: /*MAIN FUNCTION*/
        void DoInputHandle();
        void DoUpdate();
        void DoRender();

private:
        sf::RenderWindow m_Window;
        sf::Texture m_texture;
        sf::Sprite m_sprite;
};

DoRender.cpp
#include "TApp.h"
#include <assert.h>
void TApp::DoRender()
{
        bool m = m_texture.loadFromFile("D:/Project/CPP/Game_Engine/Debug/sprites/first.bmp");
        assert(m == false);
        m_sprite.setTexture(m_texture);
        m_sprite.setPosition(100.0f, 100.0f);


        m_Window.clear();
        m_Window.draw(m_sprite);
        m_Window.display();
}
Not working! I remembered a relation between sf::Image - sf::Texture - sf::Sprite, and I thought that program is right now working, but not.
A few days ago I wrote following code:
main.cpp
#include <SFML\Graphics.hpp>
#include <boost\lexical_cast.hpp>
#include <iostream>
#include <string>

class Game
{
public:
        Game();
        void run();

private:
        void processEvent();
        void update(sf::Time deltaTime);
        void render();

private:
        sf::RenderWindow        mWindow;
};

int main()
{
        Game game;
        game.run();
        return 0;
}

Game::Game()
: mWindow(sf::VideoMode::getDesktopMode(), "SFML Window", sf::Style::Fullscreen)
{
}

void Game::run()
{
        sf::Clock clock;
        sf::Time timeSinceLastUpdate = sf::Time::Zero;
        const sf::Time TimePerFrame = sf::seconds(1.f / 60.f);
        while (mWindow.isOpen())
        {
                processEvent();
                timeSinceLastUpdate += clock.restart();
                while (timeSinceLastUpdate > TimePerFrame)
                {
                        timeSinceLastUpdate -= TimePerFrame;
                        processEvent();
                        update(TimePerFrame);
                }
                render();
        }
}

void Game::processEvent()
{
        sf::Event event;
        while (mWindow.pollEvent(event))
        {
                switch (event.type)
                {

                case sf::Event::Closed:
                        mWindow.close();
                        break;

                default:
                        break;
                }
        }
}

void Game::update(sf::Time deltaTime)
{
}

void Game::render()
{

        sf::Texture texture;
        texture.loadFromFile("D:/Project/CPP/Game_Engine/Debug/sprites/first.bmp");
       
        sf::Sprite sprite(texture);
        sprite.setPosition(100.f, 100.f);

        mWindow.clear();
        mWindow.draw(sprite);
        mWindow.display();
}
It's working. But why?? I confused.

I tried use also following:
#include "TApp.h"
#include <assert.h>
void TApp::DoRender()
{
        sf::Texture texture;
        bool m = texture.loadFromFile("D:/Project/CPP/Game_Engine/Debug/sprites/first.bmp");
        assert(m == false);
        sf::Sprite sprite(texture);
        sprite.setPosition(100.0f, 100.0f);


        m_Window.clear();
        m_Window.draw(sprite);
        m_Window.display();
}
 
Same error.

6
Graphics / Error load Image
« on: January 14, 2014, 08:24:36 pm »
I have follow code:
TApp.h
#pragma once
#include <SFML\Graphics.hpp>


class TApp
{
public:
   TApp();

   int DoExecute();

private: /*MAIN FUNCTION*/
   void DoInputHandle();
   void DoUpdate();
   void DoRender();

private:
   sf::RenderWindow m_Window;
   sf::Sprite m_sprite;
};

TApp.cpp
#include "TApp.h"

TApp::TApp()
: m_Window(sf::VideoMode(640, 480), "SFML Game Engine")
{
   sf::Texture texture;
   texture.loadFromFile("sprites/first.bmp");
   m_sprite.setTexture(texture);
}

int TApp::DoExecute()
{
   while (m_Window.isOpen())
   {
      DoInputHandle();
      DoUpdate();
      DoRender();
   }

   return 0;
}

int main(int argc, char* argv[])
{
   TApp application;
   return application.DoExecute();
}

DoInputHandle.cpp
#include "TApp.h"

void TApp::DoInputHandle()
{
   sf::Event event;

   while (m_Window.pollEvent(event))
   {
      switch (event.type)
      {
      case sf::Event::Closed:
         m_Window.close();
         break;

      default:
         break;
      }
   }
}

DoRender.cpp
#include "TApp.h"

void TApp::DoRender()
{
   m_Window.clear();
   m_Window.draw(m_sprite);
   m_Window.display();
}

DoUpdate.cpp
#include "TApp.h"

void TApp::DoUpdate()
{
}

It's very very simple. But haven't work. :(
Where may be an error?


Pages: [1]
anything