Homebrew Homebrew Development

delete12345

Well-Known Member
Member
Joined
Feb 27, 2010
Messages
695
Trophies
1
Age
32
Location
Taipei, Taiwan
XP
1,276
Country
United States
Can someone check on this test sample Citro3D code, and tell me what I am missing to render a cube into the world?

http://hastebin.com/abawikalom.avrasm

The issue is I am not seeing any cube flying around in the world when it is loaded. I felt like I'm missing something crucial, but I don't know what I am missing. The code is rewritten from scratch after comparing it with the ones in 3ds_examples.
 

Spaqin

Well-Known Member
Member
Joined
Feb 17, 2015
Messages
123
Trophies
0
Age
29
XP
199
Country
Poland
I kinda wanna get into Citro3D and start working on a 2.5D multiplayer vehicle-based soccer game, but I had just a little experience with OpenGL. Any tutorials or documentation for that, or am I supposed to read the example code until I understand it?
 
  • Like
Reactions: YugamiSekai

delete12345

Well-Known Member
Member
Joined
Feb 27, 2010
Messages
695
Trophies
1
Age
32
Location
Taipei, Taiwan
XP
1,276
Country
United States
I kinda wanna get into Citro3D and start working on a 2.5D multiplayer vehicle-based soccer game, but I had just a little experience with OpenGL. Any tutorials or documentation for that, or am I supposed to read the example code until I understand it?

You will have to look up the 3ds/gpu/gputest example in devkitPro installation directory. That's how I did mine. It's been 2 months now, and I've haven't even progressed up 2% of my Citro3D tutorials.
 
  • Like
Reactions: Spaqin

Spaqin

Well-Known Member
Member
Joined
Feb 17, 2015
Messages
123
Trophies
0
Age
29
XP
199
Country
Poland
You will have to look up the 3ds/gpu/gputest example in devkitPro installation directory. That's how I did mine. It's been 2 months now, and I've haven't even progressed up 2% of my Citro3D tutorials.

Wow. That seems rather counterproductive. Incredible that there's not even a simple online documentation with functions and descriptions like for libctru or sf2d. I guess it's more suited for people already experienced with OpenGL in some way...
 

delete12345

Well-Known Member
Member
Joined
Feb 27, 2010
Messages
695
Trophies
1
Age
32
Location
Taipei, Taiwan
XP
1,276
Country
United States
Wow. That seems rather counterproductive. Incredible that there's not even a simple online documentation with functions and descriptions like for libctru or sf2d. I guess it's more suited for people already experienced with OpenGL in some way...
You can also try my repository here:

https://github.com/tommai78101/homebrew

It's sort of a simplified Citro3D tutorial. Read the wiki!
 

delete12345

Well-Known Member
Member
Joined
Feb 27, 2010
Messages
695
Trophies
1
Age
32
Location
Taipei, Taiwan
XP
1,276
Country
United States
Wow. That seems rather counterproductive. Incredible that there's not even a simple online documentation with functions and descriptions like for libctru or sf2d. I guess it's more suited for people already experienced with OpenGL in some way...

Also, after re-reading your post about this, Citro3D is a Work-In-Progress 3D graphics API library. Me (volunteer), and other contributors (project maintainers and developers), are still actively adding new APIs. Therefore, there's no particular documentation made as a tutorial from the contributors, because everything is changing. Even the API are bound to break stuffs very easily.
 
  • Like
Reactions: Spaqin

YugamiSekai

Mr. Picross
Member
Joined
Dec 24, 2014
Messages
2,015
Trophies
1
Age
21
XP
2,275
Country
United States
I'm trying to implement MiniMP3 with libctru's DSP functions. If I specified a MP3, where would it go and how would I play it? This is what I have so far:

Code:
/* MiniMP3 and LibCTRU streaming example
*  Author: Kaleb Provost (kprovost7314)
*  Desc: A PoC that plays MP3 Files
*/
#include <3ds.h>
#include <stdio.h>
#include "minimp3.h"
#include "libc.h"

#include "Bokuboku_mp3.h"

#define SAMPLERATE 48000
#define SAMPLESPERBUFF (SAMPLERATE / 30)

int bytes_left;
signed short sample_buf[MP3_MAX_SAMPLES_PER_FRAME];
int frame_size;
static unsigned char *stream_pos = 0;


int main(int argc, char **argv)
{
	//Initialize gfx (note: not needed if you're using SF2Dlib)
	gfxInitDefault();
	
	consoleInit(GFX_TOP, NULL);
	printf("Streaming A MP3 file with Minimp3 and LibCTRU\n");
	
	// Initialize NDSP for audio
	ndspInit();
	
	
	/* Set the NDSP for Stereo playback.			  *
	*  You can switch from Stereo to Mono or Surrond  *
	*  (see libctru's ndsp.h)						  */
	//You can (possibly) use minimp3's channel set
	ndspSetOutputMode(NDSP_OUTPUT_STEREO);
	
	ndspChnSetFormat(0, NDSP_FORMAT_STEREO_PCM16);
	
	//Set the sample rate to the defined one above
	//Is possible with MiniMP3 instead of LibCTRU
	ndspChnSetRate(0, SAMPLERATE);
	
	
	// Name the ndspWaveBuf struct
	ndspWaveBuf waveBuf;
	
	
	// Name the info struct from minimp3.h
	mp3_info_t info;
	
	info.sample_rate = 48000;
	
	waveBuf.sequence_id = "Bokuboku.mp3";
	
	mp3_decoder_t mp3;
	
	bytes_left -= 100;
	
	// Minimp3 code
	    // check if the result is valid
		// If not:
    if (!stream_pos) {
        printf("Error: cannot open Boku-Boku.Infinite!\n");
        return 1;
		// If it is:
    } else {
		ndspChnIsPlaying(0);
		ndspChnWaveBufAdd(0, &waveBuf);
        printf("Now Playing: Boku-Boku.Infinite\n");
    }
	
	
	mp3 = mp3_create();
	mp3_decode(mp3, stream_pos, bytes_left, sample_buf, &info);
	if (!frame_size) {
        printf("\nError: not a valid MP3 audio file!\n");
        return 1;
    }
	
	// Main loop
	while (aptMainLoop())
	{
		//Scan all the inputs. This should be done once for each frame
		hidScanInput();
		
		//hidKeysDown returns information about which buttons have been just pressed (and they weren't in the previous frame)
		//hidKeysHeld returns information about which buttons are currently pressed (regardless if they were pressed or not pressed in the previous frame)
		//hidKeysUp returns information about which buttons are not pressed but were pressed in the previous frame
		u32 kDown = hidKeysDown();
		
		
		
		if (kDown & KEY_START) break; // break in order to return to hbmenu
		// YOU WANT TO LEAVE ME?????
		/*
		I'11 FL00D thE // SYSTEM f0r3v3r
		JK, Y0u'11 c0M3 b4ck
		1 kn0w y0u wi11
		*/
		
		
		// Flush and swap framebuffers, this is needed for rendering these will not be needed when using SF2D lib
		gfxFlushBuffers();
		gfxSwapBuffers();
		
		//Wait for VBlank, this is needed for rendering these will not be needed when using SF2D lib
		gspWaitForVBlank();
	}
	// Close the MP3 file
	mp3_done(mp3);
	ndspExit();
	gfxExit();
	return 0;
}
 

RocketRobz

Stylish TWiLight Hero
Developer
Joined
Oct 1, 2010
Messages
16,575
Trophies
3
Age
24
XP
20,948
Country
United States
Right now, I'm making a forwarder template for the DSTWO.
I was able to set the ROM path for autoboot, but how do load a .nds file from SD card?
The line
Code:
runNdsFile ("dsisd:/_dstwofwd/dstwofwd.nds",0,0);
isn't working.

EDIT: Got it working!
 
Last edited by RocketRobz,
D

Deleted User

Guest
Figured I'd post this here, as I can't seem to figure this out. I've been trying to code a themable comic reader in C++, and have been using sf2dlib and sfillib to load images from the SD Card to display to the screen. Images load fine... most of the time. For some reason, I'm having trouble loading the comic pages themselves; they end up distorted in one way or another.

For example:
scr_18_MERGED.png

This is supposed to be the first page of a manga, but is loaded up all distorted. What confuses me is that the UI Buttons load just fine, and are loaded after loading the manga page.

Here's another example:
scr_21_MERGED.png

In this case, I hard-coded my program to load a specific image from the SD Card. The image loads fine, for the most part, but remnants of images that were previously on-screen remain to the side of the image. This happens even when I load said images out of memory.

Here is how I implement the image loading in my code:
Code:
             if (strcmp(mlisting->extensions[counter], ".png") == 0 || strcmp(mlisting->extensions[counter],  ".PNG") == 0) {
                 image = sfil_load_PNG_file(full_path.c_str(), SF2D_PLACE_RAM);
             } else if (strcmp(mlisting->extensions[counter], ".jpg") == 0 || strcmp(mlisting->extensions[counter], ".JPG") == 0) {
                 image = sfil_load_JPEG_file(full_path.c_str(), SF2D_PLACE_RAM);
             } else if (strcmp(mlisting->extensions[counter], ".bmp") == 0 || strcmp(mlisting->extensions[counter], ".BMP") == 0) {
                 image = sfil_load_BMP_file(full_path.c_str(), SF2D_PLACE_RAM);
             } else {
                 printf("Error!\n");
                 return;
             }

             cb = app::run_img(image, theme, vm, false);

Is there something I'm neglecting to implement? Is there anything I need to be "flushing" in and out of memory in order to get this to work? Or is it just an issue with sfillib that needs to be fixed?

UPDATE: I tried loading the image into memory as a buffer, then called sfil_load_JPEG_buffer() to convert it into an sf2d_texture, but the result was exactly the same! Is there something I'm missing, or is it the library working up? Maybe the library just doesn't like big images?

UPDATE 2: Tried resizing the images and it worked! ...kinda. It does seem that sfillib doesn't like big images. Maybe I should bring this up on GitHub?
 
Last edited by ,
  • Like
Reactions: SLiV3R
D

Deleted User

Guest
How to I edit the title ID of the app I made? I used a source code as a base to learn how to use LPP but it seems that I have the same title ID as the base so it is overwriting our apps with each other.

EDiT: I got it fixed. For those of you who have the same issue. You can change the title ID error with LPP by editing the cia_workaround.rsf

You need to change the Title, product code, and unique ID
 
Last edited by ,
D

Deleted User

Guest
Is there a way for me to pack my images in the cia of my LPP app? Or do I need to keep them separate?
 

nop90

Well-Known Member
Member
Joined
Jan 11, 2014
Messages
1,556
Trophies
0
Location
Rome
XP
3,036
Country
Italy
You can use romfs. There are many example on the forum. You need to use some commands in the makefile to build the romfs from a folder in your project. You also need to configure the cia build.

And remember that filemanes on the romfs are case sensitive.
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
    Xdqwerty @ Xdqwerty: good night