@@ -64,6 +64,7 @@ struct Functions {
6464/// Pointers to all used hw variables.
6565struct Pointers {
6666 cls : * mut client_static_t ,
67+ game : * mut * mut CGame ,
6768 host_frametime : * mut c_double ,
6869 paintbuffer : * mut portable_samplepair_t , // [1026]
6970 paintedtime : * mut c_int ,
@@ -191,6 +192,12 @@ struct dma_t {
191192 buffer : * mut c_uchar ,
192193}
193194
195+ #[ repr( C ) ]
196+ struct CGame {
197+ stuff : [ u8 ; 0xC ] ,
198+ m_hSDLGLContext : c_uint ,
199+ }
200+
194201/// The "main" function of hw.so, called inside `CEngineAPI::Run()`.
195202///
196203/// The game runs within this function and shortly after it exits hw.so is unloaded.
@@ -506,6 +513,7 @@ fn refresh_pointers(_: &Engine) -> Result<()> {
506513
507514 POINTERS = Some ( Pointers {
508515 cls : find ! ( hw, "cls" ) ,
516+ game : find ! ( hw, "game" ) ,
509517 host_frametime : find ! ( hw, "host_frametime" ) ,
510518 paintbuffer : find ! ( hw, "paintbuffer" ) ,
511519 paintedtime : find ! ( hw, "paintedtime" ) ,
@@ -652,7 +660,7 @@ pub fn get_pro_que(engine: &Engine) -> Option<&mut ocl::ProQue> {
652660 engine. data ( ) . pro_que = Some ( None ) ;
653661 } else {
654662 let context = ocl:: Context :: builder ( )
655- . gl_context ( sdl :: get_current_context ( ) )
663+ . gl_context ( get_opengl_context ( engine ) )
656664 . glx_display ( unsafe { glx:: GetCurrentDisplay ( ) } as _ )
657665 . build ( )
658666 . chain_err ( || "error building ocl::Context" ) ;
@@ -897,5 +905,10 @@ fn read_pixels(_: &Engine, (w, h): (u32, u32), buf: &mut [u8]) {
897905 }
898906}
899907
908+ /// Retrieves the current OpenGL context.
909+ fn get_opengl_context ( _: & Engine ) -> u32 {
910+ unsafe { ( * * ptr ! ( game) ) . m_hSDLGLContext }
911+ }
912+
900913cvar ! ( cap_allow_tabbing_out_in_demos, "1" ) ;
901914cvar ! ( cap_playdemostop, "1" ) ;
0 commit comments