How can I draw on both Screens with citro2d

Post Reply
Rüdiger
Posts: 4
Joined: Sat Jun 06, 2020 12:20 am
Location: Germany

How can I draw on both Screens with citro2d

Post by Rüdiger » Sun Jul 19, 2020 11:22 am

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

User avatar
fincs
( ͡° ͜ʖ ͡°)
Posts: 93
Joined: Mon Jul 12, 2010 9:45 pm
Location: Seville, Spain
Contact:

Re: How can I draw on both Screens with citro2d

Post by fincs » Sun Jul 19, 2020 11:45 am

Can you post your code? Without it I can't diagnose or give you advice.
Donate to devkitPro - help us stay alive!

Rüdiger
Posts: 4
Joined: Sat Jun 06, 2020 12:20 am
Location: Germany

Re: How can I draw on both Screens with citro2d

Post by Rüdiger » Sun Jul 19, 2020 12:05 pm

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;
}

User avatar
fincs
( ͡° ͜ʖ ͡°)
Posts: 93
Joined: Mon Jul 12, 2010 9:45 pm
Location: Seville, Spain
Contact:

Re: How can I draw on both Screens with citro2d

Post by fincs » Sun Jul 19, 2020 12:45 pm

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.
Donate to devkitPro - help us stay alive!

Rüdiger
Posts: 4
Joined: Sat Jun 06, 2020 12:20 am
Location: Germany

Re: How can I draw on both Screens with citro2d

Post by Rüdiger » Sun Jul 19, 2020 1:02 pm

Is it possible to uninitialize the console, use it for citro2d and back on

User avatar
fincs
( ͡° ͜ʖ ͡°)
Posts: 93
Joined: Mon Jul 12, 2010 9:45 pm
Location: Seville, Spain
Contact:

Re: How can I draw on both Screens with citro2d

Post by fincs » Sun Jul 19, 2020 1:53 pm

Nope, sorry. The console is really only meant to be used in quick prototype programs that are not interested in setting up proper rendering.
Donate to devkitPro - help us stay alive!

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest