C++ Noob Here :P
August 29, 2008 06:02AM
Are there any good c++ tutorials out there that are specific to wii coding? Still a pretty big coding NOOB here. I'll be using devkitPro's programmers notepad, and wiiload to transfer over my creations. all help is appreciated :)

P.S. lol sorry for using those random huge words, I just think they're FUN

P.S.S. No emoticons here?
Re: C++ Noob Here :P
August 29, 2008 06:40AM
Join the club :(

Um here is a good starting tutorial (there are three there)

Code Mii

and ask Xylite for tips ^_^
Re: C++ Noob Here :P
August 29, 2008 06:53AM
If you want to do C++ on wii, learn it for computer first. It's more straight forward and the theory is the same. I would recommend www.cprogramming.com www.cplusplus.com and www.gamedev.net they all contain articles for begginers right through to advanced graphics, physics and ai on gamedev.
Once you have some of the more advanced concepts down like classes, polymorphism etc then changing to the wii will be very easy, it's not much differnet to PC, just a few function calls (among other things).
Re: C++ Noob Here :P
August 29, 2008 03:16PM
Get the helloworld program running first.
Re: C++ Noob Here :P
August 29, 2008 04:48PM
arikado--

//helloworld

#include
using namespace std;

int main ()
{
cout << "Hello World!";
return 0;
}

There...I tried to compile this into a dol, but...look:

"make": *** No targets specified and no makefile found. Stop.

Well, thanks for all the help. :)
Re: C++ Noob Here :P
August 29, 2008 06:34PM
Are you using the tut. on www.cplusplus.com...because I learned that the Hello World example doesn't work either when trying to use Devkit PPC -.- I'm guessing because it has to be Wii specific...So go to

C:\devkitPro\examples\gamecube\template

and click the template.pnproj and thennnn compile it and then drag the .dol/elf file over to

C:\devkitPro\emulators\gcube

and over to the gcube.exe

yeah use the gamecube stuff, because you would have to use Wii Load or something and view it with your Wii...Personally I think it's easier to view it on your PC ^_^

oh yeah and here is the Gamecube Hello World example (alot more complex <.<)

#include 
#include 
#include 
#include 
#include 
#include 

static void *xfb = NULL;
static GXRModeObj *rmode = NULL;

void *Initialise();

int main(int argc, char **argv) {

	xfb = Initialise();

	printf("\nHello World!\n");

	while(1) {

		VIDEO_WaitVSync();
		PAD_ScanPads();

		int buttonsDown = PAD_ButtonsDown(0);
		
		if( buttonsDown & PAD_BUTTON_A ) {
			printf("Button A pressed.\n");
		}

		if (buttonsDown & PAD_BUTTON_START) {
			exit(0);
		}
	}

	return 0;
}

void * Initialise() {

	void *framebuffer;

	VIDEO_Init();
	PAD_Init();
	
	rmode = VIDEO_GetPreferredMode(NULL);

	framebuffer = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));
	console_init(framebuffer,20,20,rmode->fbWidth,rmode->xfbHeight,rmode->fbWidth*VI_DISPLAY_PIX_SZ);
	
	VIDEO_Configure(rmode);
	VIDEO_SetNextFramebuffer(framebuffer);
	VIDEO_SetBlack(FALSE);
	VIDEO_Flush();
	VIDEO_WaitVSync();
	if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync();

	return framebuffer;

}
Re: C++ Noob Here :P
August 29, 2008 10:14PM
@Daisyfoofpoof

cout << " "; doesn't work with wii programming. If you have libogc devkitppc properly set up then the helloworl example should be in the devkitppc (devkitpro) folder all ready to be complied.
Re: C++ Noob Here :P
August 30, 2008 04:29AM
@Arikado

cout simply does work.. people usually use printf because they cbf trying to figure it out (not that hard). change

#include

to

#include

now we have the C++ io lib instead of the C one. Then you can call cout if you have the cursor set. Top right hand corner would set it like this:

cout << "\x1b[2;0H";

Description from devkitPro hell world example (template):

"The console understands VT terminal escape codes
This positions the cursor on row 2, column 0
we can use variables for this with format codes too
e.g. printf ("\x1b[%d;%dH", row, column );"

now cout can be called as

std::cout

or just cout if you already have "using namespace std;"

Arikado, perhaps before bluntly saying something won't work, consider how it actually works.

Daisyfoofpoof:
There's a reason I told you to do it on PC first, you don't even have a make file so you can't expect GCC to compile it, hence the error you got said no make file found. The hello worl program you posted there will NOT work on wii as it is. Even if you compiled it on a compiler such as devCpp it won't work on wii. You should learn the basics on PC before jumping directly into the wii, it requires more lines of code to get text on the screen than the basic PC one. For example the hello world program for PC usually looks like this:

#include

using namespace std;

int main()
{

cout << "hello world";

return 0;

}

Do you underestand all of this? Now look at the same thing but for wii:
Quote
template
#include
#include
#include
#include
#include

static void *xfb = NULL;
static GXRModeObj *rmode = NULL;

//---------------------------------------------------------------------------------
int main(int argc, char **argv) {
//---------------------------------------------------------------------------------

// Initialise the video system
VIDEO_Init();

// This function initialises the attached controllers
WPAD_Init();

// Obtain the preferred video mode from the system
// This will correspond to the settings in the Wii menu
rmode = VIDEO_GetPreferredMode(NULL);

// Allocate memory for the display in the uncached region
xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));

// Initialise the console, required for printf
console_init(xfb,20,20,rmode->fbWidth,rmode->xfbHeight,rmode->fbWidth*VI_DISPLAY_PIX_SZ);

// Set up the video registers with the chosen mode
VIDEO_Configure(rmode);

// Tell the video hardware where our display memory is
VIDEO_SetNextFramebuffer(xfb);

// Make the display visible
VIDEO_SetBlack(FALSE);

// Flush the video register changes to the hardware
VIDEO_Flush();

// Wait for Video setup to complete
VIDEO_WaitVSync();
if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync();

std::cout << "\x1b[2;0H";


std::cout << "Hello World!" << std::endl;

while(1) {

// Call WPAD_ScanPads each loop, this reads the latest controller states
WPAD_ScanPads();

// WPAD_ButtonsDown tells us which buttons were pressed in this loop
// this is a "one shot" state which will not fire again until the button has been released
u32 pressed = WPAD_ButtonsDown(0);

// We return to the launcher application via exit
if ( pressed & WPAD_BUTTON_HOME ) exit(0);

// Wait for the next frame
VIDEO_WaitVSync();
}

return 0;
}

Hmmm not so easy? You probably don't understand most of this at the current stage, hence I advise you don't go straight to wii. It's much better learning on PC as well because it opens up a huge range of possibilities in programming and not as narrow as learning for one console. There are several examples in devkitPro that will compile as is with make file and what not, perhaps you should look at them if you want a taste but don't attempt to swallow it all at once. Also, you need to remember that basic (and advanced) programs are usually compiled to an executable file called an exe file, but with Wii, it usually exports to a .dol AND .elf file as the exe format isn't compatable (easily anyway) with the wii as it is.

Take this into account and decide what you want to do, but honestly I don't think you are going about it the right way, trying to compile programs they way you are for a platform it won't work on.
Sorry, only registered users may post in this forum.

Click here to login