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

Pages: [1]
Window / Windows gains focus only at borded
« on: August 22, 2013, 12:59:44 am »
I've noticed that my windows only gain focus (understand producing sf::Event::GainedFocus and bringing input to that window) only when clicking at it's border, not inside o the window. It's a little annoying and I'm somewhat sure it didn't happen in previous SFML versions (but it's too late for another testing.. ). Other means of gaining focus work fine (alt-tabing, picking up from taskbar,..).

I'm using SFML 2.1 32bit on Windows 8 64bit and can bring up more details if needed, like minimum code to reproduce, however it happens with 2 of my programs using SFML, so it looks like consistent issue.

System / A correct way to multithread OGL context?
« on: April 19, 2012, 12:05:40 am »
I've found plenty of stuff out there about multithreading, OGL and SFML, yet I had only partial success in inmplementing it. I'm currently working in test project to comprehend things and I actually managed to get it done..

Wait I didn't tell what.. I setup my raw OGL view, then in main loop I draw green point through thread, I switch back render a red point, display window.. Before switching to thread I deactivate window context in main thread, activate it in second thread, do my drawing, deactivate, get back to main thread and reactivate. Everything is synchronized with glFinish in second thread and sf::Thread::Wait in main thread so I'm sure nothing gets corrupted.. And it works, I get green point, a red point, but it is sloooooow as.. well I can't really expres that.

Basically it displays a frame then get stucked for about 5 seconds (everything.. even whole event system is frozen so I can't move a window). I noticed this behaviour in the dark age of mine when I recreated whole context on every launch of second thread. Also it had serious memory leaks. And the same behaviour (both leaks and long jumps to/from thread) I get now with only activating or deactivating.

This is my test code:

#include <GL\glew.h>
#include <GL\GLU.h>
#include <GL\GL.h>
#include <SFML\Window.hpp>
#include <SFML\System.hpp>
#include <SFML\Graphics.hpp>

void fun(sf::RenderWindow* win){



int main(){
        sf::RenderWindow win(sf::VideoMode(200,200), "Context sharing", sf::Style::Close);

        //setup view

        sf::Thread tr(fun,&win);       
        sf::Event ev;

                        case sf::Event::Closed:

                //clear buffer

                //render green point from thread

                //render red point to check if working

                //display it

        return 0;

If I get it right I might give that code to wiki if you like as only resource on this "Loading images in a thread (and displaying progress)" is now greyed out and can't be accessed.

General discussions / SFML-like library system
« on: January 17, 2012, 08:06:58 pm »
Hello.. this is quite a bit off-topic, but still SFML related so I'll give it a try.
I'm building my own library to concentrate many source files and headers that I'm now just copying between projects and compiling them over and over again, getting lost in where is the last modified version etc. I haven't previous experience with doing so, therefore I've chose to copy someone's else. Well and as I'm big fan of SFML and pretty impressed of how that word Simple fits in there, I tried to copy this one. I was particularly successful in creating similar file system and compiling library. However, I encountered few problems that I'd like to ask about, because SFML doesn't have such. For now I'm compiling my library with Visual Studio 10 and I don't have CMake solution yet, only visual studio project.

- GLEW include path needs to be specified in project using my library
This is biggest catch. When starting a project that should use my library, I include main include file (something like SFML/window.hpp). That file includes glew.h, thus the project that want to use just my library needs to know also about GLEW. I've noticed you're solving this by creating GLcheck.hpp and including it only to .cpp files. This way the user project doesn't have to know about glew. However, I'm using some GL data types defines (GLint) in declarations in headers, therefore I need to have GLEW included also in header. Is there any other work-arround than changing those to native data types?

- Static library size
My library is much smaller than SFML (number of lines, files, etc.), but still size of the resulting static library is greater than all SFML libraries together. I tried to play with project setting so I would get the same as SFML have, but it didn't do big difference. I think there might be problem connected with previous paragraph. If whole GLEW would be linked to static library, it could create such big libraries. (Note that my testing libraries don't exhibit such problem)

- Building both dll and lib whit single configuration(Release, Debug, ..)
I'm pretty interested in how is this possible, because I can only make configuration that produce static library or dynamic (project properties-> configuration properties-> general, configuration type [options: makefile, exe, dll, lib, utility]). This way I need to create one configuration for compiling static(lib) and one for dynamic(dll) library. SFML visual studio project created with Cmake produce both in single configuration e.g Release. Do I have to use Cmake for such option?

I don't know how much you (or people willing to input something to this topic) are familiar with visual studio, I just want to test everything out and solve major problems before getting my hands on Cmake. Anyway, I believe that you're more than competent to answer my questions as similar problems must have been addressed when creating SFML(or any other library). Also if you had some very good source where you learned something about building more advanced libraries (not just sample ones), I'd be more than interested in those.

General / Closing window causes access violation
« on: October 20, 2011, 07:58:35 pm »
My 2 programs using SFML 2.0 have both some strange glitch, that doesn't affect them but it's annoying. I'm creating sf::Window and sf::Render window in first and sf::Window in second and both programs are using also console window from sfml-main. When those windows appers on screen they behave correct and everything, but closing them through X in right up corner cause the created windows disappear (I think they close correctly), but that console window stays stuck for 3-4 seconds and then it crash. Note that when I close window my programs end(because of loop that uses sf::Window::IsOpened()). I get access violation, but it's not in my code and gets thrown after my main() function returns and formally ends program. The strange thing is, that when program is closed by clicking X in corner of console window everything closes correctly and no error appears.

I'm still not sure if it's bug in my code or SFML, because I was unable to jump from my code to SFML files. It can be still that I forgot to do something with resource inside my code, but I checked it few times and made destructors for almost every class cleaning those resources before program ends. Didn't help though, so I deleted those destructors for not to make more mess than there already is.

And sorry if there's topic like this, I couldn't find anything helpful (other than some topic about SFML using globals bacause of some ATI driver bug.. so maybe it'd help to say that I'm using ATI).

Graphics / Getting height of space under base in font
« on: September 19, 2011, 12:17:21 am »
I'm building my own render procedure for text rendering. I'm still using sf::Text, sf::Font etc., what I do is creating tags on various position that specify for example color, font or character size. While rendering I cut the string on rows and rows on uniform blocks - characters that have position inside uniform block share the same set of tags so I can set those to sf::Text and render them easily, then move my render position and repeat. However I encountered a little problem. I work with sf::Font::GetLineSpacing for determining row height and as there can be various sizes inside one row, I get maximum height and set that as main one and when rendering smaller than this one, I decrement the value so it sits on the same line. However this isn't really true because when I enlarge character size I get height steps. This is because I don't really set characters like "aAbB" on same line but those like ",,||". It can be understood after realizing what sf::Font::GetLineSpacing returns. My problem is now determining that piece of space is under the "alphabetical row" - the line on which characters lie. I tried this by retrieving Glyph and working whit Bound, but those value seems to be different from what i expected, because they don't grow with character size as fast as I'd expect and those steps can be still seen. Thanks for help

Graphics / Text::SetString() raises exception
« on: August 06, 2011, 01:11:59 pm »
Hello there. I recently ran into problem I can't solve. Anywhere I call Text::SetString() my program raises an exception. MSVC points me to strlen.asm file at line with arrow
Code: [Select]
   ; simple byte loop until string is aligned
-> mov     al,byte ptr [ecx]

and give me "0xC0000005: Access violation reading location". That error should be pointer related, but I don't work with pointers anywhere arround where this error appears. It's quite strange because MSVC doesn't even enter debug mode(checkpoint at first line of main), it's enough to see that I call SetString somewhere.. I haven't met with such thing before so I'd be glad for some help. I'm using recent SFML 2.0 build.

General / Compiling SFML 2.0 error
« on: July 25, 2011, 12:31:58 pm »
I was trying to get SFML 2.0, read in this forum it should allow textures for shapes (is that so?).

Anyway I downloaded cmake to get VS project from that bunch of files, but I get "CMake Warning at cmake/Config.cmake:45 (message): Unsupported compiler" - strange because I have my VS2008 working, but what's worse I get:
Code: [Select]
CMake Error at C:/Program Files/CMake 2.8/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:91 (MESSAGE):
  Could NOT find Freetype (missing: FREETYPE_LIBRARY)
Call Stack (most recent call first):
  C:/Program Files/CMake 2.8/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:252 (_FPHSA_FAILURE_MESSAGE)
  C:/Program Files/CMake 2.8/share/cmake-2.8/Modules/FindFreetype.cmake:92 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  src/SFML/Graphics/CMakeLists.txt:62 (find_package)

Yes I've read the tutorial on how to build with cmake and there was told that windows shouldn't need anything installed before running cmake, and yes even though I've tried to install freetype 2.3.5 (through binary setup) and it didn't resolved problem. Running on Win7 just in case it matters. Thanks in advance.

Graphics / sf::String::GetRect::GetWidth() returns wrong value?
« on: June 04, 2011, 10:09:21 pm »
As stated in function description, GetRect should return bounding box of text set to a string. When I use this value (more specificly it's width) as position to draw something immediately after text, this objects is drawn in good distance from text (almost another same text woudl fit into gap).

GetRect seems to work somewhat, because 'b' returns bigger value than 'i', but both returns something else than what I'd expect..

Maybe I'm not understanding "screen coordinates" term correctly, but those coordinates should be same as what goes into sf::Shape::SetPostition, shouldn't they?

Thanks for soon reply!

General / SFML won't run with updated ATI drivers
« on: March 15, 2011, 03:18:11 pm »
I've downloaded new drivers for my ATI radeon 3870 HD (11.2 version) and now I can't run any of my program wrote with SFML. It compiles and everything, but running it results just in command line, but the main window doesn't show up and everything stuck. Last loading call from debug is :
Code: [Select]
'gravity.exe': Loaded 'C:\Windows\System32\aticfx32.dll'
Debug doesn't even enter main() procedure so I think this isn't my fault.

Window / 0,0 in top left
« on: January 02, 2011, 02:46:09 pm »
I know it was discused in feature request, but over 3 years ago... I was searching for bug in my pick ray function. It had problem with Y axis being flipped or something. Well after few hours I came down to core of my app where SFML is being used and I finnaly realized that no matter what I set in openGL I still get flipped image.

So was there impelemented some way to flip axis int openGL-like style(0,0 in bottom left and it's more like when you draw graph on paper) or is there any easy solution w/o rewriting whole code if I'm using only openGL calls to draw primitives?

Window / sf::Event problems
« on: October 23, 2010, 01:45:30 pm »
I got strange problems with sf::Event. I'm creating 2 widnows, one for openGL drawings, second is some kind of settings for first one, so you can set parameters to that openGL.

I'm using this function to call updating of second window for main() function, which handles updating the primary one:

Code: [Select]
void Settings::update(){
const sf::Input& Input = Win.GetInput();
std::ostringstream oss;
// Process events
    sf::Event Event;
while (Win.GetEvent(Event)){
active = Input.GetMouseY() / cellHeight;
if ((Event.Key.Code==sf::Key::Return||Event.Key.Code==sf::Key::Right) && !input){
oss << active;
ID += oss.str();
if (Event.Key.Code==sf::Key::Space||Event.Key.Code==sf::Key::Left||
Event.MouseButton.Button == sf::Mouse::Right){
if(ID.size() > 0)
if (Event.Key.Code==sf::Key::Up){
if(active < 0)
active = cellsH-1;
if (Event.Key.Code==sf::Key::Down){
if(active >= cellsH)
active = 0;
if(Event.MouseButton.Button == sf::Mouse::Left && !input){
active = Event.MouseButton.Y / cellHeight;
oss << active;
ID += oss.str();

There's quite much of variables not defined in text because I am using class for second window, however the names should be intuitive. Cells are separated choices to choose in the menu which is specified by ID, and adding active to this ID you go into that choice or back from it.

What's wrong about that is, that when I simply move mouse over window for some time, setting just active(activated cell gets green so just some kind of indicator where are you pointing at), using Event.MouseMoved.
Pressing nothing, moving just mouse it suddenly generates Event.Key.Code=Space etc. jumping into other choices, and as you can see, invalidating my ID because I was just moving mouse, but ID down in menu.

I'll include window creation also:

Code: [Select]
void Settings::init(){

input = false;
ScreenX = 500;
ScreenY = 600;
sideMargin = 40;

Win.Create(sf::VideoMode(ScreenX, ScreenY, 32), "Settings",sf::Style::Titlebar);
Win.GetDefaultView().SetFromRect(sf::FloatRect(0, 0,(float)ScreenX, (float)ScreenY));

fontHeight = ScreenY/4;
std::string fontName = "ARIALN.TTF";
std::cout << "Couldn't load font " << fontName << std::endl;

ID += "0";
prepText = new std::wstring[10];


void Settings::resizeWindow(){
Win.GetDefaultView().SetFromRect(sf::FloatRect(0, 0,(float)ScreenX, (float)ScreenY));

glGetFloatv (GL_PROJECTION_MATRIX, proj.elements);

gluLookAt( 0, 0, 1, 0, 0, 0, 0, 1, 0);
glGetFloatv (GL_MODELVIEW_MATRIX, model.elements);

calling from main looks like this:
Code: [Select]

Settings uInf;
while (App.IsOpened())

If you need anything else like screenshot I'll add them, but I think it's just a mistake somewhere. However I searched for it for hours now and I am getting exahusted.

Graphics / Swapping fullscreen and windowed mode
« on: July 26, 2010, 01:46:48 am »
Is there way to switch between video modes without recreating whole class?

My current code, reacts on ctrl+enter:

Code: [Select]
if (Event.Key.Code == sf::Key::Return)
fullsize = !fullsize;
delete App;
App = new sf::RenderWindow(sf::VideoMode(VAL->ScreenX,
VAL->ScreenY, 32), caption,sf::Style::Fullscreen);
App = new sf::RenderWindow(sf::VideoMode(VAL->ScreenX,
VAL->ScreenY, 32), caption);

Window / Inputing Text to SFML
« on: July 25, 2010, 12:25:35 am »
Before I write my code for receiving text from user through Event.Key.Code, and I will end with solution supporting only ANSII, is there way to capture text as I would write to text editor (Actually funny I swapped GLUT for SFML because it couldn't handle Key Codes, but now I need thing that GLUT does provide as only input). I mean I don't want to receive shift+a, but A, or shift+3 = #. I hope there is some way to doo it, I saw sf::String, but can't find what I'm looking for. If there is this solution it would be good idea to give it to tutorial.

Audio / libsndfile-1.dll
« on: July 24, 2010, 11:08:48 am »
I was curious what is libsndfile-1.dll. I was asked for it (later on found in extlib) in sound playback tutorial. I found about something with LAME, but I would like to ask here what is this DLL part of.

Thanks in advance

Pages: [1]