Draw specific pixel
Posted: Mon Sep 09, 2024 3:01 pm
How can I draw a pixel at a specific location?
I tried it like this but the pixels get drawn completely wrong. Also multiple lines get drawn simultaneously as well. Thats my code rn:
const int TOP_SCREEN_WIDTH = 400;
const int BOTTOM_SCREEN_WIDTH = 320;
const int BOTH_SCREEN_HEIGHT = 240;
Code: Select all
const char* ERASER = "\x1b[40m \x1b[0m";
const int MIN_COLOR = 41;
const int MAX_COLOR = 47;
gfxInitDefault();
hidInit();
mcuHwcInit();
PrintConsole topScreen, bottomScreen;
consoleInit(GFX_TOP, &topScreen);
consoleInit(GFX_BOTTOM, &bottomScreen);
[code]u8* buffer = gfxGetFramebuffer(GFX_BOTTOM, GFX_LEFT, NULL, NULL);
touchPosition touch;
int offset;
while (aptMainLoop())
{
hidScanInput();
if (hidKeysDown() & KEY_START) break;
if (hidKeysHeld() & KEY_TOUCH)
{
hidTouchRead(&touch);
offset = (touch.py * BOTTOM_SCREEN_WIDTH + touch.px) * 2;
buffer[offset] = 0xF800 & 0xFF;
buffer[offset + 1] = (0xF800 >> 8) & 0xFF;
}
}[/code]