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
https://www.artistsworkshop.eu/meble-kuchenne-na-wymiar-warszawa-gdzie-zamowic/
Joined: Mon Jul 28, 2014 3:24 pm
Has thanked: 0
Been thanked: 0

KGL help

Post by Kannagi »

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: 5652
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Re: KGL help

Post by BlueCrab »

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
Has thanked: 0
Been thanked: 0

Re: KGL help

Post by Kannagi »

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: 5652
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Re: KGL help

Post by BlueCrab »

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
Has thanked: 0
Been thanked: 0

Re: KGL help

Post by Kannagi »

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: 5652
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Re: KGL help

Post by BlueCrab »

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
Has thanked: 0
Been thanked: 0

Re: KGL help

Post by Kannagi »

Ok , thank you ;)
User avatar
PH3NOM
DC Developer
DC Developer
Posts: 576
Joined: Fri Jun 18, 2010 9:29 pm
Has thanked: 0
Been thanked: 5 times

Re: KGL help

Post by PH3NOM »

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
Has thanked: 0
Been thanked: 0

Re: KGL help

Post by Kannagi »

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
Has thanked: 0
Been thanked: 0

Re: KGL help

Post by Jae686 »

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