Created a test pattern in the client's screen.

This commit is contained in:
2021-12-14 20:32:11 -06:00
parent 31ea565754
commit 5bda17331c
4 changed files with 25 additions and 14 deletions
-10
View File
@@ -1,10 +0,0 @@
#ifndef _CAPP_H
#define _CAPP_H
#include <SDL.h>
#endif
+1
View File
@@ -6,6 +6,7 @@
#define VSCREEN_WIDTH 640
#define VSCREEN_HEIGHT 480
#define VSCREEN_COLUMN_COUNT 20
#define VSCREEN_ROW_COUNT 20
void renderClientScreen(SDL_Renderer *);
-2
View File
@@ -63,8 +63,6 @@ int main(int argc, char* args[]) {
handleInput();
//blit(player.texture, player.x, player.y);
presentScene();
SDL_Delay(16);
+24 -2
View File
@@ -2,13 +2,35 @@
#include <SDL2/SDL_image.h>
#include <SDL2/SDL_render.h>
#include <SDL2/SDL_surface.h>
#include <stdio.h>
void renderClientScreen(SDL_Renderer* renderer) {
SDL_Rect dest;
SDL_RenderGetViewport(renderer, &dest);
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
SDL_Rect cell;
cell.w = dest.w / VSCREEN_COLUMN_COUNT;
cell.h = dest.h / VSCREEN_ROW_COUNT;
SDL_RenderFillRect(renderer, &dest);
int row = 0;
unsigned char backgroundColor = 0x00;
for (int i = 0; i < VSCREEN_ROW_COUNT; i++) {
for(int j = 0; j <VSCREEN_COLUMN_COUNT; j++) {
SDL_SetRenderDrawColor(renderer, backgroundColor, backgroundColor, backgroundColor, 255);
cell.x = j * cell.w;
cell.y = i * cell.h;
SDL_RenderFillRect(renderer, &cell);
backgroundColor ^= 0xFF;
}
backgroundColor ^= 0xFF;
row++;
}
}