Skip to content

Conversation

metayan
Copy link

@metayan metayan commented Jul 25, 2025

gl_context is no longer a pointer
mouse x,y is float

Fixes these warnings when building macOS
+ ninja -C /src/scm/android/scrcpy/release/work/build-macos-x86_64
ninja: Entering directory `/src/scm/android/scrcpy/release/work/build-macos-x86_64'
[21/75] Compiling C object app/scrcpy.p/src_mouse_capture.c.o
../../../app/src/mouse_capture.c:89:33: warning: incompatible pointer types passing 'int *' to parameter of type 'float *' [-Wincompatible-pointer-types]
	SDL_GetGlobalMouseState(&mouse_x, &mouse_y);
				^~~~~~~~
/src/scm/android/scrcpy/app/deps/work/install/macos-native-static/include/SDL3/SDL_mouse.h:298:81: note: passing argument to parameter 'x' here
extern SDL_DECLSPEC SDL_MouseButtonFlags SDLCALL SDL_GetGlobalMouseState(float *x, float *y);
										^
../../../app/src/mouse_capture.c:89:43: warning: incompatible pointer types passing 'int *' to parameter of type 'float *' [-Wincompatible-pointer-types]
	SDL_GetGlobalMouseState(&mouse_x, &mouse_y);
					  ^~~~~~~~
/src/scm/android/scrcpy/app/deps/work/install/macos-native-static/include/SDL3/SDL_mouse.h:298:91: note: passing argument to parameter 'y' here
extern SDL_DECLSPEC SDL_MouseButtonFlags SDLCALL SDL_GetGlobalMouseState(float *x, float *y);
											  ^
2 warnings generated.
[25/75] Compiling C object app/scrcpy.p/src_display.c.o
../../../app/src/display.c:63:29: warning: incompatible pointer types assigning to 'SDL_GLContext *' (aka 'struct SDL_GLContextState **') from 'SDL_GLContext' (aka 'struct SDL_GLContextState *') [-Wincompatible-pointer-types]
	display->gl_context = SDL_GL_CreateContext(window);
			    ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../../app/src/display.c:103:35: warning: incompatible pointer types passing 'SDL_GLContext *' (aka 'struct SDL_GLContextState **') to parameter of type 'SDL_GLContext' (aka 'struct SDL_GLContextState *'); dereference with * [-Wincompatible-pointer-types]
	    SDL_GL_DestroyContext(display->gl_context);
				  ^~~~~~~~~~~~~~~~~~~
				  *
/src/scm/android/scrcpy/app/deps/work/install/macos-native-static/include/SDL3/SDL_video.h:3300:70: note: passing argument to parameter 'context' here
extern SDL_DECLSPEC bool SDLCALL SDL_GL_DestroyContext(SDL_GLContext context);
								     ^
../../../app/src/display.c:119:27: warning: incompatible pointer types passing 'SDL_GLContext *' (aka 'struct SDL_GLContextState **') to parameter of type 'SDL_GLContext' (aka 'struct SDL_GLContextState *'); dereference with * [-Wincompatible-pointer-types]
    SDL_GL_DestroyContext(display->gl_context);
			  ^~~~~~~~~~~~~~~~~~~
			  *
/src/scm/android/scrcpy/app/deps/work/install/macos-native-static/include/SDL3/SDL_video.h:3300:70: note: passing argument to parameter 'context' here
extern SDL_DECLSPEC bool SDLCALL SDL_GL_DestroyContext(SDL_GLContext context);
								     ^
3 warnings generated.
[75/75] Linking target app/scrcpy

rom1v and others added 10 commits July 17, 2025 18:35
Do not rely on SDL to expose integer scroll values, as they are not
available in all versions.

It was reimplemented in SDL 3.2.12 by this commit:
<libsdl-org/SDL@0447c2f>

Refs Genymobile#6156 <Genymobile#6156>
Inline the function body in its only caller.

This will simplify further refactors.
The texture was created as soon as the initial video size was known,
even before the first frame arrived.

However, texture creation will require other data, such as the color
range, which is only available once the first frame is received.

Therefore, delay texture creation until the first frame.
This prepares for the migration to SDL3, where the color range can only
be specified at the time of texture creation.
Use both the color space and color range from FFmpeg to determine the
appropriate SDL YUV conversion mode.
The latest Ubuntu does not provide the SDL3 package yet.
@rom1v
Copy link
Collaborator

rom1v commented Jul 25, 2025

Thank you 👍

@metayan
Copy link
Author

metayan commented Jul 26, 2025

I had the branch spun off from sdl3 and didn't notice that Github selected master.
Shall I make a new PR to keep it clean?

@rom1v
Copy link
Collaborator

rom1v commented Jul 26, 2025

No, i'll just integrate the changes into my branch.

@yume-chan
Copy link
Contributor

Shall I make a new PR to keep it clean?

The target branch can be changed by clicking the Edit button

@metayan metayan changed the base branch from master to sdl3 July 27, 2025 18:00
@metayan
Copy link
Author

metayan commented Jul 27, 2025

@yume-chan
Excellent.
Thanks.

rom1v pushed a commit that referenced this pull request Aug 12, 2025
The field gl_context is initialized from SDL_GL_CreateContext(), which
returns a raw SDL_GLContext, not a pointer.

The type mismatch was silently ignored by SDL2 because SDL_GLContext
was defined as an alias to `void *` (in SDL3, it is instead an alias to
`struct SDL_GLContextState *`, so compilation fails).

Refs #3895 <#3895>
PR #6259 <#6259>

Signed-off-by: Romain Vimont <rom@rom1v.com>
@rom1v
Copy link
Collaborator

rom1v commented Aug 12, 2025

I merged your first commit directly into dev, it also applies to SDL2: e47529a
(even if the problem was silently ignored in SDL2)

@rom1v
Copy link
Collaborator

rom1v commented Aug 12, 2025

I fixed up the other commit into my commit Migrate from SDL2 to SDL3 in #6216.

@rom1v rom1v closed this Aug 14, 2025
@metayan metayan deleted the sdl3-macos branch August 14, 2025 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants