Hey so I'm trying to write a backend for a game I might make and am running into some troubles which (to be honest is probably just me not understanding c++ very well) but nevertheless I have been stuck on it for a few days now with very minimal progress.
Basically I have written up a GameObject class like unity which has a texture, a model, a position, and an update function which i can then attach more scripts to.
However, I cannot to save my life figure out how to get the texture to map onto the object when its rendered on the screen. For example, here is the code relevant to loading the texture into the gameobject object:
And the code to render the object:
And here is what happens trying to run it in citra:
Which I have no clue what it means. Whats more is when I run it on actual hardware, the game doesn't lock up, it just puts a random colour, (or multiple colours at times) on the object which is not what I was wanting.
I have tried various incarnations of manually setting up the C3D_Tex struct myself which albiet stopped the 3ds from locking up, still didnt fix the problem. And have also tried malloc where I put linearAlloc except citra spams "unknown getpointer" which I'm assuming means malloc isnt working and returns a null pointer?
Would appreciate any feedback, even if its just to clean up my code because I am using this to learn c/c++.
Peace
Basically I have written up a GameObject class like unity which has a texture, a model, a position, and an update function which i can then attach more scripts to.
However, I cannot to save my life figure out how to get the texture to map onto the object when its rendered on the screen. For example, here is the code relevant to loading the texture into the gameobject object:
Code:
/*
* texture is a C3D_Tex object, and tex_bin is the u8* texture_bin pointer. I am using kitten_bin as per the example just for testing.
*/
C3D_TexInit(&texture, 64,64,GPU_RGBA8);
//This is essentially what C3D_TexUpload does except for some reason it throws a bunch of read/write errors in citra
texture.data = linearAlloc(texture.size);
memcpy(texture.data, tex_bin, texture.size);
//
C3D_TexSetFilter(&texture, GPU_LINEAR, GPU_NEAREST);
And the code to render the object:
Code:
C3D_TexBind(0, &(texture));
C3D_BufInfo* bufInfo = C3D_GetBufInfo();
BufInfo_Init(bufInfo);
BufInfo_Add(bufInfo, vbo_data, sizeof(vertex), 3, 0x210);
C3D_DrawArrays(GPU_TRIANGLES, 0, model.size());
And here is what happens trying to run it in citra:
Which I have no clue what it means. Whats more is when I run it on actual hardware, the game doesn't lock up, it just puts a random colour, (or multiple colours at times) on the object which is not what I was wanting.
I have tried various incarnations of manually setting up the C3D_Tex struct myself which albiet stopped the 3ds from locking up, still didnt fix the problem. And have also tried malloc where I put linearAlloc except citra spams "unknown getpointer" which I'm assuming means malloc isnt working and returns a null pointer?
Would appreciate any feedback, even if its just to clean up my code because I am using this to learn c/c++.
Peace