FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

SDL RegisterTouchWindow

 
Post new topic   Reply to topic     Forum Index -> Derelict
View previous topic :: View next topic  
Author Message
BLM768



Joined: 22 Feb 2012
Posts: 13

PostPosted: Tue May 22, 2012 8:38 am    Post subject: SDL RegisterTouchWindow Reply with quote

I've been porting one of my projects to Derelict3 and have run into a nasty little bug. All libraries seem to load fine, but SDL fails to create a GL context. SDL_GetError() gives the message, "Failed loading RegisterTouchWindow: The specified procedure could not be found." This has been an SDL issue on XP machines, but from what I've read, it seems like it's supposed to have been fixed. Might it be something to do with the specific versions of the Win32 libraries that DMD links in?
Back to top
View user's profile Send private message
aldacron



Joined: 05 May 2004
Posts: 1322
Location: Seoul, South Korea

PostPosted: Tue May 22, 2012 9:01 am    Post subject: Re: SDL RegisterTouchWindow Reply with quote

BLM768 wrote:
I've been porting one of my projects to Derelict3 and have run into a nasty little bug. All libraries seem to load fine, but SDL fails to create a GL context. SDL_GetError() gives the message, "Failed loading RegisterTouchWindow: The specified procedure could not be found." This has been an SDL issue on XP machines, but from what I've read, it seems like it's supposed to have been fixed. Might it be something to do with the specific versions of the Win32 libraries that DMD links in?


No. Derelict loads the SDL DLL dynamically, so any Win32 libraries used by SDL will have been linked in when the DLL was compiled and linked with the C toolchain. Perhaps you are using a snapshot of SDL from a period prior to the bug fix.
_________________
The One With D | The One With Aldacron | D Bits
Back to top
View user's profile Send private message Send e-mail
BLM768



Joined: 22 Feb 2012
Posts: 13

PostPosted: Tue May 22, 2012 12:14 pm    Post subject: Reply with quote

I'm fairly sure that I'm using one after the fix; I downloaded the most recent zip archive from SDL's site and compiled it myself. I might have to try installing Mercurial and grabbing the latest code from the repository, but I'm not sure if that will fix the problem and I'd like to avoid the hassle Smile. Where did you get your SDL files?
Back to top
View user's profile Send private message
aldacron



Joined: 05 May 2004
Posts: 1322
Location: Seoul, South Korea

PostPosted: Tue May 22, 2012 6:55 pm    Post subject: Reply with quote

I built it from the source in the Feb 20 snapshot at the bottom of this page. Have you tried the DLL I put up on the Derelict3 downloads page? I'm running XP and haven't encountered any errors with it.
_________________
The One With D | The One With Aldacron | D Bits
Back to top
View user's profile Send private message Send e-mail
BLM768



Joined: 22 Feb 2012
Posts: 13

PostPosted: Tue May 22, 2012 9:30 pm    Post subject: Reply with quote

I'm still getting the same error with that DLL. I get the same error on just about every system, so I guess I'll post the relevant code. There's probably something wrong with it.

Code:

//Derelict libs have been loaded.

if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) != 0) {
   throw new SDLInitError();
}

//Error seems to happen right here, but here's the code right after anyway:

 SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
 SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);

SDL_GL_SetAttribute(SDL_GL_RED_SIZE,     8);
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE,   8);
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE,    8);
SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE,   8);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE,   depthBufferSize);
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, stencilBufferSize);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);

window = SDL_CreateWindow(null, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
width, height, SDL_WINDOW_OPENGL);
if(!window)
        throw new Error("Unable to create SDL window");

        renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE);
        if(!renderer)
            throw new Error("Unable to create SDL renderer");
      
      SDL_GetRendererInfo(renderer, &info);
      if((info.flags & SDL_RENDERER_ACCELERATED) == 0 || (info.flags & SDL_RENDERER_TARGETTEXTURE) == 0) {
         throw new Error("Unable to create accelerated OpenGL context");
      }


The formatting didn't paste all that well, but that's the general idea. I have most of the variables defined as members of a class, but I didn't bother to paste that in; it shouldn't be affecting things.[/code]
Back to top
View user's profile Send private message
aldacron



Joined: 05 May 2004
Posts: 1322
Location: Seoul, South Korea

PostPosted: Wed May 23, 2012 6:06 am    Post subject: Reply with quote

I've looked into this some more and it seems very likely that the error message you are seeing isn't really the cause of your problem. RegisterTouchWindow is a Windows 7 function. Therefore, to maintain compatibility across Windows version, SDL always tries to load it dynamically. But it *always* attempts to do so, regardless of the Windows version (see SDL_windowsvideo.c, line 104). On XP, the function will always fail to load as it will never be available, therefore the error message will always be set (see SDL_sysloadso.c line 50). There are a couple of other functions loaded before it which will also fail, but because RegisterTouchWindow is the last one, that's the last error message that is set.

Furthermore, RegisterTouchWindow is only called once as far as I can tell, in SDL_windowswindow.c, line 185. But it's wrapped in a null check, since it's a function pointer that's being called:

Code:

if (videodata->RegisterTouchWindow) {
        videodata->RegisterTouchWindow(hwnd, (TWF_FINETOUCH|TWF_WANTPALM));
    }


The null check seems to be the fix for the bug you say "has been an SDL issue on XP machines," which was actually an access violation and is entirely unrelated to your current problem.

SDL's error string is a global value that is overwritten each time an error string is saved, so that calling SDL_GetError shows the most recent string. The point at which you are calling it is causing you to see the last error string set, the failure to load RegisterTouchWindow, but it's obviously not the problem. Something else is failing, and I suspect it's something you've done wrong on your side.

So I think to go any further it would be best to post a more detailed explanation of the problem and, if possible, the actual offending line of code.
_________________
The One With D | The One With Aldacron | D Bits
Back to top
View user's profile Send private message Send e-mail
BLM768



Joined: 22 Feb 2012
Posts: 13

PostPosted: Wed May 23, 2012 9:03 am    Post subject: Reply with quote

The initial problem I was having was that SDL wasn't able to create a hardware-accelerated context for some reason and DerelictGL3.reload() said that there was no active context (not even a software one). I had assumed that the RegisterTouchEvent error was the reason, but I guess that it's more of a warning and not the source of the problem. Since other programs are able to use OpenGL 3 on the machine I'm using, it's probably a problem with my setup. I think I've got all my GL setup code (before DerelictGL3.reload()) in my last post; if you could give it a quick look, I'd really appreciate it. I'm fairly new to this stuff, so the problem is probably my code Smile.
Back to top
View user's profile Send private message
aldacron



Joined: 05 May 2004
Posts: 1322
Location: Seoul, South Korea

PostPosted: Wed May 23, 2012 8:29 pm    Post subject: Reply with quote

OK, I see what's going on (and should have noticed it earlier). You aren't creating an OpenGL context. You're calling SDL_CreateRenderer, which is not the same thing. A renderer is only needed if you are going to be using the SDL 2D rendering API. And by default on Windows, it creates a Direct3D renderer, not an OpenGL one.

If you are only using straight OpenGL and don't need the 2D rendering API, take out all of the renderer stuff. Call SDL_GL_CreateContext after creating the window. This is from some working code of mine:

Code:

SDL_Window* _window;
SDL_GLContext _ctx;

void create(string title, uint width, uint height, ref WindowProperties props)
        {
            SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
            SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
            SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
            SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE, props.colorDepth);
            SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1);

            if(props.fsaa > 0)
            {
                SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
                SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, props.fsaa);
            }

            int x = (props.x == -1) ? SDL_WINDOWPOS_CENTERED : props.x;
            int y = (props.y == -1) ? SDL_WINDOWPOS_CENTERED : props.y;

            uint flags = SDL_WINDOW_OPENGL;
            if(props.show) flags |= SDL_WINDOW_SHOWN;
            if(props.fullscreen) flags |= SDL_WINDOW_FULLSCREEN;

            _window = SDL_CreateWindow(title.toStringz(),
                x, y, width, height, flags);

            if(!_window)
            {
                throw new Exception("Failed to create window: " ~ to!string(SDL_GetError()));
            }

            _ctx = SDL_GL_CreateContext(_window);
            if(!_ctx)
            {
                throw new Exception("Failed to create OpenGL context.");
            }

            // Reload DerelictGL3 for the new context.
            DerelictGL3.reload();

            if(props.show)
            {
                glClear(GL_COLOR_BUFFER_BIT);
                SDL_GL_SwapWindow(_window);
            }
        }


If you want to use the SDL rendering API with your OpenGL stuff, I'm sure it's possible, and I can guess how to set it up, but I suggest you look to the SDL mailing list for help with that.
_________________
The One With D | The One With Aldacron | D Bits
Back to top
View user's profile Send private message Send e-mail
BLM768



Joined: 22 Feb 2012
Posts: 13

PostPosted: Wed May 23, 2012 8:51 pm    Post subject: Reply with quote

Well, that was simple Razz. Thanks for the help!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Derelict All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group