Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

185
Views
Ventana que no muestra SDL2

Estoy usando SDL2 por primera vez, y cuando trato de crear una ventana, no se muestra. La única vista de la ventana es un icono que aparece en mi base ( Imagen del icono , SDLTest.out es el nombre de mi archivo ejecutable). Descubrí que se generó cuando se llamó a SDL_INIT() .

Intenté actualizar la ventana, cambiar su color y agregar la bandera SDL_WINDOW_SHOWN , pero ninguna de estas soluciones funcionó. Incluso pegué un código de Internet, pero no funcionó mejor.

Aquí está el código que pegué:

 #include <SDL2/SDL.h> #include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { SDL_Window *window = NULL; SDL_Renderer *renderer = NULL; int status = EXIT_FAILURE; SDL_Color orange = {255, 127, 40, 255}; if(0 != SDL_Init(SDL_INIT_VIDEO)) { fprintf(stderr, "Error SDL_Init : %s", SDL_GetError()); goto Quit; } window = SDL_CreateWindow("SDL2", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 480, SDL_WINDOW_SHOWN); if(NULL == window) { fprintf(stderr, "Error SDL_CreateWindow : %s", SDL_GetError()); goto Quit; } renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED); if(NULL == renderer) { fprintf(stderr, "Error SDL_CreateRenderer : %s", SDL_GetError()); goto Quit; } if(0 != SDL_SetRenderDrawColor(renderer, orange.r, orange.g, orange.b, orange.a)) { fprintf(stderr, "Error SDL_SetRenderDrawColor : %s", SDL_GetError()); goto Quit; } if(0 != SDL_RenderClear(renderer)) { fprintf(stderr, "Error SDL_SetRenderDrawColor : %s", SDL_GetError()); goto Quit; } SDL_Delay(500); SDL_RenderPresent(renderer); SDL_Delay(500); status = EXIT_SUCCESS; Quit: if(NULL != renderer) SDL_DestroyRenderer(renderer); if(NULL != window) SDL_DestroyWindow(window); SDL_Quit(); return status; }

Mi sistema operativo es MacOS 11.6, mi compilador GCC, mi computadora tiene una tarjeta gráfica Intel Iris Pro Graphics 6200 e instalé SDL2 usando Homebrew.

¿Alguien me puede ayudar?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Solo necesitaba un bucle de eventos. Agregué este código y funcionó:

 SDL_bool quit = SDL_FALSE; while(!quit) { SDL_RenderPresent(renderer); SDL_WaitEvent(&event); if(event.type == SDL_QUIT) quit = SDL_TRUE; }

¡Gracias a HolyBlackCat por tu comentario!

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!