3D on dreamcast

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
dospro
Insane DCEmu
Insane DCEmu
Posts: 147
Joined: Thu Dec 30, 2004 7:12 pm
Contact:

3D on dreamcast

Post by dospro » Mon Sep 24, 2007 1:59 pm

Ok. Here is the question.

What is better for 3d programming on the dreamcasT?
SDL+Opengl(which i think uses pvr or kgl)
pure KGL
or
just pvr

The thing is that i already know opengl and i like it.
But i heard some years ago that sdl+opengl had some problems. How is the situation today?
I also heard recently that KGL was almost finished.
Is this true? are there any special extensions for the dreamcast?

If i have to learn pvr, is KOS source the best way to learn? or are there any better ways?
Check the BioGB emulator any help me get it much better!!
http://www.geocities.com/instructivus
User avatar
mankrip
DCEmu Ex-Mod
DCEmu Ex-Mod
Posts: 3696
Joined: Sun Nov 04, 2001 5:12 pm
Contact:

Re: 3D on dreamcast

Post by mankrip » Mon Sep 24, 2007 3:53 pm

Chui's KGL-x seems to be pretty advanced.
Ph'nglui mglw'nafh mankrip Hell's end wgah'nagl fhtagn.
==-=-=-=-=-=-=-=-=-=-==
Dev blog / Twitter / YouTube
Image
User avatar
showka
DCEmu Freak
DCEmu Freak
Posts: 95
Joined: Fri Nov 23, 2001 12:01 pm
Location: Border Town
Contact:

Re: 3D on dreamcast

Post by showka » Mon Sep 24, 2007 4:32 pm

I've got a question.

What I've tried was the OpenGL variant available with KOS - I think it was something like OpenKGL, but not KGL-x.

The big reason I abandoned my graphics work with it is that it was too hard to draw sprites. There was no mode (IIRC) that allowed you to turn off transformations and give vertices that were pre-transformed. Thus I went the PVR route and had to do a lot of super hard (at least for me) math for the perspective and stuff and it still doesn't work that well.

Can KGL-x can do this?

Bonus second question - was I just being an idiot and it's possible to mix KGL and the PVR apis?
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5335
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Contact:

Re: 3D on dreamcast

Post by BlueCrab » Mon Sep 24, 2007 6:04 pm

showka wrote:I've got a question.

What I've tried was the OpenGL variant available with KOS - I think it was something like OpenKGL, but not KGL-x.
It's just called KGL.
The big reason I abandoned my graphics work with it is that it was too hard to draw sprites. There was no mode (IIRC) that allowed you to turn off transformations and give vertices that were pre-transformed. Thus I went the PVR route and had to do a lot of super hard (at least for me) math for the perspective and stuff and it still doesn't work that well.

Can KGL-x can do this?
OpenGL spec itself doesn't define a way to "turn off" transformations entirely. There are several ways to do it with OpenGL (and thus, KGL). Here's some sample code to "turn off" transformations for all polygons (use this with some calls to glPushMatrix() and glPopMatrix() to do it for just a group):

Code: Select all

		glMatrixMode(GL_PROJECTION);
		glLoadIdentity();
		glOrtho(0.0f, m_width, m_height, 0.0f, 100.0f, -100.0f);

		glMatrixMode(GL_MODELVIEW);
		glLoadIdentity();
Bonus second question - was I just being an idiot and it's possible to mix KGL and the PVR apis?
Yes, this is entirely possible to do.
BB Hood
Insane DCEmu
Insane DCEmu
Posts: 166
Joined: Fri Mar 30, 2007 12:09 am

Re: 3D on dreamcast

Post by BB Hood » Mon Sep 24, 2007 6:17 pm

I have a question. Is Iris 3D better, worse, or as good as KGL?
User avatar
mankrip
DCEmu Ex-Mod
DCEmu Ex-Mod
Posts: 3696
Joined: Sun Nov 04, 2001 5:12 pm
Contact:

Re: 3D on dreamcast

Post by mankrip » Mon Sep 24, 2007 6:53 pm

BlueCrab wrote:It's just called KGL.
Fackue wrote:- libkglx by Heinrich Tillack
Chui wrote:I am completing KGLX and getting many progress.

For testing and debugging, i use Neverball. :D
Slight mistake, I wrote KGL-x instead of KGLX, but I wasn't the first one to write it this way.

[edit] I just noticed you're talking about the default API included in KOS.
Ph'nglui mglw'nafh mankrip Hell's end wgah'nagl fhtagn.
==-=-=-=-=-=-=-=-=-=-==
Dev blog / Twitter / YouTube
Image
dospro
Insane DCEmu
Insane DCEmu
Posts: 147
Joined: Thu Dec 30, 2004 7:12 pm
Contact:

Re: 3D on dreamcast

Post by dospro » Tue Sep 25, 2007 12:56 pm

Good.
So i must get chui's sdl and kgl code and compile it or does it already come with kos-post?

Any clues?
Check the BioGB emulator any help me get it much better!!
http://www.geocities.com/instructivus
dospro
Insane DCEmu
Insane DCEmu
Posts: 147
Joined: Thu Dec 30, 2004 7:12 pm
Contact:

Re: 3D on dreamcast

Post by dospro » Tue Sep 25, 2007 1:29 pm

Ok. i've tested this:

I have this code:

Code: Select all

#include<stdio.h>
#include<math.h>
#include<GL/gl.h>
#include<GL/glu.h>
#include<SDL.h>

int main(int argc, char *argv[])
{
	unsigned char *k;
	SDL_Init(SDL_INIT_VIDEO);
	SDL_SetVideoMode(640, 480, 32, SDL_OPENGL);
	
	glViewport(0, 0, 640, 480);
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	glOrtho(-100, 100, -100, 100, -100, 100);
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
	
	
	for(;;)
	{
		SDL_PumpEvents();
		k=SDL_GetKeyState(NULL);
		
		if(k[SDLK_ESCAPE])
			break;
				
		glClear(GL_COLOR_BUFFER_BIT);
	
		glBegin(GL_TRIANGLES);
	
		glColor3f(1.0, 1.0, 0.0);
		glVertex2f(0.0f, 25.0f);
		glColor3f(0.0, 1.0, 1.0);
		glVertex2f(25.0f, -25.0f);
		glColor3f(1.0, 0.0, 1.0);
		glVertex2f(-25.0f, -25.0f);
		
		glEnd();
		glFlush();
		SDL_GL_SwapBuffers();
	}
	
	printf("%s\n", glGetString(GL_VENDOR));
	printf("%s\n", glGetString(GL_RENDERER));	
	printf("%s\n", glGetString(GL_VERSION));	
	//printf("%s\n", glGetString(GL_SHADING_LANGUAGE_VERSION));	
	SDL_Quit();
	return 0;
}
it compiled witth:
kos-cc opengl.c -lgl -lSDL -o dcogl
And when i run it on the dreamcast, it doesn't show anything, while on my computer it does show a triangle.
Also, well... the ouput of the glGetString are:
Vendor: Kryptic Allusion
Renderer: KallistiOS
Version: 1.1

Is this the opengl version?
Isn't there a newer one? or am i doing sometihng wrong???
Check the BioGB emulator any help me get it much better!!
http://www.geocities.com/instructivus
Phantom
DC Developer
DC Developer
Posts: 1753
Joined: Thu Jan 16, 2003 4:01 am
Location: The Netherlands
Contact:

Re: 3D on dreamcast

Post by Phantom » Thu Sep 27, 2007 1:35 pm

In DreamChess we use SDL from KOS, with bero's version of KGL. We also tried KGL-X (not the Chui version), but we had problems with it, mainly in terms of OpenGL compatibility. Also, the GL_NT primitives didn't work for me.

In the end we added our own GL_NT primitive to bero GL in order to do reliable 2D overlays (On DC, glOrtho doesn't work right in many situations).

The libraries used in DreamChess can be found here if you're interested: http://prdownload.berlios.de/dreamchess ... 0.7.tar.gz
"Nothing works" - Catweazle
dospro
Insane DCEmu
Insane DCEmu
Posts: 147
Joined: Thu Dec 30, 2004 7:12 pm
Contact:

Re: 3D on dreamcast

Post by dospro » Sat Sep 29, 2007 12:02 am

Ok. I'm getting confused. How many opengls are for dreamcast? and which is the best? and how do i use it?
Check the BioGB emulator any help me get it much better!!
http://www.geocities.com/instructivus
Phantom
DC Developer
DC Developer
Posts: 1753
Joined: Thu Jan 16, 2003 4:01 am
Location: The Netherlands
Contact:

Re: 3D on dreamcast

Post by Phantom » Sat Sep 29, 2007 3:58 am

dospro wrote:Ok. I'm getting confused. How many opengls are for dreamcast? and which is the best? and how do i use it?
When we were working on the DC port of DreamChess, we found bero GL to be the best, but that was well over a year ago. I haven't tried Chui's version.

Anyway, I ran your example with the SDL and bero GL we use in DreamChess and it works. I only had to swap -lgl and -lSDL on the command line. The libs can be found in the archive I mentioned in my previous post.
"Nothing works" - Catweazle
BB Hood
Insane DCEmu
Insane DCEmu
Posts: 166
Joined: Fri Mar 30, 2007 12:09 am

Re: 3D on dreamcast

Post by BB Hood » Fri Nov 02, 2007 2:45 pm

Heinrich Tillack was also working on Holly 3D which is Iris3D V2(with more than 90% percent of the code changed). It was supposed to come out some time ago(atleast from what I have read). On his website it says its 97% and it is used in his game DCASTLE. Anybody know if Holly 3D is ever gonna be released?

http://a128.atspace.com/dcastle.htm
http://a128.atspace.com/holly3d/index.html
Strapping Scherzo
DC Developer
DC Developer
Posts: 2285
Joined: Fri Feb 21, 2003 7:37 am
Location: Chicago, IL
Contact:

Re: 3D on dreamcast

Post by Strapping Scherzo » Fri Nov 02, 2007 3:04 pm

I used PVR directly for all in NesterDC SE, like the UI. I kind of miss coding on the side. I think it would be fun to try to get a JVM working on DC. Has anyone ever done this? I don't care about any UI stuff like AWT or Swing though. Just the ability to run Java byte code on the DC.
Image
User avatar
Christuserloeser
Moderator
Moderator
Posts: 5936
Joined: Thu Aug 28, 2003 12:16 am
Location: DCEvolution.net
Contact:

Re: 3D on dreamcast

Post by Christuserloeser » Fri Nov 02, 2007 6:50 pm

Just in case there isn't enough confusion about different OpenGL / KGL versions in this thread:

Heinrich Tillack linked me to this version of KGLX not too long ago:
http://www.freewebtown.com/festival2005/kglx0.41.rar

- what is this based on and how does it compare to other KGL versions like bero's or chui's ?

I also started a stub about OpenGL / KGLX ports in DCS' Wiki:
http://www.dreamcast-scene.com/index.php/Main/KGL-X

- maybe someone with more knowledge than me (should be quite a few around here ^ ^) can improve/correct this article ?

BB Hood wrote:Heinrich Tillack was also working on Holly 3D which is Iris3D V2(with more than 90% percent of the code changed). It was supposed to come out some time ago(atleast from what I have read). On his website it says its 97% and it is used in his game DCASTLE. Anybody know if Holly 3D is ever gonna be released?
When I asked him about KGLX, he mentioned that he isn't actively working on anything Dreamcast right now (got cought by a nasty Nintendo DS fever) but hasn't given up yet. He also mentioned that he plans to release the source for Holly soon but that's been in July. Maybe another email will speed things up ? ;)

tillack - at - gmx - dot - net
Insane homebrew collector.
BB Hood
Insane DCEmu
Insane DCEmu
Posts: 166
Joined: Fri Mar 30, 2007 12:09 am

Re: 3D on dreamcast

Post by BB Hood » Fri Nov 02, 2007 7:46 pm

Thanks for the reply. I cant wait till the engine comes out. He showed some pics of it in action(PC) and they looked real nice. You can email him about it if you want to. I dont want to bug him to release something if he is busy with other things.
dospro
Insane DCEmu
Insane DCEmu
Posts: 147
Joined: Thu Dec 30, 2004 7:12 pm
Contact:

Re: 3D on dreamcast

Post by dospro » Sun Nov 04, 2007 4:00 pm

One more question.
I watched the KGL sample programs that comes with kos.
More specifically, the nehe samples.
My doubt is that there is some PVR code there together with PVR.
Can someone explain this? What's that for?

Code: Select all

pvr_init_params_t params = {
        /* Enable opaque and translucent polygons with size 16 */
        { PVR_BINSIZE_16, PVR_BINSIZE_0, PVR_BINSIZE_16, PVR_BINSIZE_0, PVR_BINSIZE_0 },

        /* Vertex buffer size 512K */
        512*1024
};
There are also some kos-gl specific funtions. Are this necessary? Or i may just use glBegin/glEnd?

Code: Select all

glKosBeginFrame();
glKosFinishFrame();
Check the BioGB emulator any help me get it much better!!
http://www.geocities.com/instructivus
Post Reply