Changeset 133
- Timestamp:
- 08/26/10 18:56:28 (18 months ago)
- Location:
- cafu/branches/cafu_to_wx
- Files:
-
- 4 modified
-
Ca3DE/ConDefs.cpp (modified) (1 diff)
-
Ca3DE/MainCanvas.cpp (modified) (2 diffs)
-
Libs/OpenGL/OpenGLWindow.cpp (modified) (1 diff)
-
Libs/OpenGL/OpenGLWindow.hpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
cafu/branches/cafu_to_wx/Ca3DE/ConDefs.cpp
r132 r133 212 212 213 213 214 static int ConFunc_VideoGetModes_Callback(lua_State* LuaState) 215 { 216 wxDisplay Display; 217 wxArrayVideoModes Modes =Display.GetModes(); 218 const wxVideoMode CurrentMode =Display.GetCurrentMode(); 219 bool Have32BPPModes=false; 220 221 for (size_t ModeNr=0; ModeNr<Modes.GetCount(); ModeNr++) 222 { 223 const wxVideoMode& Mode=Modes[ModeNr]; 224 225 if (Mode.bpp>=32) 226 { 227 Have32BPPModes=true; 228 break; 229 } 230 } 231 232 for (size_t ModeNr=0; ModeNr<Modes.GetCount(); ModeNr++) 233 { 234 const wxVideoMode& Mode =Modes[ModeNr]; 235 const bool IsCurrent=(Mode==CurrentMode); 236 237 if (Have32BPPModes && Mode.bpp<32 && !IsCurrent) continue; 238 239 Console->Print(cf::va("%3u, %i x %i, %i BPP @ %i Hz%s\n", ModeNr, Mode.w, Mode.h, Mode.bpp, Mode.refresh, IsCurrent ? " (current)" : "")); 240 } 241 214 static int ConFunc_VideoInfo_Callback(lua_State* LuaState) 215 { 216 Console->Print(GetVideoModes()); 242 217 Console->Print(cf::va("Renderer Info: %s\n", MatSys::Renderer ? MatSys::Renderer->GetDescription() : "[No renderer active.]")); 243 218 return 0; 244 219 } 245 220 246 static ConFuncT ConFunc_Video GetModes("VideoGetModes", ConFunc_VideoGetModes_Callback, ConFuncT::FLAG_MAIN_EXE, "Prints some information about the OpenGL window and renderer.");221 static ConFuncT ConFunc_VideoInfo("VideoInfo", ConFunc_VideoInfo_Callback, ConFuncT::FLAG_MAIN_EXE, "Prints some information about the OpenGL window and renderer."); 247 222 248 223 -
cafu/branches/cafu_to_wx/Ca3DE/MainCanvas.cpp
r132 r133 461 461 FrameBuffer.PushBackEmpty(Width*Height); 462 462 463 // Read the pixels from tthe OpenGL back buffer into FrameBuffer.463 // Read the pixels from the OpenGL back buffer into FrameBuffer. 464 464 // Note that the first two parameters (0, 0) specify the left BOTTOM corner of the desired rectangle! 465 465 glReadPixels(0, 0, Width, Height, GL_RGBA, GL_UNSIGNED_BYTE, &FrameBuffer[0]); … … 582 582 583 583 ME.Type =CaMouseEventT::CM_MOVE_X; 584 ME.Amount=MouseDelta.x; // TODO: Factor out screen resolution...584 ME.Amount=MouseDelta.x; 585 585 if (ME.Amount!=0) ActiveGui->ProcessDeviceEvent(ME); 586 586 587 587 ME.Type =CaMouseEventT::CM_MOVE_Y; 588 ME.Amount=MouseDelta.y; // TODO: Factor out screen resolution...588 ME.Amount=MouseDelta.y; 589 589 if (ME.Amount!=0) ActiveGui->ProcessDeviceEvent(ME); 590 590 } -
cafu/branches/cafu_to_wx/Libs/OpenGL/OpenGLWindow.cpp
r100 r133 21 21 ================================================================================= 22 22 */ 23 24 /********************************/25 /*** OpenGL Window (DLL Code) ***/26 /********************************/27 23 28 24 #define DLL_EXPORT_HEADER -
cafu/branches/cafu_to_wx/Libs/OpenGL/OpenGLWindow.hpp
r105 r133 22 22 */ 23 23 24 /******************************/25 /*** OpenGL Window (Header) ***/26 /******************************/27 28 24 #ifndef _OPENGL_WINDOW_HPP_ 29 25 #define _OPENGL_WINDOW_HPP_ … … 36 32 37 33 #include <string> 38 39 // This comment is somewhat outdated...40 //41 // Damn. I already had some finished, fully object-oriented, extremely beautiful OpenGLWindowT and OpenGLWindowInputT42 // classes for all the stuff defined in here. Sadly, it didn't work. Several considerations:43 // 1. There is a lot of old code that relies on the below defined variables 'WindowIsOpen' and 'RenderingContextCounter'44 // for its OpenGL resource management (e.g. texture objects recovery after a rendering context change).45 // The otherwise beautiful OO approach of an 'OpenGLWindowT' class does not agree well with such variables.46 // Rather, every piece of code that needs them had to be changed to receive a pointer to the current 'OpenGLWindowT' object!47 // This is extremely ugly: The pointer must either be propagated across full function call depth, which will consume48 // enormous amounts of stack space for its numerous copies alone. The pointer-passing can be reduced at the cost of extremely49 // ugly, complex, and hard-to-maintain handler code.50 // Note that these pointers frequently change, at least once for closing and re-opening a window,51 // and each change must somehow be propagated to the user code.52 // Also note that a Cafu game DLL needs access to the current OpenGL window, which in turn means that I even53 // had to bloat the game DLL interface to account for all this gruesome complexity...54 // 2. First idea for improvement: Make everything OO, except one function like 'GetCurrentOpenGLWindow()'55 // which returns a pointer to the current 'OpenGLWindowT' object.56 // This function must answer the question which window is currently current (not necessarily the one that has focus),57 // and therefore probably also requires a 'SetCurrentOpenGLWindow()' complement function.58 // 3. Somebody explained me some interesting things about 'wglCreateContext()' and 'wglMakeCurrent()' a while ago.59 // Seems like rendering contexts (RCs) may survive their parent windows, and can be bound to future windows.60 // This approach might solve ALL ABOVE MENTIONED PROBLEMS at once, because their proper use in an 'OpenGLWindowT'61 // class and the proper use of 'glIsTexture()' (and related functions) in user code might make the need for62 // 'WindowIsOpen' and 'RenderingConextCounter' obsolete.63 // Sounds very well, but I still consider an immediate change to be risky. Is it portable? What if incompatible64 // pixel formats are desired between RC changes? Do we *really* get rid of demand for direct access to the 'OpenGLWindowT'?65 // Best is probably to make a thorough back-up someday, and try it out.66 // 4. Except for 3., I'm still not sure for multi-window programs if and how we can answer the users code question67 // if and when OpenGL resources are to be (re-)created. How do we manage multiple RCs? Do we have to, after all?68 34 69 35
