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

Pages: [1] 2
1
Window / How to lock cursor to window?
« on: April 30, 2016, 12:07:30 pm »
Is there a way to lock the mouse cursor to the window with SFML, such that when the mouse is about the exit the window's border, it is stopped?  Setting the mouse location isn't very reliable, as it fails when the mouse's movement is great enough (or if the program hangs briefly and delays the reset) allowing the mouse to escape and the window to lose focus.




2
I think I solved this finally! 

I got rid of the warning by updating both my code and sfml with the current GLEW library. 

I had to get glewInit() to be called to fix the access violation.  However, SFML calls it internally, in a structure that ensures it's only called once, but only if it itself does it.  (I can't call this from my code since it's not visible, the funciton is sf::priv::ensureExtensionsInit()) 

And it doesn't seem that merely creating a RenderWindow calls this.  So, what I did was after creating a window, I called sf::RenderWindow::ResetGLState(), which seems to make the call for me.  So now everything works as it should

3
I am trying to #include extlibs/headers/GL/glew.h that came with SFML, but haven't quite got it to work out. 

If I link against glew.lib and run my program, I get warnings for
Commons.lib(Shader.obj) : warning LNK4049: locally defined symbol ___glewCreateProgram imported
And after creating the SFML render window instance, if the program uses glCreateProgram(), it'll get an access violation for trying to access a NULL address.

I've read that this may be because I am not calling glewInit(), but I have also read that I should not do this when using SFML because it already does it. 

I guess my question is, is there anything special I must do to use both GLEW and SFML, while statically linking to both of them?


4
When inspecting a 'text entered' event, the integer I get from sf::Event::TextEvent::unicode is 13, for carriage return.  I would've expected this to be 10, or '\n' for newline. 

Is this intended, or is something going wrong here?  (I've never encountered a carriage return before, so this took me a bit by surprise)

5
Aw, that was it!  I'll keep that in mind from now on!  Just moved the window creation to the very start.  Thank you! 

(and thanks for the texture size!  It's so hard to get a fair idea of what to expect in that regard.  I guess I should aim for 1024 and just make a runtime workaround thing if it ever returns lower than that.)

6
Hello!  I wrote a program to print out the maximum size of a texture I can create, so I can get a rough idea of what a good lower limit is when programming.  (so far, I've yet to see a value below 8192). 

It prints a reasonable number at first.  But if I run the function a second time, it'll return a different, and insanely large, number.  This occurred on my laptop as well.  I'm using the latest version, fresh from the git repo.

For me, the first time, it gave me 16384.  Every time after that though, it was "11457127" which isn't even a power of 2 (or even for that matter)

Here's the code I used, it's relatively small.  The check occurs on the first line of "queryOpenGL()." I left in the other tests in case they may have had something to do with it.  This should compile I think. 

#include <cstdio>
#include <SFML/Graphics.hpp>


void queryOpenGL(){
        printf("\nMaximum texture size is %u\n", sf::Texture::getMaximumSize());
        bool modeTest = sf::VideoMode(640, 480).isValid();
        printf("A fullscreen mode of 640 by 480 is %s\n", modeTest ? "VALID" : "NOT VALID what???");
        sf::RenderWindow window(sf::VideoMode(50, 50), "Test Window", 7U, sf::ContextSettings(24, 8, 0));
        printf("Framebuffer depth/stencil format: %u:%u\n", window.getSettings().depthBits, window.getSettings().stencilBits);
        printf("Shaders are... %s\n", sf::Shader::isAvailable() ? "VALID" : "NOT VALID aawwww");
        sf::RenderTexture texture;
        bool success = texture.create(1024, 1024, true);
        printf("Attempting to create a Framebuffer Object ... %s\n", success ? "SUCCESSFUL!" : "FAILURE OH NO");
        printf("Concluding test\n");
        printf( " (\\_/)\n"
                        "(@' <'@)  Thanks bebe~\n\n");
}

int main(int argc, char * argv[]){
        char * initialMessage =
                "What tool to use?  (enter the digit)\n"
                "  0: Quit\n"
                "  1: Query SFML to see some things\n"
                ">>";
        int choice;
        do{
                printf(initialMessage);
                scanf("%i", &choice);
                switch(choice){
                case 1:
                        queryOpenGL();
                        break;
                }
                printf("\n-----\n");
        }while(choice);
        return 0;
}

7
General / Re: unresolved references to glut/jpeg/gl stuff
« on: January 25, 2014, 02:29:42 am »
AAAAA!  That solved it!  Thank you so much! 

8
General / unresolved references to glut/jpeg/gl stuff
« on: January 25, 2014, 01:00:58 am »
I'm in a bit of a pickle... I updated to the lastest version of SFML from source, and have been getting linker errors no matter what I do.

I'm using VS2010, telling cmake to generate static SFML libraries (SFML_STATIC is defined).  Everything compiles fine for SFML, but when I include them into my project, things don't go so well... This is the build output it's throwin' at me:

1>  All outputs are up-to-date.
1>sfml-window-s.lib(GlContext.obj) : error LNK2001: unresolved external symbol __imp__glEnable@4
1>sfml-graphics-s.lib(RenderTarget.obj) : error LNK2001: unresolved external symbol __imp__glEnable@4
1>sfml-window-s.lib(GlContext.obj) : error LNK2001: unresolved external symbol __imp__glGetString@4
1>sfml-window-s.lib(WglContext.obj) : error LNK2001: unresolved external symbol __imp__wglDeleteContext@4

...

1>sfml-graphics-s.lib(Shader.obj) : error LNK2001: unresolved external symbol ___glewUniform4fARB
1>sfml-graphics-s.lib(Shader.obj) : error LNK2001: unresolved external symbol ___glewUniformMatrix4fvARB
1>sfml-graphics-s.lib(Texture.obj) : error LNK2001: unresolved external symbol __imp__glDeleteTextures@8

...

1>sfml-graphics-s.lib(ImageLoader.obj) : error LNK2001: unresolved external symbol _jpeg_finish_compress
1>sfml-graphics-s.lib(ImageLoader.obj) : error LNK2001: unresolved external symbol _jpeg_write_scanlines
1>sfml-graphics-s.lib(ImageLoader.obj) : error LNK2001: unresolved external symbol _jpeg_start_compress
1>sfml-graphics-s.lib(ImageLoader.obj) : error LNK2001: unresolved external symbol _jpeg_set_quality
1>sfml-graphics-s.lib(ImageLoader.obj) : error LNK2001: unresolved external symbol _jpeg_set_defaults
1>sfml-graphics-s.lib(ImageLoader.obj) : error LNK2001: unresolved external symbol _jpeg_stdio_dest
1>sfml-graphics-s.lib(ImageLoader.obj) : error LNK2001: unresolved external symbol _jpeg_CreateCompress
1>sfml-graphics-s.lib(ImageLoader.obj) : error LNK2001: unresolved external symbol _jpeg_std_error
1>sfml-graphics-s.lib(RenderTextureImplFBO.obj) : error LNK2001: unresolved external symbol ___GLEW_EXT_framebuffer_object
1>sfml-graphics-s.lib(RenderTextureImplFBO.obj) : error LNK2001: unresolved external symbol ___glewDeleteFramebuffersEXT

...

1>sfml-system-s.lib(SleepImpl.obj) : error LNK2001: unresolved external symbol __imp__timeEndPeriod@4
1>sfml-system-s.lib(SleepImpl.obj) : error LNK2001: unresolved external symbol __imp__timeBeginPeriod@4
1>sfml-system-s.lib(SleepImpl.obj) : error LNK2001: unresolved external symbol __imp__timeGetDevCaps@8
1>F:\Sealark\Tools\Tools.exe : fatal error LNK1120: 95 unresolved externals

I've tried everything, including reacquiring and compiling the source.   I'm at a total loss...  Am I just forgetting to link or include something?  Any help would be immensely appreciated! 

9
Graphics / Re: Requesting a Stencil Buffer on sf::RenderTexture?
« on: January 13, 2014, 05:46:14 am »
Sorry to triple post!  Just wanted to report my results after testing it out. 

It works as intended it seems!  It does require using raw openGL calls to manipulate the stencil testing.  glStencilOp(), glStencilFunc(), and glEnable/glDisable(GL_STENCIL_TEST).  And I had to add a small overload to sf::RenderTexture::Clear() so it could take a second argument for clearing the stencil buffer.  But that's not too bad!  It doesn't leak any resources either, thankfully! 

I was messing around inside SFML's shader example to test some things with it.  Got some interesting-ish effects by just mixing a few of the shading examples.



They're the result of having one shader draw to the stencil buffer, then having two other shaders draw normally, one inside the stencil, and one outside the stencil.  So they're pretty random admittedly, but I was just mixing them at random to see what would happen.  With some thought though, it should make lighting, shadows, masking, and reflections a piece of cake (hopefully)!


10
Graphics / Re: Requesting a Stencil Buffer on sf::RenderTexture?
« on: January 13, 2014, 03:55:48 am »
Went through the source with a crayon scrawling recklessly.  I think I have my work around now!  At least, it doesn't crash the program by some miracle while doing what I wanted.  Thought I'd share it here if anyone was interested.

Made 2 small edits in sfml, and added a small namespace named 'clair' (so I can search it easily if something explodes) that contains a boolean that activates the code needed for stencils.  I just flip the bool to true before creating a RenderTexture, then turn it back off after it's done.  Yeah... it's pretty ugly  :'(

The destructor seems to clean up the FBO version regardless of which branch is taken (but I might be fatally mistaken).

RenderTextureImplFBO.cpp
bool RenderTextureImplFBO::create(unsigned int width, unsigned int height, unsigned int textureId, bool depthBuffer)
{
        ...
       
        if (depthBuffer)
        {
                ...
               
                glCheck(glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, m_depthBuffer));
                if(clair::enableStencilOnRenderTextureCreation){
                        // edited to allow stencils  --clair
                        glCheck(glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH24_STENCIL8_EXT, width, height));
                        glCheck(glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, m_depthBuffer));
                        glCheck(glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, m_depthBuffer));
                }else{
                        // original code moved to else branch
                        glCheck(glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, width, height));
                        glCheck(glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, m_depthBuffer));
                }
                ...
        }
        ...
}
 
RenderTextureImplDefault.cpp
bool RenderTextureImplDefault::create(unsigned int width, unsigned int height, unsigned int, bool depthBuffer)
{
    ...

        // Create the in-memory OpenGL context
        if(clair::enableStencilOnRenderTextureCreation){
                // edited to allow stencils  --clair
                m_context = new Context(ContextSettings(24, 8, 0), width, height);
        }else{
                // original code moved to else branch
                m_context = new Context(ContextSettings(depthBuffer ? 32 : 0), width, height);
        }
        return true;
}
 



11
Graphics / Requesting a Stencil Buffer on sf::RenderTexture?
« on: January 13, 2014, 12:35:59 am »
Hello!  I use stenciling a lot for lighting effects.  I can request a stencil buffer through sf::RenderWindow by passing it a ContextSettings instance (8bits stencil, 24bits depth).  However, this same functionality doesn't seem to be present with sf::RenderTexture, unless I'm mistaken of course! 

I was wondering if there was any work around?

RenderTextures do allow requesting a depth buffer, though only as a boolean (can't specify the bitplane count).  Took a look to see if I could easily add a stencil request myself, but it lead me into 2 difference -Impl.cpp type files, which I'm hesitant to mess with, aha...

12
This is amazing.  I've been scrambling around trying to find a way to avoid renderTarget after reading about the intel issue a few days ago.  I end up looking up that same issue tracker bug, and seeing it was closed not 6 hours ago. 

Kudos!

13
Graphics / [solved] Disable y-flip to use mathematical model?
« on: October 13, 2011, 02:08:00 am »
... it figures, work on it for a few hours, then as soon as I make a post, I see the problem.

I had gluOrtho2d()'s arguments backwards for the Y axis.  I think I have (un)negated the y-discrepancy totally now.  Thanks for the time though!

14
Graphics / [solved] Disable y-flip to use mathematical model?
« on: October 13, 2011, 02:03:59 am »
Hello!  I'm trying to use opengl rendering, while at the same time using SFML in spots to control the windows and texture loading.

However, the difference between openGL and SFML's coordinate systems, specifically the fact that y rises is different directions, is causing all sorts of subtle problems.  

Is there any way to isolate and disable the parts of SMFL that performs the y-flip conversion in the first place?

15
General / gl***() functions aren't defined after including sfml(fixed)
« on: September 21, 2011, 07:13:18 am »
Ah, nevermind, I looked at the opengl example and figured it out.  

I needed to include <SFML/OpenGL.hpp> too.  Whoops!

Pages: [1] 2