Homebrew [Release] Caelina - OpenGL Driver

machinamentum

Well-Known Member
OP
Member
Joined
Jul 5, 2015
Messages
163
Trophies
0
XP
549
Country
United States
Thanks a lot! i now successfully compiled, but it now hangs when I try to run it, top screen black, bottom one is red. I guess I am just extremely unlucky (or stupid) person :blink:...
If you're using ninjhax2/tubehax/ironhax/oot3dhax/etc, there's a known bug causing Caelina to hang during start up. If you call consoleInit() before setting up Caelina, it will run correctly without hanging. It's very odd and due to my current interests in other projects, I don't plan to fix it at this time.
 

neobrain

-
Member
Joined
Apr 25, 2014
Messages
306
Trophies
0
XP
730
Country
Is there prebuilt win binary for caelina?
Because I am trying to get it work on ubuntu for like an hour. I had to install nihstro for caelina, but i cant install it w/o boost, but even though I installed boost (ran bootstrap.sh and then b2), it seems it (nihstro) cant find it, so it making only dissassembler, which is not enough for caelina.
Next time, just install the boost-devel package using your package manager... :P
 

slu

Member
Newcomer
Joined
Sep 14, 2015
Messages
7
Trophies
0
Age
32
XP
52
Country
If you're using ninjhax2/tubehax/ironhax/oot3dhax/etc, there's a known bug causing Caelina to hang during start up. If you call consoleInit() before setting up Caelina, it will run correctly without hanging. It's very odd and due to my current interests in other projects, I don't plan to fix it at this time.
Thanks a lot. Sorry for spamming; everything now runs smoothly.
Btw, do you plan to use the 3d since 3ds have the technology?
 

machinamentum

Well-Known Member
OP
Member
Joined
Jul 5, 2015
Messages
163
Trophies
0
XP
549
Country
United States
Thanks a lot. Sorry for spamming; everything now runs smoothly.
Btw, do you plan to use the 3d since 3ds have the technology?
You can already use 3D using this. It's still a little complicated because you need to draw the scene, call gfxFlush with the left framebuffer then draw the scene again at a slight angle/displacement and call gfxFlush with the right framebuffer. Don't forget to call gfxSet3D!

Also I've uploaded a new prebuilt that seems to not hang on ninjhax2 when building the nehe lessons and is updated for the latest ctrulib. There still doesn't seem to be full compatibility with ninjhax2 though.
 
  • Like
Reactions: slu

slu

Member
Newcomer
Joined
Sep 14, 2015
Messages
7
Trophies
0
Age
32
XP
52
Country
So i got to turn on the 3d on, but i don't know how to set the angle and how big it should be.
now my code is
Code:
        DrawGLScene(0);

        gfxFlush(gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL));

        DrawGLScene(1);

        gfxFlush(gfxGetFramebuffer(GFX_TOP, GFX_RIGHT, NULL, NULL));

        gfxSet3D(1);

while DrawGlScene takes bool for left/ right side, there I should have something like glRotatef(5, 0.0f, 0.0f, 0.0f); for one of the sides, right? How big exactly the angle should be?
Sorry that I keep asking. It would be nice to have some caelina wiki for dummies. (Perhaps I'll write one after I'll understand everything :lol:)
 

machinamentum

Well-Known Member
OP
Member
Joined
Jul 5, 2015
Messages
163
Trophies
0
XP
549
Country
United States
So i got to turn on the 3d on, but i don't know how to set the angle and how big it should be.
now my code is

while DrawGlScene takes bool for left/ right side, there I should have something like glRotatef(5, 0.0f, 0.0f, 0.0f); for one of the sides, right? How big exactly the angle should be?
Sorry that I keep asking. It would be nice to have some caelina wiki for dummies. (Perhaps I'll write one after I'll understand everything :lol:)
Choosing the displacement is sort of complicated and it seems everyone has a different approach based on testing. I've attached an example project that uses most of Caelina's features, including 3D using the 3DS' slider. This one uses a translation as a displacement instead of a rotation.

EDIT: Playing around with ninjhax2 some more, it seems like there's some global initialization somewhere that seems to cause the issues on these entry points, which is weird because I believe none of the code uses global initializers. When compiling the lib with options to remove dead code (which supposedly disables global initialization if i read correctly), it doesn't cause the usual issues such as breaking netloader.
 

Attachments

  • example.zip
    28.1 KB · Views: 148
Last edited by machinamentum,

piratesephiroth

I wish I could read
Member
Joined
Sep 5, 2013
Messages
3,453
Trophies
2
Age
103
XP
3,233
Country
Brazil

machinamentum

Well-Known Member
OP
Member
Joined
Jul 5, 2015
Messages
163
Trophies
0
XP
549
Country
United States
Small progress update: a new feature of this project is disabling error checking. Although relatively useful, for projects that are entirely free of errors, this more or less just wastes CPU cycles and fills icache lines with code that never runs. Error checking can be disabled for source builds only, by adding "-DDISABLE_ERRORS" to CFLAGS
Code:
CFLAGS="-DDISABLE_ERRORS" make
make install

I'll likely add this same mechanism for display lists as well soon.

EDIT: DISABLE_LISTS will disable the overhead incurred by display list building/checking/etc...
Also, it seems that the GPU actually stores some amount of GL state across command buffers, so I've started a new branch that takes advantage of this by using less memory and managing less state on the client-side. This of course will be available as a source build only and will not be uploaded as pre-builts.
 
Last edited by machinamentum,

AtlasFontaine

Well-Known Member
Member
Joined
Jul 18, 2015
Messages
1,095
Trophies
0
Age
26
Location
Venezuela-Zulia.
XP
865
Country
Venezuela
Small progress update: a new feature of this project is disabling error checking. Although relatively useful, for projects that are entirely free of errors, this more or less just wastes CPU cycles and fills icache lines with code that never runs. Error checking can be disabled for source builds only, by adding "-DDISABLE_ERRORS" to CFLAGS
Code:
CFLAGS="-DDISABLE_ERRORS" make
make install

I'll likely add this same mechanism for display lists as well soon.

EDIT: DISABLE_LISTS will disable the overhead incurred by display list building/checking/etc...
Also, it seems that the GPU actually stores some amount of GL state across command buffers, so I've started a new branch that takes advantage of this by using less memory and managing less state on the client-side. This of course will be available as a source build only and will not be uploaded as pre-builts.
Man, you and @DiscostewSM are the true MVP in the gpu area!
 

machinamentum

Well-Known Member
OP
Member
Joined
Jul 5, 2015
Messages
163
Trophies
0
XP
549
Country
United States
Small project update: a long time missing feature was using a single context to draw to both displays. This new update changes gfxFlush to use the output display's width and height so a project could draw to both displays using something along the following:
Code:
DrawGLScene();
gfxFlush(gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL), 240, 400);
DrawGLScene2();
gfxFlush(gfxGetFramebuffer(GFX_BOTTOM, GFX_LEFT, NULL, NULL), 240, 320);
Screen Shot 2015-11-22 at 8.25.45 PM.png
Get it here
EDIT: it seems that it currently doesn't scale the image to the framebuffer. The documentation in ctrulib is somewhat ambiguous on how anti-aliasing and scaling works. I'm looking into it.
EDIT2: this can likely just mitigated by just using glViewport to the size of the framebuffer you need to flush to
 
Last edited by machinamentum,
  • Like
Reactions: kiwiis

machinamentum

Well-Known Member
OP
Member
Joined
Jul 5, 2015
Messages
163
Trophies
0
XP
549
Country
United States
v0.5 now available.
Change log:
gfxFlush now accepts GX_TRANSFER_FORMAT as an argument.
Added gfxResize (resizes the backbuffer the GL will render to).
gfxMakeCurrent now returns the previously bound context reference.
Adds GL_BGRA support to glTexImage2D/glTexSubImage2D.
Driver code cleanup.

This update brings more stability, and features, when using multiple contexts. A context can be used to render an image then flushed out to a buffer and submitted to a texture in the same context or another context. This essentially can work in place of render-to-texture until render targets are actually implemented. Note that GX_TRANSFER_FMT_RGBA8 is equivalent to GL_BGRA when submitting as a texture.
Attached is an example of these new features working.
Screen Shot 2015-11-25 at 8.32.17 PM.png
EDIT: NeHe lesson06 example now available (uses stb_image, included in the repo)
Screen Shot 2015-11-26 at 9.54.18 AM.png
 
Last edited by machinamentum,
  • Like
Reactions: AtlasFontaine

machinamentum

Well-Known Member
OP
Member
Joined
Jul 5, 2015
Messages
163
Trophies
0
XP
549
Country
United States
v0.6 now available. This release marks the beginning of GL ES support.
Change log:
Caelina is now split among 3 libraries.
  • libcaelina.a - context creation and management
  • libGL.a - desktop GL API
  • libGLESv1.a - GL ES 1 API
Apps must link against libcaelina and one of the two GL libraries.
glFrustumf is now removed from libGL, glFrustum has been added in its place.
A new example is now available demonstrating the GL ES library.
GL ES support is still very new and currently doesn't support the fixed-function vertex attributes (glTexCoordPointer, glNormalPointer, glColorPointer, etc) which makes it very limited.
 
  • Like
Reactions: hippy dave

TheCruel

Developer
Banned
Joined
Dec 6, 2013
Messages
1,350
Trophies
2
XP
3,131
Country
United States
I could never get gl*Pointer functions implemented properly because I couldn't figure out how to get the stride set to anything besides the size of the vertex data (and feeding it tightly packed interleaved vertex data).
 
Last edited by TheCruel,

elhobbs

Well-Known Member
Member
Joined
Jul 28, 2008
Messages
1,044
Trophies
1
XP
3,032
Country
United States
I could never get gl*Pointer functions implemented properly because I couldn't figure out how to get the stride set to anything besides the size of the vertex data (and feeding it tightly packed interleaved vertex data).
I ran into the same issue. Any gaps and things stop working. Separate buffers for each attribute work fine though.
 

machinamentum

Well-Known Member
OP
Member
Joined
Jul 5, 2015
Messages
163
Trophies
0
XP
549
Country
United States
I could never get gl*Pointer functions implemented properly because I couldn't figure out how to get the stride set to anything besides the size of the vertex data (and feeding it tightly packed interleaved vertex data).
If I understand correctly, you need to set the stride bits of GPUREG_ATTRIBUFFERi_CONFIG2. ctrulib's GPU_SetAttributeBuffers function is overkill in that it assumes a packed buffer, so it calculates that stride based on the number of components and the size of the attributes you specify (see gpu.c#L470). You'd probably want to use a masked write to overwrite just the stride bits after calling SetAttributeBuffers or just stop using SetAttributeBuffers all together and add the writes yourself.
 
Last edited by machinamentum,

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
    K3Nv2 @ K3Nv2: Well start walking towards them +1