KGL help

If you have any questions on programming, this is the place to ask them, whether you're a newbie or an experienced programmer. Discussion on programming in general is also welcome. We will help you with programming homework, but we will not do your work for you! Any porting requests must be made in Developmental Ideas.
Post Reply
Kannagi
DCEmu Fast Newbie
DCEmu Fast Newbie
Posts: 19
Joined: Mon Jul 28, 2014 3:24 pm

KGL help

Post by Kannagi » Mon Jul 28, 2014 4:00 pm

J'ai eu so much probleme with kgl , the first a problem is clipping.
I modified gluPerspective ( zNar, zFear) but it does not change the clipping.
For 2D, PC, GL_Ortho + gl_disable depht,for draw 2D example:

Code: Select all

gl_draw background
gl_draw text
But Kgl, the background will display first and will not see the text (when it should be in the background).
strange test , I had a very large 3D model, model 3D bug, I scale and normally appears. (I have not changed code).
I think using the PVR for 3D? I guess it is reliable (but I'd like confirmation).
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5357
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Contact:

Re: KGL help

Post by BlueCrab » Mon Jul 28, 2014 5:32 pm

You should probably give both the background and the text a Z coordinate and make sure that the text would be closer to the viewer than the background if you want the text to show up.

Basically, because of the way the PVR works (and how KOS sets it up), you're probably losing the text to the automatic depth-sorting that happens on translucent polygons.
Kannagi
DCEmu Fast Newbie
DCEmu Fast Newbie
Posts: 19
Joined: Mon Jul 28, 2014 3:24 pm

Re: KGL help

Post by Kannagi » Tue Jul 29, 2014 2:10 am

Yes I use now Z coordinate, I do not like this method, it forces me to use global variables to increment.
For 3d, I have always the problem of clipping, what solution ?

demo :
http://www.mediafire.com/download/urjdk ... c_demo.elf
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5357
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Contact:

Re: KGL help

Post by BlueCrab » Tue Jul 29, 2014 1:00 pm

For clipping, you'll either have to devise your own clipping code or wait for PH3NOM to release his new KGL replacement library, which is being discussed in this thread.
Kannagi
DCEmu Fast Newbie
DCEmu Fast Newbie
Posts: 19
Joined: Mon Jul 28, 2014 3:24 pm

Re: KGL help

Post by Kannagi » Wed Jul 30, 2014 4:53 am

I see, I'll work on the clipping.
I have another question for transparency.
I did this:

Code: Select all

glEnable(GL_BLEND);
 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
and :

Code: Select all

png_load_texture("/rd/mytexture.png", &texture_pvr, GL_ARGB4444_TWID,&w, &h);
	
	glGenTextures(1, &id);
	glBindTexture(GL_TEXTURE_2D, id);
	glKosTex2D(GL_ARGB4444_TWID, w, h, texture_pvr);
	
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_FILTER, GL_FILTER_NONE);
But it does not work.
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5357
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Contact:

Re: KGL help

Post by BlueCrab » Wed Jul 30, 2014 8:47 am

I'm guessing by "it doesn't work" you mean that your texture isn't coming out partially translucent? That's because with the KGL that's provided with KOS, you have to do a bit of extra work that's related to the way the PVR itself works (KGL is just a convenient wrapper around the lower-level PVR API).

Basically, you have to make sure the polygons you submit that you want to have alpha blending done are submitted to the PVR as translucent polygons. Assuming that you initialized things to their defaults, KGL will start out assuming everything you give it is an opaque polygon and will submit it to the PVR in that manner. You'll need to switch to the translucent polygon list before submitting any translucent polygons. I suggest looking at the kgl/basic/gl/gltest.c example that's included with KOS to see what I mean by that. Specifically, pay attention to what it does when the variable "trans" has 1 in its first bit.
Kannagi
DCEmu Fast Newbie
DCEmu Fast Newbie
Posts: 19
Joined: Mon Jul 28, 2014 3:24 pm

Re: KGL help

Post by Kannagi » Wed Jul 30, 2014 9:47 am

Ok , thank you ;)
User avatar
PH3NOM
DC Developer
DC Developer
Posts: 574
Joined: Fri Jun 18, 2010 9:29 pm

Re: KGL help

Post by PH3NOM » Wed Jul 30, 2014 10:56 pm

Yeah, those were some of the problems with the existing API that bothered me enough to commit to writing a better implementation of the OpenGL API for Dreamcast KOS myself.

With the API I am working on, glEnable(GL_BLEND) will effectively switch lists and allow you to submit blended polygons as you would expect with the standard Open GL API.

For Z Clipping, you will need to call glEnable(GL_KOS_NEARZ_CLIPPING) to enable vertex clipping. Are you already doing that? From your demo, it does not appear so...

At any rate, my api is basically done ( right now I am finishing glDrawArrays() to round off the feature set ).
Kannagi
DCEmu Fast Newbie
DCEmu Fast Newbie
Posts: 19
Joined: Mon Jul 28, 2014 3:24 pm

Re: KGL help

Post by Kannagi » Thu Jul 31, 2014 3:20 am

Your APi interested me, I work with the pvr but it will be a little long.
Thank you for glEnable(GL_KOS_NEARZ_CLIPPING).
Jae686
Insane DCEmu
Insane DCEmu
Posts: 112
Joined: Sat Sep 22, 2007 9:43 pm
Location: Braga - Portugal

Re: KGL help

Post by Jae686 » Thu Jul 31, 2014 12:38 pm

PH3NOM wrote:Yeah, those were some of the problems with the existing API that bothered me enough to commit to writing a better implementation of the OpenGL API for Dreamcast KOS myself.

With the API I am working on, glEnable(GL_BLEND) will effectively switch lists and allow you to submit blended polygons as you would expect with the standard Open GL API.

For Z Clipping, you will need to call glEnable(GL_KOS_NEARZ_CLIPPING) to enable vertex clipping. Are you already doing that? From your demo, it does not appear so...

At any rate, my api is basically done ( right now I am finishing glDrawArrays() to round off the feature set ).
I'm quite eager to work with your API PH3NOM.

:D
Post Reply