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.


Topics - Ardeshir81

Pages: [1]
1
Window / How to simulate keyboard/mouse press with SFML?
« on: March 07, 2014, 06:12:33 pm »
HI Everyone !
Is it possible to simulate a key press with SFML ?
I mean can SFML press a key for me ?

The reason I want this is that I'm writing a program which waits for some time (entered by user) and then runs a kernel command . (Linux Ubuntu 13)
But sometimes when the command is "sudo apt-get install ..." it requires a password and a confirmation which is done by pressing 'y' ;
Do you think I'm doing the right thing ?
Is there a better solution to do this or I should keep looking for key press simulation ?


+ :
I tried searching using forum's search BUT I faced this message :

Database Error
Please try again. If you come back to this error screen, report the error to an administrator.

Who is this administrator ?

2
Window / Can't save and load ContextSettings and WindowHandle
« on: October 22, 2013, 12:51:21 am »
HI !
I'm beginner and trying to write a simple app which creates a basic window based on properties the user enters .
Now I want to try to save the current state and load it later , thus I'm using a struct :
struct SLInfo
{
    sf::ContextSettings winMainSettings ; //winMain.getSettings ()
    sf::WindowHandle winMainSystemHandle ; //winMain.getSystemHandle ()
}

and a function to save :
int SaveCurrentState (sf::RenderWindow & winMain)
{
    SLInfo Info ;
    ofstream SaveFile ("some_file" , ios::binary) ;
    Info.winMainSettings = winMain.getSettings () ;
    Info.winMainSystemHandle = winMain.getSystemHandle () ;
    SaveFile.write (reinterpret_cast <char *> (& Info) , sizeof (Info)) ;
    return 1 ;
}
(is that refrence sign (&) before winMain correct?)
(Most of the code is omitted so that it looks simple and easier for you to check it)


and a function to load :
SLInfo LoadFile (string FileName)
{
    ifstream LoadLoc (FileName.c_str () , ios::binary) ;
    SLInfo Loader ;
    LoadLoc.read (reinterpret_cast <char *> (& Loader) , sizeof (Loader)) ;
    return Loader ;
}

Then in another function I open the window like this :
SLInfo winMainInfo ;
    string FileName ;
    cout << "\nEnter file name :\n" ;
    cin >> FileName ;
    winMainInfo = LoadFile (FileName.c_str ()) ;
    sf::RenderWindow winMain (winMainInfo.winMainSystemHandle , winMainInfo.winMainSettings) ;
(+ while window.isOpen () and event handlings , I omitted those parts too)

But when I run it (using Code::Blocks 12.11) I see these messages in console :
Failed to set pixel format for device context -- cannot creat OpenGL context
Failed to activate the window's context
Failed to activate the window's context
 
And I see no window at all .
Thanks in advanced for helping.
And if there is any additional info on my code needs to be provided let me know .
Thanks .

3
Graphics / I can't draw a sprite in RenderWindow
« on: October 19, 2013, 12:00:21 pm »
HI !
I am new to SFML .
I wanted to make a window and show a picture inside it .
I create the window correctly and the picture is loaded correctly , BUT I still can't display the sprite .
What I did is I created a RenderWindow and I tried to loadFromFile a sprite , BUT I saw an error indicating its not possible , so I loadeFromFileED a texture and setTextureED the sprite .
BUT I still can't observe the picture .
This is my code :
#include <SFML/graphics.hpp>
#include <iostream>

using std :: cout ;

int main ()
{
    sf::RenderWindow winMain (sf::VideoMode(800,600),"Test") ;
    sf::Texture winTexture ;
    if (!winTexture.loadFromFile("Untitled.jpg"))
    {
        cout << "ERROR opening Untitled.jpg" ;
    }
    sf::Sprite winSprite ;
    winSprite.setTexture(winTexture) ;
    winMain.display() ;
    while (winMain.isOpen())
    {
        sf::Event winEvent ;
        while (winMain.pollEvent(winEvent))
        {
            winMain.draw(winSprite) ;
            winTexture.update (winMain) ;
            switch (winEvent.type)
            {
            case sf::Event::Closed :
                winMain.close() ;
                break ;
            }
        }
    }
}
 
Thnaks !

4
System / cout operator << doesn't work for getElapsedTime ()
« on: October 02, 2013, 08:56:06 pm »
HI !
I'm new to sfml .
I was just testing time functions and I tried to use this :
cout << clock.getElapsedTime () ;
then i saw this error : "no match for operator << ..."

I tried this :
cout << (sf::Int64) clock.getElapsedTime () ;
BUT I got invalid cast error .

I'm wondering if there is any way to output elapsed time directly without converting it to sf::Time .
Thanks !

5
HI!
I'm beginnger !
I have read the tutorial on setting up sfml (2.1) with CodeBlocks and I pasted the sample code (The one which draws a green circle with caption "IT WORKS") and CodeBlocks messaged : 0 errors , 0 warnings .
But when I ran the program I get this error :
"The program can't start because sfml-graphics-2.dll is missing from our computer."
So I copied all the .dll s in bin folder (from sfml) to debug folder of my project , in the same folder that the executable is created .

Then that error gone and a new one appears :
"The procedure entry point_gxx_personality_v0 could not be located in the dynamic link library libstdc++-6.dll ."

I am using CodeBlocks 12.11 gcc 4.7.1 windows 32 bit .
THank YOU !

Pages: [1]