Actual source code: drawopensdl3.c
1: // PetscDrawOpenSDL3() - open a window using SDL3
3: #include <../src/sys/classes/draw/impls/sdl3/sdl3impl.h>
5: /*@
6: PetscDrawOpenSDL3 - Opens an SDL3 window for use with the `PetscDraw` routines.
8: Collective
10: Input Parameters:
11: + comm - the communicator that will share the window
12: . title - the title to put in the title bar, or `NULL` for no title
13: . x - the x screen coordinates of the upper left corner of window (or `PETSC_DECIDE`)
14: . y - the y screen coordinates of the upper left corner of window (or `PETSC_DECIDE`)
15: . w - the screen width in pixels of (or `PETSC_DRAW_HALF_SIZE`, `PETSC_DRAW_FULL_SIZE`, or `PETSC_DRAW_THIRD_SIZE` or `PETSC_DRAW_QUARTER_SIZE`)
16: - h - the screen height in pixels of (or `PETSC_DRAW_HALF_SIZE`, `PETSC_DRAW_FULL_SIZE`, or `PETSC_DRAW_THIRD_SIZE` or `PETSC_DRAW_QUARTER_SIZE`)
18: Output Parameter:
19: . draw - the drawing context.
21: Options Database Keys:
22: + -nox - Disables all graphics output
23: . -draw_pause pause - Sets time (in seconds) that the program pauses after `PetscDrawPause()` has been called
24: (0 is default, -1 implies until user input)
25: . -draw_cmap name - Sets the colormap to use
26: . -draw_cmap_reverse (true|false) - Reverses the colormap
27: . -draw_cmap_brighten beta - Brighten (0 < `beta` < 1) or darken (-1 < `beta` < 0) the colormap
28: . -draw_sdl3_font filename - Font file for SDL3_ttf text rendering
29: - -geometry x,y,w,h - Indicates location and size of window
31: Level: beginner
33: Notes:
34: If `x` and `y` are both `PETSC_DECIDE` then PETSc places the window automatically.
36: Every process of the communicator draws; the first process displays the combined drawing of all
37: processes in the window. See `PETSC_DRAW_SDL3`.
39: When finished with the drawing context, it should be destroyed
40: with `PetscDrawDestroy()`.
42: .seealso: `PetscDrawFlush()`, `PetscDrawDestroy()`, `PetscDrawCreate()`, `PETSC_DRAW_SDL3`, `PetscDrawOpenX()`
43: @*/
44: PetscErrorCode PetscDrawOpenSDL3(MPI_Comm comm, const char title[], int x, int y, int w, int h, PetscDraw *draw)
45: {
46: PetscFunctionBegin;
47: PetscCall(PetscDrawCreate(comm, NULL, title, x, y, w, h, draw));
48: PetscCall(PetscDrawSetType(*draw, PETSC_DRAW_SDL3));
49: PetscFunctionReturn(PETSC_SUCCESS);
50: }