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
| #include <stdio.h>
#include <SDL3/SDL.h>
#include <SDL3/SDL_main.h> // only include this one in the source file with main()!#include <SDL3/SDL_render.h>
#include <SDL3/SDL_events.h>
#include <SDL3/SDL_render.h>
#include <SDL3/SDL_surface.h>
#include <SDL3/SDL_ttf.h>
#include <string.h>
#include <SDL3/SDL_rect.h >
#include <stdbool.h>
int main(int argc, char* argv[])
{
const int WIDTH = 800;
const int HEIGHT = 600;
const char* err = NULL;
bool text_input_complete = false, v;
char text[1024] = { "a"};
int cursor = 0, retour = 0;
SDL_Surface* texts = NULL;
TTF_Font* police = NULL;
SDL_Color blanc = { 0, 0, 0 };
SDL_Texture* texture = NULL;
SDL_FRect* srcrect, * dstrect;
SDL_FRect frect_dst = { 0,0,800,600 };
const SDL_FRect area = { 10,50,100,50 };
SDL_FRect rect = { 10,50,100,0 };
SDL_Window* window = NULL;
SDL_Renderer* renderer = NULL;
SDL_Init(SDL_INIT_VIDEO);
if (TTF_Init() == -1) {
printf("TTF init a un probléme !");
}
police = TTF_OpenFont("WsParadoseRegular-1jPAe.ttf", 12);
err = SDL_GetError();
window = SDL_CreateWindow("Ave frater", WIDTH, HEIGHT, 0);
renderer = SDL_CreateRenderer(window, NULL);
SDL_RenderPresent(renderer);
texts = TTF_RenderText_Blended(police, text, 5, blanc);
texture = SDL_CreateTextureFromSurface(renderer, texts);
v = SDL_RenderTexture(renderer, texture, NULL, NULL);
SDL_SetRenderDrawColor(renderer, 0x00, 0xFF, 0x00, 0xFF);
SDL_RenderFillRect(renderer, &rect);
SDL_RenderPresent(renderer);
SDL_DestroyRenderer(renderer);
SDL_DestroyWindow(window);
SDL_Quit();
return 0; |
Partager