sdl2 – Delta Time FPS with SDL 2 in C++

I have tried achieving a good delta time and fps counter over the last few days, read and watched a lot about it, but still can’t seem to get it to work.

Here is an example:

#include <iostream>
#include <SDL.h>
#include <SDL_image.h>

int main(int argc, char* argv()) {

    if (SDL_Init(SDL_INIT_VIDEO) != 0) {
        printf("error initializing SDL: %sn", SDL_GetError());
    }

    SDL_Window* window = SDL_CreateWindow("Title", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1000, 900, SDL_WINDOW_SHOWN);

    if (!window) {
        printf("error creating window: %sn", SDL_GetError());
    }

    Uint32 renderFlags = SDL_RENDERER_ACCELERATED;
    SDL_Renderer* renderer = SDL_CreateRenderer(window, -1, renderFlags);
    if (!renderer) {
        printf("error creating renderer");
        SDL_DestroyWindow(window);
        SDL_Quit();
    }

    SDL_Surface* surface = IMG_Load("dot.bmp");

    if (!surface) {
        printf("Error creating surface: %sn", SDL_GetError());
        SDL_DestroyRenderer(renderer);
        SDL_DestroyWindow(window);
        SDL_Quit();
    }

    SDL_Texture* texture = SDL_CreateTextureFromSurface(renderer, surface);
    SDL_FreeSurface(surface);
    if (!texture) {
        printf("error creating texture: %sn", SDL_GetError());
        SDL_DestroyRenderer(renderer);
        SDL_DestroyWindow(window);
        SDL_Quit();
    }

    SDL_Rect dest;

    dest.x = 0;
    dest.y = 0;

    SDL_QueryTexture(texture, NULL, NULL, &dest.w, &dest.h);

    Uint64 NOW = SDL_GetPerformanceCounter();
    Uint64 LAST = 0;
    double deltaTime = 0;

    while (true) {
        LAST = NOW;
        NOW = SDL_GetPerformanceCounter();
        deltaTime = (double)((NOW - LAST) / (double)SDL_GetPerformanceFrequency());
        
        SDL_RenderClear(renderer);

        dest.x += 50 * deltaTime;
        dest.y += 50 * deltaTime;

        SDL_RenderCopy(renderer, texture, NULL, &dest);

        SDL_RenderPresent(renderer);    

        std::cout << "Delta Time: " << deltaTime << std::endl;
        std::cout << "FPS: " << 60.0 - deltaTime << std::endl;

        SDL_Delay(1000.0f / (60.0 - deltaTime));
    }


    return 0;
}

I used the suggestion from this post: How to calculate delta time with SDL?

I print out “delta time” and “FPS” to the console and, while the deltaTime is slightly different each time, the FPS is stable 60 (which is the same value that I use in SDL_Delay to calculate delay in ms).
But the test image is clearly moving not smoothly, it stutters and moves at inconsistent speed, and I can’t understand why.

Please help me understand what I am doing wrong. I just can’t understand it even after looking through many examples.

fourier transform – how to describe delta convolution using integral expression

We express the radiation from a source by the expression bellow:
$U(x,y)=frac{e^{jkz}e^{frac{k}{2z}(x^2+y^2)}}{jlambda z}iint_{-infty}^{+infty}u(x’,y’)e^{-jfrac{2pi}{lambda z}(x’x+y’y)}dx’dy’ $
the fourier transform is $f_x=frac{x}{lambda z}$ and $f_y=frac{y}{lambda z}$.
Our system bellow has two apartures which has distance between them.
each aparture has fourier transform of sinc $F(rect(ax)rect(by))=frac{1}{|ab|}sinc(frac{f_x}{a})sinc(frac{f_y}{b})$.
$F(delta(f_x-frac{a}{2},f_y-frac{b}{2}))=e^{(ipi(ax+by))}$.
I know that convolution with delta is a shift in space.
how to find using the integral expression shown above the fourier transform of the shape bellow?
Thanks.
enter image description here

fourier analysis – Definite integral with Dirac delta and Heaviside function

In relation with the question I posed on MathSE here, I want to ask how can Mathematica give an answer to my problem.

The context

I am trying to get rid of the integral over $y$ in
$$begin{align}
int_0^{infty}dy ; psileft(frac{y}{q}right)phi(y) int_{-infty}^{infty}frac{dp}{sqrt{2pi}} p^{gamma} e^{-ip(y-x)};,
end{align}$$

and to obtain an analytical expression in terms of $phi(x)$, $psi(x/q)$ and their derivatives. I assume that $gamma=1-delta$, with $0<delta<1$. I tried to break down the problem (though I don’t know if there is a better way) so that I am left with
$$ begin{align}
int_0^{infty} dy ; psileft(frac{y}{q}right)phi(y) times left(frac{delta(y-x)}{(y-x)^{1-delta}} – (1-delta)frac{H(y-x)}{(y-x)^{2-delta}}right);,
end{align}$$

where $delta$ is the Dirac delta and $H$ the Heaviside function.

The problem

Since the parameter $delta$ (not to be confused with the Dirac) is constrained as $0<delta<1$, I expect troubles when evaluating the first term in the brackets. However, when I define $psi$ and $phi$, MMA returns an expression for this integral, which leaves me confused. Basically, my code is

  (Psi)(x_) := 9*6^{-1/2} x^{3/2} Exp(-3 x/2);
  (Phi)(x_) := x; (* Or x^2, or E^(x)...*)
  fourpfrac(x_, y_, (Delta)_) := (2*Pi)^(1/2)/Gamma((Delta))*HeavisideTheta(y - x)*(y - x)^((Delta) - 1); (* Fourier Transform of p^(1-(Delta)) *)
  x1frac(x_, (Nu)_, (Delta)_, (Alpha)_, q_) := Integrate(Derivative(0, (Nu), 0)(fourpfrac)(x, y, (Delta))*(Psi)(y/q)*(Phi)(y)*y^(-(Alpha) - 1), {y, 0, Infinity}); (* The whole integral *)
  x1frac(x, 1, (Delta), -1, q)

which returns in traditional form
$$
left{text{ConditionalExpression}left(frac{45 sqrt{3} x ((pi delta ) sin ) Gamma left(-delta -frac{3}{2}right) (-x)^{delta +frac{1}{2}} , _1F_1left(frac{7}{2};delta +frac{5}{2};-frac{3 x}{2 q}right)}{8 q^{3/2}}+frac{sqrt{pi } 2^{delta +frac{3}{2}} 3^{-delta } Gamma left(delta +frac{3}{2}right) q^{delta } , _1F_1left(2-delta ;-delta -frac{1}{2};-frac{3 x}{2 q}right)}{Gamma (delta -1)},x<0right)right}
$$

and in input form

{ConditionalExpression((2^(3/2 + (Delta)) 3^-(Delta) Sqrt((Pi)) q^(Delta) Gamma(3/2 + (Delta)) Hypergeometric1F1(2 - (Delta), -(1/2) - (Delta), -((3 x)/(2 q))))/Gamma(-1 + (Delta))
+ (45 Sqrt(3) (-x)^(1/2 + (Delta))x Gamma(-(3/2) - (Delta)) Hypergeometric1F1(7/2, 5/2 + (Delta), -((3 x)/(2 q))) Sin((Pi) (Delta)))/(8 q^(3/2)),  x < 0)}

The thing is that in no way the form I have given to $phi$ and $psi$ could have canceled the singularity.

  1. Is the result I have obtained with MMA correct?
  2. What did MMA do to evaluate the integral?
  3. Is there a better way to resolve the problem?

Many thanks!

Does the Microsoft Graph API support delta links for Outlook message subscriptions/notifications?

I’m trying to set up a subscription for the graph API message resource that uses delta links. I’m using the following subscription;

var subscription = new Subscription
{
    ChangeType = "created",
    NotificationUrl = "https://blah.azurewebsites.net/api/ChangeNotificationTrigger",
    LifecycleNotificationUrl = "https://blah.azurewebsites.net/api/LifecycleNotificationTrigger",
    Resource = "me/mailfolders('Inbox')/messages/delta",
    ExpirationDateTime = DateTime.Now.AddDays(1),
    ClientState = "secretClientValue",
    LatestSupportedTlsVersion = "v1_2"
};

I was hoping that the incoming notifications would include a @odata.deltaLink tag, but no such luck;

{
  "value": (
    {
      "subscriptionId": "xxxx-xxxx-xxx-xxx-xxx",
      "subscriptionExpirationDateTime": "2021-04-10T05:41:27.56134-07:00",
      "changeType": "created",
      "resource": "Me/Messages/xxxxxxxx==",
      "resourceData": {
        "@odata.type": "#Microsoft.Graph.Message",
        "@odata.id": "Me/Messages/xxxxx==",
        "@odata.etag": "W/"CQAAABYAAAC+zsk88BOYRJtmVg/VB/S8AAR+KqND"",
        "id": "xxxxxx"
      },
      "clientState": "secretClientValue",
      "tenantId": ""
    }
  )
}

Does anyone know if delta links are supported or unsupported for message notifications? I can’t find any MS docs to suggest it either way. My guess is that delta links in notifications would be relatively useless anyway, given that notifications can arrive in a different order in which they are sent. I was hoping to use them as some way of checkpointing the ‘last message processed until now’

How do I convert the argument of a dirac delta function from cartesian coordinates to spherical coordinates?

I have V(x)=Aδ(x) where I needed to convert the argument from cartesian to spherical, namely from δ(x) to δ(r) so I can compute an integral involving V in dr. I don’t understand the dirac delta quite well so I have little idea how to do this. Any help would be greatly appreciated. Thanks!

object oriented design – What would be a good scene algorithm to iterate over a nucleon graph with a minimum delta?

I’m creating a software to calculate the likelihood of having jams on a distributed network depending on how much traffic each node is sending to others at any given time.

For that I’m using a nucleon graph. I’m thinking of a good algorithm, purely scenical, that can iterate traffic though this network between the nodes, informing each other of how much likelihood they had.

The thing is that delta for the measurement needs to be as little as possible compared with the actual measurement.

Do you know any good algorithm that could serve that?

delta air lines – Showing credit card for international flight purchased with online travel agency

Yes. I do have knowledge about this since I fly Delta internationally a lot from the USA to Ghana and Delta always requests you show credit card for locations like Ghana with reputations for fraud.

If you buy it from the Delta website, it alerts you about the requirement and you have to click a check box in agreement before you can purchase the ticket so you’re aware.

If you bought it from Expedia however, it’s Expedia that makes the payment to Delta and thus you’re exempt from having to show the physical card.

If you’re still uncomfortable after my explanation, you can also go to a Delta office any day before the persons flight and show the card. I did that when I purchased tickets for others directly from the Delta website.