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

Pages: [1] 2
1
Graphics / using views with a "background" of unlimited size
« on: May 22, 2010, 01:07:03 pm »
I've been working on that basis following your previous suggestion
so thanks for that.

2
Graphics / using views with a "background" of unlimited size
« on: May 21, 2010, 10:21:38 am »
Thanks very much for coming back and sorry for making a "meal" of it.
I'm not familiar with the terminology you're using
but it does give me something to look up.

Let me try to explain it another way.

1 user does nothing
cell|
----                          
                           
2 user presses right arrow    
cell | cell |                          
-----------                          
                                         
3 user pressess down arrow  
cell | cell |                        
---------------------            
cell | cell |                        
         
etc

The background grid will keep growing until the user
stops clicking the right and down arrow keys and presses DONE
at which time the size of the background gets fixed.


Is this more clear and, if so, is what you're suggesting still the solution?

EDIT:

Ahhh! I think I'm starting to see --- so you could have the background the same size as the view and just keep overwriting it with different cells?????

3
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

4
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

5
Graphics / getting the best performance when animating text strings
« on: February 15, 2010, 06:45:56 pm »
I'm really pleased to hear that this sort of caching is built-in.
That's great!

My program is very fast but I've only got one string in it at present.

I've been trying to formulate a question about the use of textures re the above but am struggling. I need to develop the above example further, to make the question clear and will come back when I've done this.

In the meantime...thank you very much for your help.

6
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.

7
Graphics / blocking keypress
« on: February 14, 2010, 09:01:53 pm »
Thanks very much

I notice that it's switched on now so thanks for enabling it in the code for my 1st post and turning it on now.

I've just revisited my 2nd post and it works fine.
I just forgot to show the 1st frame to start with and that threw me.

8
Graphics / blocking keypress
« on: February 14, 2010, 08:04:40 pm »
BTW I tried this
ie putting the drawing under the control of the Esc key
but no go

Code: [Select]

    while ( App.IsOpened() ){
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)) { //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;}
  }
        }
    }


I'm not sure why my code doesn't appear indented when I preview it
I am using code tags. Am I missing something??

9
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;
}



10
General / libsfml-graphics.so.1.4-1084: cannot open shared object fil
« on: February 10, 2010, 04:40:33 pm »
Cracked it!
I investigated your comments that I didn't have wxwidgets installed
and you were right. Crunchbang does come with some wxwidget packages but...

Compiling a wxwidgets test program showed that I was missing "wx-config".
I got it via "libwxgtk2.8-dev".

Similarly, a quick look at the makefile in /usr/lib/pkgconfig
showed that I was missing the gtk+-2.0.pc file
required by the makefile in SFML-1.5/samples/wxwidgets
(the include file was probably missing too).
I got them via "libgtk2.0-dev".

The sdk comes with the samples already compiled in samples/bin.
I deleted all executables in bin and ran "make sfml-samples".
Only "post-fx", "pong", "opengl" & "ftp" compiled,
leaving the original wxwidgets executable intact.
I'm thinking wxwidgets was probably compiled with 1.4
and that this is why it was looking for a 1.4 so.

To compile wxwidgets...
I went into SFML-1.5/samples/wxwidgets & typed "sudo make".
(Note: make without su status wasn't sufficient)
This produced "Main.o" & "wxSFMLCanvas.o".
I then linked with...
"g++ -o wxwidgets Main.o wxSFMLCanvas.o -lsfml-graphics -lsfml-window -lsfml-system `wx-config --libs` `pkg-config --libs gtk+-2.0`"
gleaned from the makefile.

"./wxwidgets" now displays a dialog.
On the right is a plain blue rectangle and...
on the left is a message box with a slider bar, below it.

Thx for sticking with me.

11
General / libsfml-graphics.so.1.4-1084: cannot open shared object fil
« on: February 09, 2010, 09:48:26 pm »
That's ok.
I've just
1) reinstalled my os,
2) downloaded only the 64 bit linux C++ sfml full sdk source package and checkinstall &
3)installed it using...
   make,
   sudo checkinstall and
   make sfml-samples

When I tried to run the wxwidgets sample I got the self-same error ie...

./wxwidgets
./wxwidgets: error while loading shared libraries: libsfml-graphics.so.1.4-1084: cannot open shared object file: No such file or directory

which suggests that the problem is inherent in the os binary itself.
I'll try re-installing the os and see if there's anything I can remove re sfml before downloading the sdk.

12
General / libsfml-graphics.so.1.4-1084: cannot open shared object fil
« on: February 09, 2010, 07:29:42 pm »
Yes you are right! Sorry for my clumsy/incomplete account.

Before realising that the Crunchbang package was just for C
and was not as up-to-date as the sdk
I did install the Crunchbang package.
However, I thought I had removed it with "apt-get remove --purge".
This appears to be the case below.

I installed the Crunchbang package again before installing the sdk
to increase my chances that all of the sdk's dependencies would be met.
I did this 'cos last week I was unable to install a number of the graphics
packages under consideration so that:
a) they ran
b) and included complete documentation and examples

Given this experience I'm afraid the fact that your sdk is self-sufficient came as a bit of a surprise to me, albeit a refreshing one.

It's helpful to know that the problem is probably due to apt's inability to completely tidy up.

Given your suggestions I tried to remove the dev package I installed.
I didn't know quite which one of the two it was so I tried to remove both.
As you can see in both cases apt tells me they are not installed.
ie
sudo apt-get remove --purge libsfml1.4-dev
Reading package lists... Done
Building dependency tree      
Reading state information... Done
Package libsfml1.4-dev is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 131 not upgraded.
&
sudo apt-get remove --purge libcsfml1.4-dev
Reading package lists... Done
Building dependency tree      
Reading state information... Done
Package libcsfml1.4-dev is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 131 not upgraded.

I also searched for anything pertaining to "libsfml-graphics" and got this...
sudo egrep -d recurse "libsfml-graphics" /
results in...
Binary file /etc/ld.so.cache matches
egrep: /etc/ssl/certs/b2c62324: No such file or directory
I have no idea what these are?

I've just reinstalled the sdk again but still get the same error message.
Do you think it's time to reinstall my os?

13
Graphics / undefined reference to `gluPerspective'
« on: February 08, 2010, 10:29:13 pm »
The answer was staring me in the face in the 1.5 sdk opengl makefile sample.

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

Thank you Laurent!

14
General / gluPerspective
« on: February 08, 2010, 10:28:24 pm »
The answer was staring me in the face in the 1.5 sdk opengl makefile sample.

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

Thank you Laurent!

15
Graphics / undefined reference to `gluPerspective'
« on: February 08, 2010, 09:44:11 pm »
I too am having problems with this tutorial on amd64/linux

I already had the latest versions of the 3 files that you suggest downloading.

I tried your suggestions in various configurations, one of which was...

g++ -c window-opengl.cpp -lsfml-graphics -lsfml-window -lsfml-system -l/usr/lib/GL

g++ -o window-opengl window-opengl.o -L/usr/lib -lGLU

I'm not sure if that's what you meant but none of them have worked.

The first line produces the .o file
The second line produces this

window-opengl.o: In function `main':
window-opengl.cpp:(.text+0x55): undefined reference to `sf::VideoMode::VideoMode(unsigned int, unsigned int, unsigned int)'
window-opengl.cpp:(.text+0x79): undefined reference to `sf::Window::Window(sf::VideoMode, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned long, sf::WindowSettings const&)'
window-opengl.cpp:(.text+0xea): undefined reference to `sf::Clock::Clock()'
window-opengl.cpp:(.text+0x114): undefined reference to `sf::Window::~Window()'
window-opengl.cpp:(.text+0x1f5): undefined reference to `sf::Window::Close()'
window-opengl.cpp:(.text+0x213): undefined reference to `sf::Window::Close()'
window-opengl.cpp:(.text+0x244): undefined reference to `sf::Window::GetEvent(sf::Event&)'
window-opengl.cpp:(.text+0x259): undefined reference to `sf::Window::SetActive(bool) const'
window-opengl.cpp:(.text+0x28e): undefined reference to `sf::Clock::GetElapsedTime() const'
window-opengl.cpp:(.text+0x2b6): undefined reference to `sf::Clock::GetElapsedTime() const'
window-opengl.cpp:(.text+0x2de): undefined reference to `sf::Clock::GetElapsedTime() const'
window-opengl.cpp:(.text+0x5d0): undefined reference to `sf::Window::Display()'
window-opengl.cpp:(.text+0x5dc): undefined reference to `sf::Window::IsOpened() const'
window-opengl.cpp:(.text+0x5f5): undefined reference to `sf::Window::~Window()'
window-opengl.cpp:(.text+0x62b): undefined reference to `sf::Window::~Window()'

I tried commenting out the gluPerspective line
and it all compiled nicely with
g++ -o window-opengl window-opengl.cpp -lsfml-graphics -lsfml-window -lsfml-system

and ran as a window so it does seem to be this bit that is doing the "damage"

==============================================

Your synaptic suggestion is excellent 'cos I've never known how to look at what gets put where. Synaptic shows that my files are here...

libgl1-mesa-dev contains...
================
/.
/usr
/usr/share
/usr/share/doc
/usr/share/doc/libgl1-mesa-dev
/usr/share/doc/libgl1-mesa-dev/copyright
/usr/share/doc/libgl1-mesa-dev/changelog.Debian.gz
/usr/lib
/usr/lib/pkgconfig
/usr/lib/pkgconfig/gl.pc
/usr/lib/libGL.so

libglu1-mesa-dev contains...
=================
/.
/usr
/usr/share
/usr/share/doc
/usr/share/doc/libglu1-mesa-dev
/usr/share/doc/libglu1-mesa-dev/copyright
/usr/share/doc/libglu1-mesa-dev/changelog.Debian.gz
/usr/include
/usr/include/GL
/usr/include/GL/glu.h
/usr/include/GL/glu_mangle.h
/usr/lib
/usr/lib/libGLU.a
/usr/lib/libGLU.so


and libopenal-dev contains...
=================
/.
/usr
/usr/share
/usr/share/doc
/usr/share/doc/libopenal-dev
/usr/share/doc/libopenal-dev/README.Debian
/usr/share/doc/libopenal-dev/copyright
/usr/share/doc/libopenal-dev/changelog.Debian.gz
/usr/share/man
/usr/share/man/man1
/usr/share/man/man1/openal-config.1.gz
/usr/include
/usr/include/AL
/usr/include/AL/al.h
/usr/include/AL/alc.h
/usr/include/AL/alext.h
/usr/lib
/usr/lib/libopenal.a
/usr/lib/pkgconfig
/usr/lib/pkgconfig/openal.pc
/usr/bin
/usr/bin/openal-config
/usr/lib/libopenal.so

Could someone please advise
a) whether I've got all the files this tutorial needs and
b) what my compile line should be

To give some idea of the state of my system
I was able to compile and run this example
   http://www.sfml-dev.org/tutorials/1.4/graphics-fonts.php
with
   g++ -o graphics-fonts graphics-fonts.cpp -lsfml-graphics -lsfml-window -lsfml-system
Hope this helps

Thx in anticipation

Pages: [1] 2