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

Pages: [1]
1
Graphics / using views with a "background" of unlimited size
« on: May 21, 2010, 08:56:49 am »
I've just run the graphics-views.cpp tutorial here
http://www.sfml-dev.org/tutorials/1.6/graphics-views.php

I'd like to modify it so that a user can set up a grid of cells...
where each cell is a coloured rectangle of fixed size
with the first so-many digits on it i.e. nothing fancy.

The thing is...
I want the grid size to be specified at run time,
i.e. avoiding statements like "Background.Resize(2000, 2000);"
which fixes the size of the background at compile time.
I'd like to start with one cell (top left) and have the user add cells
by pressing either the right or down arrow keys.

I used such unlimited pads in both ncurses and wxpython.

Any thoughts much appreciated
Rgds
Dean

2
Python / SFML and wxpython playing nicely
« on: February 24, 2010, 09:38:53 pm »
Before discovering SFML I wrote some stuff in Python/wxpython.
I'm now wondering if the two could "play" nicely together
eg
   stop the C++/SFML animation
   open a wxpython gui window on top of the SFML animation
   & do things like...
      show the SFML cursor's x,y values in the gui &
      modify them so that the SFML cursor would move on closure of the gui

Any thoughts/advice re this sort of communication would be very much appreciated

edit1:
Code: [Select]

http://www.sfml-dev.org/forum/viewtopic.php?t=1126&sid=acf2a5245ad6fcd4e925af795cd48b57

explains the difficulties in 2007 of using wxwidgets from python.
I seem to be trying to do the reverse using wxpython from C++

edit2:
Thx for moving this thread.

This may be more of a C++/Python thing than a wxpython/SFML one so I'm trying to embed Python/wxpython into C++.
If it doesn't work I'll come back with some more meaningful questions
so it prolly best to hang fire on answering this thread, for now.

Rgds

3
Graphics / getting the best performance when animating text strings
« on: February 15, 2010, 04:19:06 pm »
I'm currently animating text strings by repeating these lines ie...
Code: [Select]

       App.Clear();
       Text.SetText(  Some_function_that_returns_a_string()  );
       App.Draw(Text);
       App.Display();

once for each frame ie by placing them inside a loop.
My full example is here...
Code: [Select]

http://www.sfml-dev.org/forum/viewtopic.php?t=2189&highlight=


Ultimately many strings will be displayed on screen but most won't change from frame to frame.  
The way I'm doing it now, I think I have to Text.SetText() every string that gets displayed
ie even those strings that don't change between frames
which seems wasteful.

Additionally, I was recently advised that...
Code: [Select]

The number one mistake people make in doing text apps in OpenGL is
they do not cache individual character glyphs as textures.
They either reconvert from the font (very slow) each time they draw a character
or
they upload the glyphs (slow) each time they draw the character.
If you create each glyph as a texture with only the alpha plane
you can scale the characters to any size you need and paint them any way you want
and since modern graphics cards are designed to render textures you get the best speed possible.


How can I speed up my program to take account of the above advice and that most strings will not change between frames.

Thank you in anticipation.

4
Graphics / blocking keypress
« on: February 14, 2010, 04:13:13 pm »
This is my first program built from the samples and source codes.
I'm pleased to see the facility for non-blocking keyboard input
but I would also like to single step through a frame at a time.

Can someone please show me how to modify this program so that you can  use eg the spacebar to step through the program a frame at a time.

Thank you in anticipation


Code: [Select]

//just testing display of set with capacity of 1000 that gets filled then emptied
//g++ text_opengl.cpp -lsfml-graphics -lsfml-window -lsfml-system -lGLU -lGL
#include <SFML/Graphics.hpp>
//#include <SFML/Graphics/Color.hpp>  //Red, this include already included by <SFML/Graphics.hpp>?
#include <iostream>
#include <string>              
#include <iomanip>              //setprecision
#include <sstream>              //stringstream
#include <math.h>              //log10
using namespace std;

string Set_string(int capacity, int items_in_set){
   int max_digits;
   int items_digits;
   stringstream ss;
   if (capacity > 0) {max_digits = ( (int) log10(capacity) + 1 );}
   else {max_digits = 0;}
   if (items_in_set > 0){items_digits = ( (int) log10(items_in_set) + 1 );}
   else {items_digits = 0;}
   int leading_0s = max_digits - items_digits;
   ss << string(leading_0s,'0') << items_in_set;
   return ss.str();
}

int Display_set(){
    sf::RenderWindow App(sf::VideoMode(800, 600), "SFML_App");

    sf::Font TextFont;
    if (!TextFont.LoadFromFile("/home/me/Desktop/bench/cheeseburger.ttf", 30)) {return 1;}

    const char * String = "AZERTYUIOPQSDFGHJKLMWXCVBNazertyuiopqsdfghjklmwxcvbn0123456789";
    sf::String Text(String, TextFont, 30.f);
   
    Text.SetColor(sf::Color::Red);  
    Text.SetX(50.f);
    Text.SetY(10.f);

    int capacity = 100, i=0, count_up=1;  //i simulates the qty of items in set with capacity for 1000 of them

    while ( App.IsOpened() ){

       //This is non-blocking!
       sf::Event Event;
       while ( App.GetEvent(Event) ){
          if (Event.Type == sf::Event::Closed) {App.Close();} //mouse click window close or alt/F4
          if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape)) {App.Close();} //Esc key
       }

       App.Clear();
       Text.SetText(  Set_string(capacity,i)  );
       App.Draw(Text);
       App.Display();

       if (count_up){ if (i<capacity) i++; }
       else         { if (i>0) i--;    }
       if (i == capacity) {count_up=0;}
    }
   return 0;
}

int main(){
   Display_set();
   return 0;
}



5
General / gluPerspective
« on: February 08, 2010, 07:56:19 pm »
I've been looking at the window-opengl tutorial ie...

   //http://www.sfml-dev.org/tutorials/1.3/window-opengl.php

which I'm compiling with...

   g++ -o window-opengl window-opengl.cpp -lsfml-graphics -lsfml-window -lsfml-system

The sticking point seems to be the line...

    gluPerspective(90.f, 1.f, 1.f, 500.f);

ls /usr/lib/libGLU* gives me...

    /usr/lib/libGLU.a  
    /usr/lib/libGLU.so.1            DIR
    /usr/lib/libGLU.so              DIR
    /usr/lib/libGLU.so.1.3.070300

so libGLU looks to exist.
I tried compiling with "-lglu" added in but this didn't work.
I'm not sure if this is the right specification or if its got to be in a certain place in the line.

Any suggestions much appreciated.

6
General / libsfml-graphics.so.1.4-1084: cannot open shared object fil
« on: February 08, 2010, 04:13:10 pm »
Thanks for creating sfml.
I think it's just what I've been looking for.

I've downloaded "SFML-1.5-sdk-linux-64.tar.gz"
and installed it on my phenom
runnning crunchbang linux 9.04.01 using...
make
sudo checkinstall &
make sfml-samples

Before realising that the sdk already provides the external libraries,
I installed them with...apt-get build-dep libsfml
(I was going to apt-get sfml too but only the C bindings are available on this distro)
My assumption is that the external libraries in the sdk have updated those that I previously installed with apt-get, where necessary. I may be wrong.

Some of the samples run ok ie...
opengl
pong
post-fx

the following samples don't ie...
qt
window
wxwidgets
X11

due to...
"error while loading shared libraries:libsfml-graphics.so.1.4-1084:cannot open shared object file"

libsfml-graphics.so.1.4-1084 doesn't sound right in version 1.5 and
"/usr/lib$ dir |grep libsfml-graphics" seems to "agree" by showing
libsfml-graphics.so.1.5
as a likely replacement.

I've crawled all over the dir looking for "1.4" in the hope that I could change it to 1.5 but I'm not seeing it.

Any advice to resolve this would be much appreciated.
Regards

Pages: [1]
anything