| Summary: | Fullscreen/WINDOW change | ||
|---|---|---|---|
| Product: | SDL | Reporter: | wudi <songrui2009> |
| Component: | video | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED INVALID | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | CC: | bombasticbryan |
| Version: | 1.2.13 | Keywords: | target-1.2.14 |
| Hardware: | x86 | ||
| OS: | Windows (XP) | ||
Tagging this bug with "target-1.2.14" so we can try to resolve it for SDL 1.2.14. Please note that we may choose to resolve it as WONTFIX. This tag is largely so we have a comprehensive wishlist of bugs to examine for 1.2.14 (and so we can close bugs that we'll never fix, rather than have them live forever in Bugzilla). --ryan. Please re-enter a new bug if you can catch it doing that in the debugger. :) Whoops, I see this was intended to be Chinese. Can you add an english translation of the error? Let's see if I can decode this a little bit... 0xC0000005 usually means a segmentation fault... I imagine that 0x00000000 is a NULL pointer dereference. The code itself looks fine offhand. Are your video drivers up to date? Can you reproduce this with the current SDL snapshot? http://www.libsdl.org/tmp/SDL-1.2.zip If so, do you get the same problem with testgl, included in the test folder in the SDL source archive? Please submit a new bug report if you're still seeing this issue with SDL 1.3. Thanks! |
ä¸èƒ½è°ƒç”¨SDL_SetVideoMode两次! 我想动æ€çš„æ”¹å˜window/fullscreen通过F1 但是总æç¤ºæˆ‘错误! ERROR: M2_File_SDL.exe ä¸çš„ 0x77c178c0 处未处ç†çš„异常: 0xC0000005: 读å–ä½ç½® 0x00000000 æ—¶å‘ç”Ÿè®¿é—®å†²çª CODE: #include <iostream> #include <cstdlib> #include <SDL.h> #include <SDL_opengl.h> #include <GL/GL.h> #include <GL/GLU.h> #include <GL/GLAux.h> #include "Model.h" #pragma comment(lib,"SDL.lib") #pragma comment(lib,"SDLMain.lib") #pragma comment(lib,"opengl32.lib") #pragma comment(lib,"glu32.lib") #pragma comment(lib,"glaux.lib") #define SCREEN_WIDTH 640 #define SCREEN_HEIGHT 480 #define SCREEN_BPP 16 int globalTime=0; int globalFrame=0; int LastTime=0; SDL_Surface* pSurFace; void Quit(int wReturnCode) { SDL_Quit(); exit(wReturnCode); } int ResizeWindow(int width,int height) { if (height==0) height=1; glViewport(0,0,width,height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45.0f,(GLfloat)width/(GLfloat)height,0.1f,100.0f); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); return true; } void HandleKeyPress(SDL_keysym* KeySym,/*SDL_Surface* pSurFace,*/uint32& wVideoFlags) { switch(KeySym->sym) { case SDLK_ESCAPE: Quit(0); break; #ifndef WIN32 case SDLK_F1: SDL_WM_ToggleFullScreen(pSurFace);//这个åªåœ¨linuxä¸Šå¾—åˆ°æ”¯æŒ break; #else case SDLK_F1: wVideoFlags^=SDL_FULLSCREEN; pSurFace=SDL_SetVideoMode(SCREEN_WIDTH,SCREEN_HEIGHT,SCREEN_BPP,wVideoFlags); if (!pSurFace) { std::cout<<"改å˜çª—å£å¤§å°åŽæ— 法设置显å¡:"<<SDL_GetError()<<std::endl; Quit(1); } ResizeWindow(SCREEN_WIDTH,SCREEN_HEIGHT); break; #endif default: break; } return; } int InitGL() { glShadeModel(GL_SMOOTH); glClearColor(0.0f,0.0f,0.0f,1.0f); glClearDepth(1.0f); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST); glPolygonMode(GL_FRONT_AND_BACK,GL_FILL); glEnable(GL_TEXTURE_2D); return true; } int DrawScene(Model& MyModel) { static float r=-90.0f; glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); glLoadIdentity(); glTranslatef(0.0f,-1.5f,-2.3f); glRotatef(r,0,1.0f,0); glColor3f(1.0f,1.0f,1.0f); MyModel.Animate(117); MyModel.m_pAnimManager->Tick(23); MyModel.DrawModel(); SDL_GL_SwapBuffers(); return true; } int main(int argc, char *argv[]) { uint32 wVideoFlags; int done=false; SDL_Event event; const SDL_VideoInfo* pVideoInfo; //SDL_Surface* pSurFace; int isAvtive=true; if (SDL_Init(SDL_INIT_VIDEO)<0) { std::cout<<"åˆå§‹åŒ–显å¡é”™è¯¯:"<<SDL_GetError()<<std::endl; Quit(1); } pVideoInfo=SDL_GetVideoInfo(); if (!pVideoInfo) { std::cout<<"查询显å¡å¤±è´¥:"<<SDL_GetError()<<std::endl; Quit(1); } wVideoFlags=SDL_OPENGL; wVideoFlags|=SDL_GL_DOUBLEBUFFER; wVideoFlags|=SDL_HWPALETTE; wVideoFlags|=SDL_RESIZABLE; //wVideoFlags|=SDL_FULLSCREEN; if (pVideoInfo->hw_available) wVideoFlags|=SDL_HWSURFACE; else wVideoFlags|=SDL_SWSURFACE; if (pVideoInfo->blit_hw) wVideoFlags|=SDL_HWACCEL; SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER,1); pSurFace=SDL_SetVideoMode(SCREEN_WIDTH,SCREEN_HEIGHT,SCREEN_BPP,wVideoFlags); if (!pSurFace) { std::cout<<"åˆå§‹åŒ–显å¡è®¾ç½®å¤±è´¥:"<<SDL_GetError()<<std::endl; Quit(1); } InitGL(); ResizeWindow(SCREEN_WIDTH,SCREEN_HEIGHT); ///////////// static Model MyModel("E:\\3D\\Model\\BloodElfMale\\BloodElfMale.M2"); MyModel.m_pAnimManager->Set(0,117,0); MyModel.m_pAnimManager->SetSpeed(1.0f); /////////// while (!done) { while(SDL_PollEvent(&event)) { switch(event.type) { case SDL_ACTIVEEVENT: if (event.active.gain==0) isAvtive=false; else isAvtive=true; break; case SDL_VIDEORESIZE: pSurFace=SDL_SetVideoMode(event.resize.w,event.resize.h,SCREEN_BPP,wVideoFlags); if (!pSurFace) { std::cout<<"改å˜çª—å£å¤§å°åŽæ— 法设置显å¡:"<<SDL_GetError()<<std::endl; Quit(1); } ResizeWindow(event.resize.w,event.resize.h); break; case SDL_KEYDOWN: HandleKeyPress(&event.key.keysym/*,pSurFace*/,wVideoFlags); break; case SDL_QUIT: done=true; break; default: break; } } if (isAvtive) DrawScene(MyModel); } Quit(0); return 0; }