mirror of
				https://gitlab.com/klmp200/LO27.git
				synced 2025-10-31 04:43:05 +00:00 
			
		
		
		
	Swag matrice en SDL
This commit is contained in:
		| @@ -1,5 +1,5 @@ | ||||
| CC=gcc | ||||
| CFLAGS=-Wall -Werror -pedantic -fpic -g -std=c89 | ||||
| CFLAGS=-Wall -Werror -pedantic -fpic -g -std=c89 -Wextra | ||||
|  | ||||
|  | ||||
| LIBSDIR=-L/usr/lib -L../Libs | ||||
|   | ||||
| @@ -2,7 +2,7 @@ | ||||
| * @Author: klmp200 | ||||
| * @Date:   2016-12-27 19:59:21 | ||||
| * @Last Modified by:   klmp200 | ||||
| * @Last Modified time: 2016-12-28 18:48:54 | ||||
| * @Last Modified time: 2016-12-28 21:36:39 | ||||
| */ | ||||
|  | ||||
| #include <stdio.h> | ||||
| @@ -10,10 +10,29 @@ | ||||
| #include <SDL2/SDL.h> | ||||
| #include <pixel.h> | ||||
| #include <matrix.h> | ||||
| #include <cellElement.h> | ||||
|  | ||||
| void SDL_test(){ | ||||
| 	PIXEL test; | ||||
| 	Matrix gg = CreateMatrix(); | ||||
| 	SetCellValue(gg, 1, 1, true); | ||||
| 	test.color = 1; | ||||
| void SetPixel(SDL_Renderer *renderer, int x, int y, bool value){ | ||||
|  | ||||
| 	if (value){ | ||||
| 		SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255); | ||||
| 	} else { | ||||
| 		SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255); | ||||
| 	} | ||||
| 	SDL_RenderDrawPoint(renderer, x, y); | ||||
| } | ||||
|  | ||||
| void DisplayMatrixSDL(SCREEN *screen, Matrix m){ | ||||
| 	int i; | ||||
| 	int j; | ||||
|  | ||||
| 	SDL_SetRenderDrawColor(screen->renderer, 0, 0, 0, 0); | ||||
| 	SDL_RenderClear(screen->renderer); | ||||
|  | ||||
| 	for (i=0;i<m.rowCount;i++){ | ||||
| 		for (j=0;j<m.colCount;j++){ | ||||
| 			SetPixel(screen->renderer, i, j, GetCellValue(m, j, i)); | ||||
| 		} | ||||
| 	} | ||||
| 	SDL_RenderPresent(screen->renderer); | ||||
| } | ||||
|   | ||||
| @@ -2,12 +2,33 @@ | ||||
| #define PIXEL_H_INCLUDED | ||||
|  | ||||
| #include <SDL2/SDL.h> | ||||
| #include <cellElement.h> | ||||
| #include <matrix.h> | ||||
|  | ||||
| typedef struct { | ||||
| 	SDL_Rect position; | ||||
| 	Uint8 color; | ||||
| } PIXEL; | ||||
| 	SDL_Window * window; | ||||
| 	SDL_Renderer * renderer; | ||||
| 	int WIDTH; | ||||
| 	int HEIGHT; | ||||
| 	SDL_Event event; | ||||
| } SCREEN; | ||||
|  | ||||
| void SDL_test(); | ||||
| /** | ||||
| * Set a pixel on a given screen | ||||
| * @param screen the screen to display the pixel | ||||
| * @param x x position | ||||
| * @param y y position | ||||
| * @param value display white if true and black if false | ||||
| * @return | ||||
| */ | ||||
| void SetPixel(SDL_Renderer *renderer, int x, int y, bool value); | ||||
|  | ||||
| /** | ||||
| * Display an entire matrix on a given screen | ||||
| * @param screen the screen where the matrix should be displayed | ||||
| * @param m a Matrix | ||||
| * @return | ||||
| */ | ||||
| void DisplayMatrixSDL(SCREEN *screen, Matrix m); | ||||
|  | ||||
| #endif | ||||
|   | ||||
		Reference in New Issue
	
	Block a user