Bonjour / bonsoir à tous,

Avec la fonction SDL_RenderDrawLine(), SDL trace une ligne d'un point p1 à un point p2. Mais voilà, suivant l'angle entre p1 et p2, la ligne est "hachée". Ma version de SDL est la 2.0.8, et donc elle ne connait pas SDL_RenderDrawLineF(), qui a débarqué avec la version 2.0.10. Et apparemment, la dernière version de sld2 est la 2.30.11.

Avant de me lancer dans l'upgrade de sdl (ce qui implique la re-compilation de mes autres projets en cas de correction / amélioration), la fonction version F permettra-t-elle d'avoir une ligne visuellement correcte ? Pour info, c'est pour afficher les aiguilles d'une horloge et je suis sous win10.

Je dois avouer que lorsque quelque chose fonctionne, je suis assez frileux pour en faire l'upgrade

D'avance merci de vos réponses.

Le petit programme de test pour l'affichage de l'horloge:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include <math.h>
#include <stdio.h>
#include <sdl2/sdl.h>
 
#define WND_SIZE_HORZ           600
#define WND_SIZE_VERT           600
#define WND_COLOR_R             50
#define WND_COLOR_G             100
#define WND_COLOR_B             150
#define WND_TITLE               "Test degree"
#define RDR_DEFAULT_DRIVER      -1
#define DELAY_MS                10000
#define UNUSED(x)               (void)x
 
#define PI                      3.14159265358979323846
#define RAY                     100
#define TORADIAN(x)             ((x)*(PI/180))
 
void DisplaySDLVersion(void) {
    SDL_version v;
    SDL_GetVersion(&v);
    printf("SDL version %hd.%hd.%hd\n", v.major, v.minor, v.patch);
}
 
 
void DisplayWatch(SDL_Renderer *rdr, SDL_Point *center) {
    for(int a=0; a<360; a+=6) {
        if(a%5)
            SDL_SetRenderDrawColor(rdr, 0xff, 0xff, 0xff, SDL_ALPHA_OPAQUE);
        else
            SDL_SetRenderDrawColor(rdr, 0x00, 0xff, 0x00, SDL_ALPHA_OPAQUE);
        SDL_Point p;
        p.x=center->x+cos(TORADIAN(a))*RAY;
        p.y=center->y+sin(TORADIAN(a))*RAY;
        SDL_RenderDrawPoint(rdr, p.x, p.y);
    }
}
 
 
int main(int argc,char *argv[]) {
    UNUSED(argc);
    UNUSED(argv);
    DisplaySDLVersion();
    SDL_Init(SDL_INIT_VIDEO);
    SDL_Window *wnd=SDL_CreateWindow(WND_TITLE, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, WND_SIZE_HORZ, WND_SIZE_VERT, SDL_WINDOW_SHOWN);
    SDL_Renderer *rdr=SDL_CreateRenderer(wnd, RDR_DEFAULT_DRIVER, SDL_RENDERER_ACCELERATED);
    SDL_Point center={.x=WND_SIZE_HORZ/2, .y=WND_SIZE_VERT/2};
 
    for(int r=0; r<360; r+=6) {
        SDL_SetRenderDrawColor(rdr, WND_COLOR_R, WND_COLOR_G, WND_COLOR_B, SDL_ALPHA_OPAQUE);
        SDL_RenderClear(rdr);
        DisplayWatch(rdr, &center);
        SDL_SetRenderDrawColor(rdr, 0xff, 0xff, 0xff, SDL_ALPHA_OPAQUE);
        SDL_RenderDrawLine(rdr, center.x, center.y, center.x+cos(TORADIAN(r))*(RAY-10), center.x+sin(TORADIAN(r))*(RAY-10));
        SDL_RenderPresent(rdr);
        SDL_Delay(250);
    }
 
    SDL_DestroyRenderer(rdr);
    SDL_DestroyWindow(wnd);
    SDL_Quit();
 
    return(0);
}
}