Hello
I am making a test program to render text in SDL3.
when attempting to render the texture, I get an error. “No matching function for call to ‘SDL_RenderTexture’”
I’m assuming this is with the last parameter, because when I make it null, the text renders and fills the screen.
here is the code:
#include <iostream>
#include "SDL3/SDL.h"
#include "SDL3/SDL_main.h"
#include "SDL3_ttf/SDL_ttf.h"
int main(int argc, char ** argv)
{
bool quit = false;
SDL_Event event;
SDL_Init(SDL_INIT_VIDEO);
TTF_Init();
SDL_Window * window = SDL_CreateWindow("SDL_ttf in SDL2",640,480, 0);
SDL_Renderer * renderer = SDL_CreateRenderer(window, NULL);
TTF_Font * font = TTF_OpenFont("/Library/pM_Fonts/coolvetica.ttf", 25);
SDL_Color color = { 255, 255, 255 };
SDL_Surface * surface = TTF_RenderText_Solid(font,"Hello, WorldSR",11, color);
SDL_Texture * texture = SDL_CreateTextureFromSurface(renderer, surface);
int texW = 0;
int texH = 0;
// SDL_QueryTexture(texture, NULL, NULL, &texW, &texH);
SDL_Rect dstrect = { 0, 0, texture->w, texture->h };
while (!quit)
{
SDL_WaitEvent(&event);
switch (event.type)
{
case SDL_EVENT_QUIT:
quit = true;
break;
}
SDL_RenderTexture(renderer, texture, NULL, &dstrect);
SDL_RenderPresent(renderer);
}
SDL_DestroyTexture(texture);
TTF_CloseFont(font);
SDL_DestroyRenderer(renderer);
SDL_DestroyWindow(window);
TTF_Quit();
SDL_Quit();
return 0;
}
Any help is appreciated
Thank you!