π
<-

La fonction nSDL_LoadImage de nSDL

C, C++, ASM...

La fonction nSDL_LoadImage de nSDL

Unread postby newprog » 07 Jan 2013, 16:30

Bonjour,

J'ai un problème à l'exécution du code suivant :

Code: Select all
#include <os.h>
#include <SDL/SDL.h>
#include <SDL/fdlibm.h>
#include <SDL/SDL_gfxPrimitives.h>
#include "img.h"

int main(void) {
   int i=0,x,y;
   
   SDL_Surface *screen;
   nSDL_Font *font;
   
   SDL_Surface *mario_sdl;
   SDL_Rect position_mario;
   
   SDL_Init(SDL_INIT_VIDEO);
   screen = SDL_SetVideoMode(320, 240, is_cx ? 16 : 8, SDL_SWSURFACE);
   
   font = nSDL_LoadFont(NSDL_FONT_THIN,
                        SDL_MapRGB(screen->format, 29, 43, 61),
                        NSDL_FONTCFG_DEFAULT);
   SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 184, 200, 222));
   nSDL_DrawString(screen, font, (int)(rand()%250), (int)(rand()%180), "Hello, world! \x1");
   
   // nl_relocdata((unsigned*)image_mario, sizeof(image_mario)/sizeof(unsigned short));
   mario_sdl=nSDL_LoadImage(image_mario);

       position_mario.x = 0;
       position_mario.y = 0;

    /* On blitte par-dessus l'écran */
   SDL_BlitSurface(image_mario, NULL, screen, &position_mario);  //l'erreur à l'exécution est ici mais pourquoi ?
   SDL_Flip(screen);
   wait_key_pressed();
   
   boxColor(screen, 0, 0, 320, 240, 0);
   
   SDL_Flip(screen);
   SDL_Delay(3000);
   SDL_FreeSurface(mario_sdl);
   SDL_Quit();
   return 0;
}

*/


L'erreur intervenant à l'exécution du programme est la suivante : "Surfaces must not be locked during blit"

Quelqu'un a t-il une idée ?

Merci
User avatar
newprog
Niveau 3: MH (Membre Habitué)
Niveau 3: MH (Membre Habitué)
Level up: 84%
 
Posts: 15
Joined: 28 Nov 2012, 00:48
Gender: Not specified
Calculator(s):
MyCalcs profile
Class: Un peu trop vieux pour l'avouer

Re: La fonction nSDL_LoadImage de nSDL

Unread postby sarniq » 07 Jan 2013, 23:15

Tu devrais pas plutot blitter mario_sdl au lieu de image_mario? J'ai l'impression que t'essayes de blitter un tableau...
User avatar
sarniq
Niveau 1: MD (Membre Débutant)
Niveau 1: MD (Membre Débutant)
Level up: 20%
 
Posts: 3
Joined: 07 Jan 2013, 23:14
Gender: Not specified
Calculator(s):
MyCalcs profile

Re: La fonction nSDL_LoadImage de nSDL

Unread postby newprog » 08 Jan 2013, 12:36

Exact, j'étais en train d'essayer de blitter un tableau. Ca marche en mettant mario_sdl.

C'est vraiment une erreur bête...

Merci pour ton aide sarniq
User avatar
newprog
Niveau 3: MH (Membre Habitué)
Niveau 3: MH (Membre Habitué)
Level up: 84%
 
Posts: 15
Joined: 28 Nov 2012, 00:48
Gender: Not specified
Calculator(s):
MyCalcs profile
Class: Un peu trop vieux pour l'avouer


Return to Native: Ndless, Linux, ...

Who is online

Users browsing this forum: ClaudeBot [spider] and 2 guests

-
Search
-
Social TI-Planet
-
Featured topics
Comparaisons des meilleurs prix pour acheter sa calculatrice !
"1 calculatrice pour tous", le programme solidaire de Texas Instruments. Reçois gratuitement et sans aucune obligation d'achat, 5 calculatrices couleur programmables en Python à donner aux élèves les plus nécessiteux de ton lycée. Tu peux recevoir au choix 5 TI-82 Advanced Edition Python ou bien 5 TI-83 Premium CE Edition Python.
Enseignant(e), reçois gratuitement 1 exemplaire de test de la TI-82 Advanced Edition Python. À demander d'ici le 31 décembre 2024.
Aidez la communauté à documenter les révisions matérielles en listant vos calculatrices graphiques !
1234
-
Donations / Premium
For more contests, prizes, reviews, helping us pay the server and domains...
Donate
Discover the the advantages of a donor account !
JoinRejoignez the donors and/or premium!les donateurs et/ou premium !


Partner and ad
Notre partenaire Jarrety Calculatrices à acheter chez Calcuso
-
Stats.
2071 utilisateurs:
>2058 invités
>6 membres
>7 robots
Record simultané (sur 6 mois):
6892 utilisateurs (le 07/06/2017)
-
Other interesting websites
Texas Instruments Education
Global | France
 (English / Français)
Banque de programmes TI
ticalc.org
 (English)
La communauté TI-82
tout82.free.fr
 (Français)