| Summary: | Call SDL_SetVideoMode will make Lua fail in SDL 1.3 | ||
|---|---|---|---|
| Product: | SDL | Reporter: | kaleidos <gjcaoyi> |
| Component: | *don't know* | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | ||
| Version: | 2.0.0 | ||
| Hardware: | x86 | ||
| OS: | Windows (XP) | ||
Hmm, this works just fine for me on Mac OS X. What compiler are you using? (In reply to comment #1) > Hmm, this works just fine for me on Mac OS X. What compiler are you using? The visual studio 2008 and visual studio 2005 have the same problem. I've done a bunch of work in the video system. I haven't fixed anything like stack overflows or anything that might cause this, but it might be worth checking again: http://www.libsdl.org/tmp/SDL-1.3.zip I wasn't ever able to reproduce this, so if you have any more debugging information, that would be great. Thanks! (In reply to comment #3) > I've done a bunch of work in the video system. I haven't fixed anything like > stack overflows or anything that might cause this, but it might be worth > checking again: > http://www.libsdl.org/tmp/SDL-1.3.zip > > I wasn't ever able to reproduce this, so if you have any more debugging > information, that would be great. > > Thanks! Thanks for your works. It works. My version is SDL-1.3.0-4429. After downloading the SDL-1.3.0-5482, there has no any problem. Sorry for my late response. I'm glad to hear it's fixed. Thanks! |
I am writing a program with Lua and SDL.They are Lua5.1 and SDL 1.3. My problem is: when I call the "SDL_SetVideoMode" function to get SDL_Surface, the "luagetstring" function will make an error at lua_call(L, 1, 1); If I write "lua_pcall(L,1,1,0);" instead of lua_call(L, 1, 1), there is the same result. But if the SDL_SetVideoMode not execute, there is no problem. I will get the right result by calling luagetstring(L, 1,str ); There is no problem when I call SDL_SetVideoMode in SDL 1.2. Is it a conflict between SDL 1.3 with Lua? Or is there anything I missed? ======================================================= data.lua ======================================================= wndres = { { type = "tga", x = 100, y = 200, width = 0, height = 0}, { type = "tga", x = 100, y = 200, width = 0, height = 0}, } ======================================================= testfromlua.lua ======================================================= function add ( x ) return wndres[x].x end function gettablelen() return #wndres end function getwndtype( idx ) return wndres[idx].type end function getX( idx ) return wndres[idx].x end function getY( idx ) return wndres[idx].y end ======================================================= testnewlua.cpp ======================================================= // testnewlua.cpp : Defines the entry point for the console application. // #include "SDL.h" #include "SDL_image.h" extern "C" { #include "lua.h" #include "lauxlib.h" #include "lualib.h" } #include <iostream> #include <string> static void luagetstring(lua_State *L, int idx, std::string& str ) { lua_getglobal(L,"getwndtype");; lua_pushnumber(L, idx); lua_call(L, 1, 1); size_t number = 0; str = lua_tolstring(L, -1,&number); lua_pop(L, 1); } int main(int argc, char* args[]) { lua_State *L; L = luaL_newstate(); luaL_openlibs(L); int base = lua_gettop(L) - 0; std::string t; luaL_loadfile(L, "data.lua") || lua_pcall(L, 0, 1,base); luaL_loadfile(L, "testfromlua.lua") || lua_pcall(L, 0, 1,base); if( SDL_Init( SDL_INIT_EVERYTHING ) == -1 ) { return false; } //Set up the screen SDL_Surface* g_pScreen = SDL_SetVideoMode( 300, 300, 32, SDL_SWSURFACE ); for( size_t i = 0; i < 2; i++ ) { std::string str = ""; luagetstring(L, 1,str ); } return 0; }