Skip to content
This repository was archived by the owner on Sep 18, 2022. It is now read-only.

Commit 18ca77b

Browse files
committed
Removed external SDL2 dependency
1 parent 8f1ec6d commit 18ca77b

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ hl-capture is designed to be **fast** and **convenient**. Video and sound are en
1515

1616
## Requirements
1717
- 32-bit FFMpeg libraries.
18-
- 32-bit SDL2.
1918
- 32-bit OpenCL (look for something like ocl-icd).
2019

2120
## Usage

src/hooks/hw.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ struct Functions {
6464
/// Pointers to all used hw variables.
6565
struct 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+
900913
cvar!(cap_allow_tabbing_out_in_demos, "1");
901914
cvar!(cap_playdemostop, "1");

src/sdl.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,3 @@ pub fn get_proc_address(name: &str) -> *const c_void {
77
let cstring = CString::new(name).expect("could not convert name to a CString");
88
unsafe { sdl2_sys::SDL_GL_GetProcAddress(cstring.as_ptr()) }
99
}
10-
11-
#[inline]
12-
pub fn get_current_context() -> u32 {
13-
unsafe { sdl2_sys::SDL_GL_GetCurrentContext() as u32 }
14-
}

0 commit comments

Comments
 (0)