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

Pages: [1]
1
Window / Re: Cannot draw 2D elements with modern OpenGL
« on: June 04, 2015, 11:05:34 pm »
Hi Nexus.

I think that this is a very minimal example that fits to my game structure and shows that 2D elements are not appearing in the screen. There are only three functions to draw a 3D triangle and a 2D shape, and one of them is just to compile shaders, so you can ignore it. Furthermore, as SpeCter said, I think that is not a good idea remove shaders using OpenGL 3.3. ;D

And about resetGlStates(), it doesn't matter if you put or not this function; you will get the same result (in this case). I just put it in one of my tests.

Regards!


2
Window / Cannot draw 2D elements with modern OpenGL
« on: June 04, 2015, 09:50:46 pm »
Hi!

I'm trying to draw some 2D elements mixed with some 3D elements using OpenGL 3.3, but 2D elements never appears in the screen.

I prepared a full example to test this issue:
http://pastebin.com/BvJbK5K9

Some info:
- SFML: I tried it with version 2.1 and 2.3 with the same result.
- OS: Win7 64b (but game is compiled in x86).

Can anybody help me to make this works?

Thanks!!

3
Graphics / Re: sf::Texture and std::vector error
« on: January 12, 2013, 08:20:23 pm »
I see... then I'll move it to another container. Thank you Nexus!

PS: I've tryied to search it, but I don't found nothing (maybe I haven't know how to search it...), and I'll try to follow the rules better next time.  :-[


4
Graphics / sf::Texture and std::vector error
« on: January 12, 2013, 07:51:54 pm »
Hi! I'm newbie in STL use and I'm doing some tests with a vector of my own class. The code:
class Animation{
        sf::Texture m_texture;
        sf::Sprite m_image;
        // Other stuff
       
public:
        // Constructors
        Animation(){}
        Animation (std::string file){
                m_texture.loadFromFile(file);
                m_image = sf::Sprite(m_texture);
                // ...
        }
        Animation (const Animation& anim){ // Copy constructor
                m_texture = sf::Texture(anim.m_texture);
                m_image = sf::Sprite(anim.m_image);
                // ...
        }
       
        // get the sprite to draw      
        sf::Sprite& getSprite(){
                return m_image;
        }
};
 

class Game{
        std::vector <Animation> m_player;
        // ...
       
public:
        Game(){}
       
        void run(sf::RenderWindow *m_window){
                loadLevel(); // Load players and so on...
               
                // Load players, method 2 (with this game works fine)
                /*Animation a("001.png"), b("002.png");
                m_player.push_back(a);
                m_player.push_back(b);*/

               
                while (m_window->isOpen()){
                        sf::Event event;
                        while(m_window->pollEvent(event)){
                                if(event.type == sf::Event::Closed || (event.type == sf::Event::KeyReleased && event.key.code == sf::Keyboard::Escape)){
                                        m_window->close();
                                }
                        }
                       
                        m_window->clear();
                        for (std::vector<Animation>::iterator i = m_player.begin(); i < m_player.end(); i++){ // Draw the animations
                                m_window->draw((*i).getSprite()); // Here I get the error
                        }
                        m_window->display();
                }
               
                unloadLevel();
        }
       
       
        void loadLevel(){
                Animation a("001.png");
                Animation b("002.png");
                m_player.push_back(a);
                m_player.push_back(b);
        }
       
       
        void unloadLevel(){
                m_player.clear();
        }
};

int main(int argc, char **argv){
        sf::RenderWindow window(sf::VideoMode(800, 600), "SFML window");
        Game game;
        game.run(&window);
       
        return 0;
}

The problem is that, when I use "loadLevel()" to load my animations, I get an error when I try to show them, or get an empty texture (the shape of the image filled in blank), but when I use the "method 2" instead of "loadLevel()" it works fine...

Any idea?

I'm using SFML 2.0 with CodeLite 5570 (Win7 x64).

Thank you.

PS: You can download the project from HERE

5
Graphics / [SOLVED] Sprite resize error
« on: November 02, 2011, 01:26:04 pm »
Thank you, TheCake.

I finally solved it using a temporal sprite and then copying it to my sprite variable.

 :D

6
Graphics / [SOLVED] Sprite resize error
« on: October 28, 2011, 02:30:38 pm »
I load an image with:
Code: [Select]
sf::Image img;
sf::Sprite sprite;

img.LoadFromFile("myimage.png"); // An image of 480x530 px
img.SetSmooth(0);

sprite.SetImage(img);
sprite.SetPosition(0, 0);
sprite.Resize(480, 530);


and when I show it with App.Draw (sprite); there's no problem. But then I change the image with:
Code: [Select]
img.LoadFromFile("biggerimage.png"); // An image of 500x500 px
sprite.SetImage(img);
sprite.Resize(480, 530);


then the image looks 500x500 size but cutted to 480x530, so it looks ugly.

How can I change an sprite image into a bigger image and resize it correctly?

7
Window / [SOLVED] App chash when minimize
« on: October 24, 2011, 04:22:20 pm »
Here it is ^^.

Just copy all to main.cpp and compile.

Code: [Select]
// INCLUDES
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
#include <SFML/Network.hpp>
#include <SFML/Audio.hpp>

#include <string.h>
#include <stdlib.h>
#include <stdio.h>

#include <ios>
#include <iostream>
#include <fstream>
#include <ctime>


typedef struct{
int panoramica; // 1 for panoramic, 0 for 4:3
int proporcional; // 1 to keep aspect ratio
}SYSTEM;


// GLOBALS
SYSTEM sys;
sf::RenderWindow App;


int main(){

App.Create(sf::VideoMode(1024, 768, 32), "Minimize error");
App.SetFramerateLimit(60);
App.SetPosition(0,0);
App.Clear(sf::Color::Black );

sys.panoramica = false;
sys.proporcional = true;



const sf::Input& Input = App.GetInput();

// Main Loop
int i = 0;
    while (App.IsOpened()){

        sf::Event Event;
        while (App.GetEvent(Event)){

            // Close app(ESC)
            if (Event.Type == sf::Event::Closed || (Event.Type == sf::Event::KeyPressed && Event.Key.Code == sf::Key::Escape) ){
sf::Sleep (0.5);
App.Close();
}

// Keep aspect ratio
if (Event.Type == sf::Event::Resized){
if (sys.panoramica ){
if (sys.proporcional && ( (App.GetHeight()*100 / App.GetWidth() != 56) && (App.GetHeight()*100 / App.GetWidth() != 60) ) ){
App.SetSize(App.GetWidth(), ( App.GetWidth() * 60 / 100) );
}
}else{
if (sys.proporcional && (App.GetHeight()*100 / App.GetWidth() != 75)){
App.SetSize(App.GetWidth(), ( App.GetWidth() * 75 / 100) );
}
}
}

}
       


        // Clean the screen
App.Clear(sf::Color::Black );
App.Display();
sf::Sleep (0.1);
    }

sf::Sleep(1);
fflush (stdin);
    return EXIT_SUCCESS;
}



EDIT: The problem was in App.GetWidth(), which at minimize window return 0, so there's a zero division. I solved it with:
Code: [Select]
// Keep aspect ratio
if (Event.Type == sf::Event::Resized){
if (App.GetHeight() > 10 && App.GetWidth() > 10){
if (sys.panoramica ){
    ...


Thank you, Laurent!

8
Window / [SOLVED] App chash when minimize
« on: October 24, 2011, 04:02:34 pm »
But it only crash when I minimize the window. When I resize it there's no problem.

Could I know when the minimize button is pushed? Some event or something like this.

9
Window / [SOLVED] App chash when minimize
« on: October 24, 2011, 12:38:21 pm »
Hi!

I have write a code to keep aspect ratio in my app, but when I minimize the window, my app crash.

The code is:
Code: [Select]
// sys.panoramica is 1 if resolution screen is panoramic
// sys.proporcional set if we will keep the aspect ratio

sf::Event Event;
while (App.GetEvent(Event)){

        // keep aspect
if (Event.Type == sf::Event::Resized){
if (sys.panoramica ){
if (sys.proporcional && ( (App.GetHeight()*100 / App.GetWidth() != 56) && (App.GetHeight()*100 / App.GetWidth() != 60) ) ){
App.SetSize(App.GetWidth(), ( App.GetWidth() * 60 / 100) );
}
}else{
if (sys.proporcional && (App.GetHeight()*100 / App.GetWidth() != 75)){
App.SetSize(App.GetWidth(), ( App.GetWidth() * 75 / 100) );
}
}
}
}


Some idea?  :?

I'm using Win7-32, CodeLitte and SFML 1.6

10
Window / That annoying little window
« on: August 09, 2011, 12:37:09 pm »
If you need the console window but you don't want to show it always, you can use this code to show/hide it:

Code: [Select]
#include <windows.h>

//----------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------
class ConsoleWindow{
//----------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------
private:
HWND CONSOLE;

public:
ConsoleWindow(void);
void HideConsoleWindow (void);
void ShowConsoleWindow (void);
};


//----------------------------------------------------------------------------------------------------
ConsoleWindow::ConsoleWindow (void){
//----------------------------------------------------------------------------------------------------
SetConsoleTitle("- Console Window -");
sf::Sleep(1);
this->CONSOLE = FindWindow(NULL, "- Console Window -");
}

//----------------------------------------------------------------------------------------------------
void ConsoleWindow::HideConsoleWindow (void){
//----------------------------------------------------------------------------------------------------
ShowWindow(this->CONSOLE, SW_HIDE);
}

//----------------------------------------------------------------------------------------------------
void ConsoleWindow::ShowConsoleWindow (void){
//----------------------------------------------------------------------------------------------------
ShowWindow(this->CONSOLE, SW_SHOW);
}

11
Window / [SOLVED] Window Size problem
« on: May 27, 2011, 02:52:30 pm »
I solved it checking if height is correct and then, adapting my resize system to the height-titlebar_size:

Code: [Select]
sys.width = 1280;
sys.height = 800;
sys.bpp = 32;
sys.titlebar = 0; // titlebar size

* * *

sf::Window proof;
proof.Create(sf::VideoMode(sys.width, sys.height, sys.bpp), "");
sys.titlebar = sys.height - proof.GetHeight();
proof.Close();

if (sys.titlebar != 0){
sys.height -= sys.titlebar;
}

* * *
App.Create(sf::VideoMode(sys.width, sys.height+sys.titlebar, sys.bpp), title);


Thanks for the help, Laurent!

12
Window / [SOLVED] Window Size problem
« on: May 27, 2011, 01:42:55 pm »
taskbar isn't the problem because when I start my program I can see it down the taskbar. I think the problem is titlebar. Do you know if it's size is always 22 pixels?

13
Window / [SOLVED] Window Size problem
« on: May 27, 2011, 03:08:23 am »
Hi! I have some problems with my window size. I mean, I do that:

Code: [Select]
// 1280x800x32 is my desktop configuration
sys.width = 1280;
sys.height = 800;
sys.bpp = 32;

*  *  *

sf::RenderWindow App;
char title[100] = "";
sprintf (title, "Storm Alarm %d.%d.%d", sys.version, sys.revision, sys.beta);
App.Create(sf::VideoMode(sys.width, sys.height, sys.bpp), title);
App.SetFramerateLimit(15);
App.SetIcon(39, 38,  Icon.GetPixelsPtr() );
App.SetPosition(0,0);
printf ("Width: %d  Height: %d\n", App.GetWidth(), App.GetHeight());


But in DOS console I get:
Code: [Select]
Width:1280  Height: 778

And my window background is incompleted, as the titlebar was eatting up the image, but if I try with 1280x720 or minor I have no problem.

There is a screenshot with the window maximized:
SCREENSHOT

I'm using SFML 1.6, Windows 7 and CodeLite with g++.

Some idea?

PS: Sorry about my English -.-U

Pages: [1]
anything