Page 1 of 1

How can I draw on both Screens with citro2d

Posted: Sun Jul 19, 2020 11:22 am
by Rüdiger
I want to draw on both screens with citro2d but when I do the bottom screen is very buggy and picture gets duplicated and only the half get drawn.
The top screen works fine

Sorry for my bad english

Re: How can I draw on both Screens with citro2d

Posted: Sun Jul 19, 2020 11:45 am
by fincs
Can you post your code? Without it I can't diagnose or give you advice.

Re: How can I draw on both Screens with citro2d

Posted: Sun Jul 19, 2020 12:05 pm
by Rüdiger
Never mind I found the problem: consoleInit(GFX_BOTTOM, NULL);
but idk why this was the problem

This was the code

Code: Select all

#include <citro2d.h>
#include <3ds.h>


int main(int argc, char* argv[]) {
	gfxInitDefault();
	C3D_Init(C3D_DEFAULT_CMDBUF_SIZE);
	C2D_Init(C2D_DEFAULT_MAX_OBJECTS);
	C2D_Prepare();
	consoleInit(GFX_BOTTOM, NULL);

	C3D_RenderTarget* bot = C2D_CreateScreenTarget(GFX_BOTTOM, GFX_LEFT);


	u32 clear_color = C2D_Color32f(0.0f, 0.0f, 0.0f, 1.0f);

	while (aptMainLoop()) {
		gspWaitForVBlank();
		hidScanInput();

		u32 kDown = hidKeysDown();
		if (kDown & KEY_SELECT)
			break;

		C3D_FrameBegin(C3D_FRAME_SYNCDRAW);

		C2D_TargetClear(bot, clear_color);
		C2D_SceneBegin(bot);

		C2D_DrawRectSolid(0, 0, 0, 40, 40, C2D_Color32f(1, 1, 1, 1));


		C2D_Flush();
		C3D_FrameEnd(0);
	}
	C2D_Fini();
	C3D_Fini();

	gfxExit();
	return 0;
}

Re: How can I draw on both Screens with citro2d

Posted: Sun Jul 19, 2020 12:45 pm
by fincs
You were both creating a rendertarget on the bottom screen *and* a console. Put the console on the other screen so that they don't conflict.
When using citro3d/citro2d, you must not use gspWaitForVBlank, as these libs automatically handle screen synchronization.

Re: How can I draw on both Screens with citro2d

Posted: Sun Jul 19, 2020 1:02 pm
by Rüdiger
Is it possible to uninitialize the console, use it for citro2d and back on

Re: How can I draw on both Screens with citro2d

Posted: Sun Jul 19, 2020 1:53 pm
by fincs
Nope, sorry. The console is really only meant to be used in quick prototype programs that are not interested in setting up proper rendering.