Homebrew Homebrew Help! C++ question.

[GBATemp]~IceStorm

Banned!
OP
Banned
Joined
Oct 29, 2013
Messages
71
Trophies
0
Location
yo mama's house
XP
111
Country
United States
Hi.

I am new to DS Homebrew. I am planning on using C++ as the primary language for developing Homebrew. I also plan on using higher level aspects of C++ (such as the vtable for virtual methods). However, I am afraid that using high level concepts will cause an excess in overhead and ultimately a slowdown in the program. However, I have been told that the compiler you use can ultimately optimize away these high level constructs. Is this true?
 

elhobbs

Well-Known Member
Member
Joined
Jul 28, 2008
Messages
1,044
Trophies
1
XP
3,032
Country
United States
Hi.

I am new to DS Homebrew. I am planning on using C++ as the primary language for developing Homebrew. I also plan on using higher level aspects of C++ (such as the vtable for virtual methods). However, I am afraid that using high level concepts will cause an excess in overhead and ultimately a slowdown in the program. However, I have been told that the compiler you use can ultimately optimize away these high level constructs. Is this true?
This is fine. I think the only thing that does not work is possibly exceptions. For the rest c++ is fine. Worry about optimization when it is a problem. Then use analysis to determine where the problem is. Don't guess or worry about the rest.
 
  • Like
Reactions: Foxi4

Foxi4

Endless Trash
Global Moderator
Joined
Sep 13, 2009
Messages
30,825
Trophies
3
Location
Gaming Grotto
XP
29,841
Country
Poland
I wouldn't call C and C++ "high-level languages", at least not anymore. In the olden days any language that was more-or-less machine-independent (meaning "not Assembly for the particular platform") was considered "high level", but today "level" is put on large a spectrum, ranging from Assembly to interpreted languages. C and C++ are just one step above Assembly since they both provide low-level functionality, there's no need to worry, the DS is a modern platform with plenty of resources to spare. C and C++ programs are compiled directly into native binaries for the platform, the overhead is minimal, they're nothing like Java or C# programs that run on a virtual machine which in turn works on "an abstraction of an abstraction of an abstraction". Chances are that your C/C++ program will require no low-level optimization whatsoever, and if it will, then it'll be minimal. Go ahead and use C/C++, you don't have to code each and every mundane task in Assembly, somebody's done it for you already and chances are that your implementation won't be more efficient.

Anywho, seeing that you're just starting, you might want to give my little guide a read - it'll familiarize you with some basic platform-specific concepts:

https://gbatemp.net/threads/ds-programming-for-newbies.322106/

For further resources, particularly low-level information, check out GBAtek - it'll help you find all the relevant registers. That, and be sure to check out libnds documentation.
 
  • Like
Reactions: TheToaster

TheToaster

Kishore
Member
Joined
Aug 11, 2015
Messages
467
Trophies
0
Location
USA
XP
979
Country
United States
Thank you,@Foxi4

But your tutorial doesn't talk about 3D game creation! Does 3D game creation for the NDS use the same libraries as the ones in your tutorial? If so, what libraries specifically.
 

Foxi4

Endless Trash
Global Moderator
Joined
Sep 13, 2009
Messages
30,825
Trophies
3
Location
Gaming Grotto
XP
29,841
Country
Poland
Thank you,@Foxi4

But your tutorial doesn't talk about 3D game creation! Does 3D game creation for the NDS use the same libraries as the ones in your tutorial? If so, what libraries specifically.
If you want to use 3D, I suggest using barebones libnds for efficiency, you'll find relevant code snippets in the Devkit Pro directory under Examples. As far as 3D on the DS is concerned, it's handled by VideoGL which is a clone of OpenGL 1.x, it should be familiar to you if you've ever coded anything using OpenGL. Keep in mind that the DS has very little VRAM (a little over 700kb IIRC) and RAM (4MB, including your code), so don't go nuts with complexity. I've been meaning to write a chapter about this, but in the advent of the 3DS it seemed pointless. Honestly, I suggest a 2D project for starters just to get the hang of platform-specific quirks, you can deal with 3D once you're comfortable with the DS.

Here's a link to VideoGL docs: http://libnds.devkitpro.org/videoGL_8h.html
 
  • Like
Reactions: TheToaster

TheToaster

Kishore
Member
Joined
Aug 11, 2015
Messages
467
Trophies
0
Location
USA
XP
979
Country
United States
If you want to use 3D, I suggest using barebones libnds for efficiency, you'll find relevant code snippets in the Devkit Pro directory under Examples. As far as 3D on the DS is concerned, it's handled by VideoGL which is a clone of OpenGL 1.x, it should be familiar to you if you've ever coded anything using OpenGL. Keep in mind that the DS has very little VRAM (a little over 700kb IIRC) and RAM (4MB, including your code), so don't go nuts with complexity. I've been meaning to write a chapter about this, but in the advent of the 3DS it seemed pointless. Honestly, I suggest a 2D project for starters just to get the hang of platform-specific quirks, you can deal with 3D once you're comfortable with the DS.

Here's a link to VideoGL docs: http://libnds.devkitpro.org/videoGL_8h.html

Thank you. I have done many OpenGL projects before so I think this would be good
 

Foxi4

Endless Trash
Global Moderator
Joined
Sep 13, 2009
Messages
30,825
Trophies
3
Location
Gaming Grotto
XP
29,841
Country
Poland
Thank you. I have done many OpenGL projects before so I think this would be good
Basic functionality is exactly the same, but there are some custom functions for setup, memory banks, screen modes, shading etc., so check the Examples folder for those. Good luck!

EDIT: Something to keep in mind - the DS is capable of rendering a maximum of 6144 vertices/2048 triangles per second - be modest with your models. Culling helps cut down the number of polygons on-screen, but don't rely on it too much. ;)

For texture creation use GRIT, it'll allow you to convert images into native DS bins with 8 or 16 bit colour depth. They should be formatted as multiples of 2 (32x32 for example) and preferably square to avoid issues. For models use NDS Mesh Converter and don't use any surface effects. :)
 
  • Like
Reactions: TheToaster

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    PotatoStatic @ PotatoStatic: Jesus. Someone really wants to give me speedy loans.