debug screen
This commit is contained in:
105
lib/ui.c
105
lib/ui.c
@ -131,12 +131,27 @@ void ui_update() {
|
||||
SDL_UpdateTexture(sdlTexture, NULL, screen->pixels, screen->pitch);
|
||||
SDL_RenderClear(sdlRenderer);
|
||||
SDL_RenderCopy(sdlRenderer, sdlTexture, NULL, NULL);
|
||||
TTF_Font* sans = TTF_OpenFont("Sans.ttf", 24);
|
||||
if ( !sans ) {
|
||||
printf("Failed to load font: %s\n", TTF_GetError());
|
||||
}
|
||||
SDL_Color text_color = {255,255,255};
|
||||
int yOffset = 50;
|
||||
int lastY = (yOffset) + (audio_get_context()->sq1_history[0] * 50);
|
||||
int lastY = (yOffset) - (audio_get_context()->sq1_history[audio_get_context()->sq1_index] * 50);
|
||||
int xOffset = XRES*scale;
|
||||
SDL_Surface* message = TTF_RenderText_Solid(sans, "Square 1", text_color);
|
||||
SDL_Texture* messageTexture = SDL_CreateTextureFromSurface(sdlRenderer, message);
|
||||
SDL_Rect messageRect;
|
||||
messageRect.x = xOffset;
|
||||
messageRect.y = yOffset-50;
|
||||
messageRect.w = 50;
|
||||
messageRect.h = 20;
|
||||
SDL_RenderCopy(sdlRenderer, messageTexture, NULL, &messageRect);
|
||||
SDL_SetRenderDrawColor(sdlRenderer, 0, 255, 0, 255);
|
||||
for(int x = 1; x < 882; x++){
|
||||
int y = (yOffset) + (audio_get_context()->sq1_history[x*5] * 50);
|
||||
SDL_FreeSurface(message);
|
||||
SDL_DestroyTexture(messageTexture);
|
||||
for(int x = 1; x < 384; x++){
|
||||
int y = (yOffset) - (audio_get_context()->sq1_history[(x + audio_get_context()->sq1_index) % 384] * 50);
|
||||
SDL_RenderDrawLine(sdlRenderer, x-1+xOffset, lastY, x+xOffset, y);
|
||||
lastY = y;
|
||||
if(x+xOffset == SCREEN_WIDTH) {
|
||||
@ -145,10 +160,20 @@ void ui_update() {
|
||||
}
|
||||
|
||||
yOffset = 150;
|
||||
lastY = (yOffset) + (audio_get_context()->sq2_history[0] * 50);
|
||||
lastY = (yOffset) - (audio_get_context()->sq2_history[audio_get_context()->sq2_index] * 50);
|
||||
message = TTF_RenderText_Solid(sans, "Square 2", text_color);
|
||||
messageTexture = SDL_CreateTextureFromSurface(sdlRenderer, message);
|
||||
messageRect.x = xOffset;
|
||||
messageRect.y = yOffset-50;
|
||||
messageRect.w = 50;
|
||||
messageRect.h = 20;
|
||||
SDL_RenderCopy(sdlRenderer, messageTexture, NULL, &messageRect);
|
||||
SDL_SetRenderDrawColor(sdlRenderer, 0, 255, 0, 255);
|
||||
for(int x = 1; x < 882; x++){
|
||||
int y = (yOffset) + (audio_get_context()->sq2_history[x*5] * 50);
|
||||
SDL_FreeSurface(message);
|
||||
SDL_DestroyTexture(messageTexture);
|
||||
SDL_SetRenderDrawColor(sdlRenderer, 0, 255, 0, 255);
|
||||
for(int x = 1; x < 384; x++){
|
||||
int y = (yOffset) - (audio_get_context()->sq2_history[(x + audio_get_context()->sq2_index) % 384] * 50);
|
||||
SDL_RenderDrawLine(sdlRenderer, x-1+xOffset, lastY, x+xOffset, y);
|
||||
lastY = y;
|
||||
if(x+xOffset == SCREEN_WIDTH) {
|
||||
@ -157,10 +182,21 @@ void ui_update() {
|
||||
}
|
||||
|
||||
yOffset = 250;
|
||||
lastY = (yOffset) + (audio_get_context()->ch3_history[0] * 50);
|
||||
lastY = (yOffset) - (audio_get_context()->ch3_history[audio_get_context()->ch3_index] * 50);
|
||||
message = TTF_RenderText_Solid(sans, "Wave", text_color);
|
||||
messageTexture = SDL_CreateTextureFromSurface(sdlRenderer, message);
|
||||
messageRect.x = xOffset;
|
||||
messageRect.y = yOffset-50;
|
||||
messageRect.w = 50;
|
||||
messageRect.h = 20;
|
||||
SDL_RenderCopy(sdlRenderer, messageTexture, NULL, &messageRect);
|
||||
SDL_SetRenderDrawColor(sdlRenderer, 0, 255, 0, 255);
|
||||
for(int x = 1; x < 882; x++){
|
||||
int y = (yOffset) + (audio_get_context()->ch3_history[x*5] * 50);
|
||||
SDL_FreeSurface(message);
|
||||
SDL_DestroyTexture(messageTexture);
|
||||
SDL_SetRenderDrawColor(sdlRenderer, 0, 255, 0, 255);
|
||||
SDL_SetRenderDrawColor(sdlRenderer, 0, 255, 0, 255);
|
||||
for(int x = 1; x < 384; x++){
|
||||
int y = (yOffset) - (audio_get_context()->ch3_history[(x + audio_get_context()->ch3_index) % 384] * 50);
|
||||
SDL_RenderDrawLine(sdlRenderer, x-1+xOffset, lastY, x+xOffset, y);
|
||||
lastY = y;
|
||||
if(x+xOffset == SCREEN_WIDTH) {
|
||||
@ -169,10 +205,21 @@ void ui_update() {
|
||||
}
|
||||
|
||||
yOffset = 350;
|
||||
lastY = (yOffset) + (audio_get_context()->ch4_history[0] * 50);
|
||||
lastY = (yOffset) - (audio_get_context()->ch4_history[audio_get_context()->ch4_index] * 50);
|
||||
message = TTF_RenderText_Solid(sans, "Noise", text_color);
|
||||
messageTexture = SDL_CreateTextureFromSurface(sdlRenderer, message);
|
||||
messageRect.x = xOffset;
|
||||
messageRect.y = yOffset-50;
|
||||
messageRect.w = 50;
|
||||
messageRect.h = 20;
|
||||
SDL_RenderCopy(sdlRenderer, messageTexture, NULL, &messageRect);
|
||||
SDL_SetRenderDrawColor(sdlRenderer, 0, 255, 0, 255);
|
||||
for(int x = 1; x < 882; x++){
|
||||
int y = (yOffset) + (audio_get_context()->ch4_history[x*5] * 50);
|
||||
SDL_FreeSurface(message);
|
||||
SDL_DestroyTexture(messageTexture);
|
||||
SDL_SetRenderDrawColor(sdlRenderer, 0, 255, 0, 255);
|
||||
SDL_SetRenderDrawColor(sdlRenderer, 0, 255, 0, 255);
|
||||
for(int x = 1; x < 384; x++){
|
||||
int y = (yOffset) - (audio_get_context()->ch4_history[(x + audio_get_context()->ch4_index) % 384] * 50);
|
||||
SDL_RenderDrawLine(sdlRenderer, x-1+xOffset, lastY, x+xOffset, y);
|
||||
lastY = y;
|
||||
if(x+xOffset == SCREEN_WIDTH) {
|
||||
@ -181,10 +228,21 @@ void ui_update() {
|
||||
}
|
||||
|
||||
yOffset = 450;
|
||||
lastY = (yOffset) + (audio_get_context()->left_history[0] * 50);
|
||||
lastY = (yOffset) - (audio_get_context()->left_history[audio_get_context()->left_index] * 50);
|
||||
message = TTF_RenderText_Solid(sans, "Left Out", text_color);
|
||||
messageTexture = SDL_CreateTextureFromSurface(sdlRenderer, message);
|
||||
messageRect.x = xOffset;
|
||||
messageRect.y = yOffset-50;
|
||||
messageRect.w = 50;
|
||||
messageRect.h = 20;
|
||||
SDL_RenderCopy(sdlRenderer, messageTexture, NULL, &messageRect);
|
||||
SDL_SetRenderDrawColor(sdlRenderer, 0, 255, 0, 255);
|
||||
SDL_FreeSurface(message);
|
||||
SDL_DestroyTexture(messageTexture);
|
||||
SDL_SetRenderDrawColor(sdlRenderer, 0, 255, 0, 255);
|
||||
SDL_SetRenderDrawColor(sdlRenderer, 0, 0, 255, 255);
|
||||
for(int x = 1; x < 882; x++){
|
||||
int y = (yOffset) + (audio_get_context()->left_history[x*5] * 50);
|
||||
for(int x = 1; x < 384; x++){
|
||||
int y = (yOffset) - (audio_get_context()->left_history[(x + audio_get_context()->left_index) % 384] * 50);
|
||||
SDL_RenderDrawLine(sdlRenderer, x-1+xOffset, lastY, x+xOffset, y);
|
||||
lastY = y;
|
||||
if(x+xOffset == SCREEN_WIDTH) {
|
||||
@ -193,10 +251,21 @@ void ui_update() {
|
||||
}
|
||||
|
||||
yOffset = 550;
|
||||
lastY = (yOffset) + (audio_get_context()->right_history[0] * 50);
|
||||
lastY = (yOffset) - (audio_get_context()->right_history[audio_get_context()->right_index] * 50);
|
||||
message = TTF_RenderText_Solid(sans, "Right Out", text_color);
|
||||
messageTexture = SDL_CreateTextureFromSurface(sdlRenderer, message);
|
||||
messageRect.x = xOffset;
|
||||
messageRect.y = yOffset-50;
|
||||
messageRect.w = 50;
|
||||
messageRect.h = 20;
|
||||
SDL_RenderCopy(sdlRenderer, messageTexture, NULL, &messageRect);
|
||||
SDL_SetRenderDrawColor(sdlRenderer, 0, 255, 0, 255);
|
||||
SDL_FreeSurface(message);
|
||||
SDL_DestroyTexture(messageTexture);
|
||||
SDL_SetRenderDrawColor(sdlRenderer, 0, 255, 0, 255);
|
||||
SDL_SetRenderDrawColor(sdlRenderer, 0, 0, 255, 255);
|
||||
for(int x = 1; x < 882; x++){
|
||||
int y = (yOffset) + (audio_get_context()->right_history[x*5] * 50);
|
||||
for(int x = 1; x < 384; x++){
|
||||
int y = (yOffset) - (audio_get_context()->right_history[(x + audio_get_context()->right_index) % 384] * 50);
|
||||
SDL_RenderDrawLine(sdlRenderer, x-1+xOffset, lastY, x+xOffset, y);
|
||||
lastY = y;
|
||||
if(x+xOffset == SCREEN_WIDTH) {
|
||||
|
Reference in New Issue
Block a user