English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. C/C++

 
 
Thread Tools
Old 17 May 2024, 09:38   #1
NovaCoder
Registered User
 
NovaCoder's Avatar
 
Join Date: Sep 2007
Location: Melbourne/Australia
Posts: 4,406
Mesa OpenGL 68k RTG

I got a bit bored recently and started to port my old 3D engine over to 68k, I made some good progress but hit a bit of a wall with the triangle rendering along with the 8bit AGA color depth limitations.

I was thinking about using my old engine to do a little space shooter game.

Anyway, I decided to look for alternatives to my old DirectX render target (which my engine was using before) and of course started looking at OpenGL and more specifically Storm. I've tried to compile the old Storm sources a few times over the years but always got stuck on something, this time I actually managed to get (a cut down) build building

Here's the code that generated the attached output:

Code:
int main(int argc, char **argv) {
	ULONG modeId = INVALID_ID;

	atexit(exitT);

	CyberGfxBase = OpenLibrary((UBYTE*)"cybergraphics.library", 0);

	// Choose the best mode.
	modeId = BestCModeIDTags(CYBRBIDTG_Depth, DEPTH, CYBRBIDTG_NominalWidth, WIDTH, CYBRBIDTG_NominalHeight, HEIGHT, TAG_DONE);

	_hardwareScreen = CreateHardwareScreen(modeId, WIDTH, HEIGHT, DEPTH);

	_hardwareWindow = CreateHardwareWindowFullScreen(WIDTH, HEIGHT, _hardwareScreen);

	context = AmigaMesaCreateContextTags(AMA_Window, (ULONG) _hardwareWindow, AMA_Width, WIDTH, AMA_Height, HEIGHT,
	AMA_RGBMode, GL_TRUE, TAG_END);

	drawTriangles(500);

	return 0;
}

void drawTriangles(int num) {
	int count;
	struct timeval startTime, stopTime;
	double secs;

	/* we have changed the context (maybe the buffer too, so
	 * make it the current again
	 */
	AmigaMesaMakeCurrent(context);

	glEnable(GL_DEPTH_TEST);
	glEnable(GL_DITHER);
	glShadeModel(GL_SMOOTH);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();

	glOrtho(-400.0, 400.0, -300.0, 300.0, 500.0, -500.0);

	srand(42);

	gettimeofday(&startTime, NULL);
	for (count = 0; count < num; count++) {
		glBegin(GL_TRIANGLES);
		glColor3ub(rand() % 256, rand() % 256, rand() % 256);
		glVertex3i(rand() % 800 - 400, rand() % 600 - 300, rand() % 1000 - 500);
		glColor3ub(rand() % 256, rand() % 256, rand() % 256);
		glVertex3i(rand() % 800 - 400, rand() % 600 - 300, rand() % 1000 - 500);
		glColor3ub(rand() % 256, rand() % 256, rand() % 256);
		glVertex3i(rand() % 800 - 400, rand() % 600 - 300, rand() % 1000 - 500);
		glEnd();
	}
	glFlush();
	gettimeofday(&stopTime, NULL);

	secs = (double) stopTime.tv_micro / 1000000 + stopTime.tv_secs;
	secs -= (double) startTime.tv_micro / 1000000 + startTime.tv_secs;
	if (secs == 0.0)
		secs = 0.1;

	printf("%g triangles/s (%g secs)\n", (double) num / secs, secs);
}
As you can see it's pretty easy to use.

I'm thinking that this could be use to add basic opengl support to some stuff or maybe even to do my space shooter (if I can find the energy)

Does anyone know if Storm Mesa was ever actually used for any 68K games?
Attached Thumbnails
Click image for larger version

Name:	Mesa_output.jpg
Views:	72
Size:	15.5 KB
ID:	82237   Click image for larger version

Name:	Mesa32bit.jpg
Views:	104
Size:	48.7 KB
ID:	82238  

Last edited by NovaCoder; 17 May 2024 at 09:51.
NovaCoder is offline  
Old 17 May 2024, 11:20   #3
NovaCoder
Registered User
 
NovaCoder's Avatar
 
Join Date: Sep 2007
Location: Melbourne/Australia
Posts: 4,406
Cool, thanks Alex

Yes I was thinking about piStorm as a target for Storm

I think it might just be powerful enough for some simple 3D rendering.
NovaCoder is offline  
Old 17 May 2024, 12:49   #4
alexh
Thalion Webshrine
 
alexh's Avatar
 
Join Date: Jan 2004
Location: Oxford
Posts: 14,411
It would be good to keep in mind that ultimately PiStorm should get a 68k Warp3D driver for VideoCore VI. Yes it might be years in coming but I am hopeful.

Would it be possible to write your work so as to be able to target both SW renderer and HW renderer if it became available in the future?
alexh is offline  
Old 17 May 2024, 13:44   #5
NovaCoder
Registered User
 
NovaCoder's Avatar
 
Join Date: Sep 2007
Location: Melbourne/Australia
Posts: 4,406
Quote:
Originally Posted by alexh View Post
It would be good to keep in mind that ultimately PiStorm should get a 68k Warp3D driver for VideoCore VI. Yes it might be years in coming but I am hopeful.

Would it be possible to write your work so as to be able to target both SW renderer and HW renderer if it became available in the future?
Maybe, I've only just got this working so don't know what I'll do next. I'll try and build a simple 3D test and see what kind of performance is possible on a piStorm first using software rendering.
NovaCoder is offline  
Old 17 May 2024, 14:04   #6
alexh
Thalion Webshrine
 
alexh's Avatar
 
Join Date: Jan 2004
Location: Oxford
Posts: 14,411
There are several examples of people using wazp3D which IIUC is a Warp3D software render driver. It's performance is "ok" but I don't know much about it.

https://aminet.net/package/driver/video/Wazp3D
http://thellier.free.fr/Wazp3D.htm

[ Show youtube player ]
[ Show youtube player ]
alexh is offline  
Old 17 May 2024, 14:14   #7
Seiya
Registered User
 
Seiya's Avatar
 
Join Date: Nov 2014
Location: Italy
Posts: 2,417
Warp3D emulation (software) should be much faster than Wazp3D (software).
Emu68 is much faster than WinUAE because it emulates only CPU and not all computer hardware, de facto should be fast as Amithlon in cpu speed.
Warp3D is the best solution.
Seiya is offline  
Old 17 May 2024, 14:27   #8
alexh
Thalion Webshrine
 
alexh's Avatar
 
Join Date: Jan 2004
Location: Oxford
Posts: 14,411
Quote:
Originally Posted by Seiya View Post
Warp3D emulation (software) should be much faster than Wazp3D (software).
That doesn't make any sense. Surely if there was a Warp3D software renderer then there would be no-need for Wazp3D would there? I suspect there isn't one (or it was terrible) but I'm probably wrong.

Quote:
Originally Posted by Seiya View Post
Emu68 is much faster than WinUAE because it emulates only CPU and not all computer hardware, de facto should be fast as Amithlon in cpu speed.
Again that makes no sense. WinUAE can be faster than Emu68 because it can run on the latest Intel/AMD processors which are roughly 10x the performance over an RPi4's 2.2GHz ARM Cortex A72. Not to mention that WinUAE Warp3D can utilise HW acceleration.
alexh is offline  
Old 17 May 2024, 17:30   #9
Hedeon
Semi-Retired
 
Join Date: Mar 2012
Location: Leiden / The Netherlands
Posts: 2,026
StormMESA currently needs warp3d.library. It's sitting on top of Warp3D for HW 3D. StormMESA is gfx card agnostic.
Hedeon is offline  
Old 17 May 2024, 17:33   #10
Hedeon
Semi-Retired
 
Join Date: Mar 2012
Location: Leiden / The Netherlands
Posts: 2,026
Also, StormMESA has a software rendering option through an ENV
Hedeon is offline  
Old 17 May 2024, 17:51   #11
Seiya
Registered User
 
Seiya's Avatar
 
Join Date: Nov 2014
Location: Italy
Posts: 2,417
Quote:
Originally Posted by alexh View Post
Not to mention that WinUAE Warp3D can utilise HW acceleration.
i have some doubts that works in this way.
Dosbox emulate Glide and you can run Windows 98 with Direct3D support and play any 3DFX game, but OpenGL and Direct3D are emulated by cpu
Gallium in VWMare use the cpu to emulate OpenGL/DirectX
Seiya is offline  
Old 17 May 2024, 18:13   #12
alexh
Thalion Webshrine
 
alexh's Avatar
 
Join Date: Jan 2004
Location: Oxford
Posts: 14,411
Quote:
Originally Posted by Seiya View Post
Quote:
Originally Posted by alexh View Post
Not to mention that WinUAE Warp3D can utilise HW acceleration.
i have some doubts that works in this way.
I hope this dispels them.

https://github.com/RobDangerous/QuarkTex

Wazp3D in WinUAE can also do something similar.
alexh is offline  
Old 17 May 2024, 20:06   #13
arti
Registered User
 
Join Date: Jul 2008
Location: Poland
Posts: 663
Cool little example, no SDL used.

I use StormMesa with SDL since 2010. It was available all time on amiga sourceforge.
I've compiled many games with it like HexenGL,Cube1,Cube2 recently WipEout:

[ Show youtube player ]

I was also trying to compile it with gcc6 many years without success.
And using that old one was not working with SDL compiled with gcc6.
Just recently I decided to link also that old libSDL and to my big suprise it works!

So I could compile more complex source code like this :

[ Show youtube player ]

Linkable libGL is available in SM archive. It links all needed GL funcs from SDL.

Last edited by arti; 17 May 2024 at 20:24.
arti is offline  
Old 18 May 2024, 00:07   #14
NovaCoder
Registered User
 
NovaCoder's Avatar
 
Join Date: Sep 2007
Location: Melbourne/Australia
Posts: 4,406
Quote:
Originally Posted by arti View Post
Cool little example, no SDL used.

I use StormMesa with SDL since 2010. It was available all time on amiga sourceforge.
I've compiled many games with it like HexenGL,Cube1,Cube2 recently WipEout:

[ Show youtube player ]

I was also trying to compile it with gcc6 many years without success.
And using that old one was not working with SDL compiled with gcc6.
Just recently I decided to link also that old libSDL and to my big suprise it works!

So I could compile more complex source code like this :

[ Show youtube player ]

Linkable libGL is available in SM archive. It links all needed GL funcs from SDL.

Cool, nice work Arti

It's interesting that emulated 68K makes this kind of thing possible theses days.

I used the old Storm Mesa 3.0 code off Aminet, early days but hopefully I can use it for something cool.
NovaCoder is offline  
Old 18 May 2024, 08:03   #15
davec
Registered User
 
Join Date: Sep 2021
Location: Los Angeles
Posts: 17
How did you compile the code? With which compiler?

Sent from my SM-F731U1 using Tapatalk
davec is offline  
Old 18 May 2024, 08:35   #16
NovaCoder
Registered User
 
NovaCoder's Avatar
 
Join Date: Sep 2007
Location: Melbourne/Australia
Posts: 4,406
Quote:
Originally Posted by davec View Post
how did you compile the code? With which compiler?

Sent from my sm-f731u1 using tapatalk
gcc 6
NovaCoder is offline  
Old 18 May 2024, 09:59   #17
alexh
Thalion Webshrine
 
alexh's Avatar
 
Join Date: Jan 2004
Location: Oxford
Posts: 14,411
Quote:
Originally Posted by NovaCoder View Post
It's interesting that emulated 68K makes this kind of thing possible theses days.
I don't think it's so much the speed of the emulated processor as the direct access to native HW accelerated OpenGL We won't see this kind of performance on PiSTorm (with Emu68) until there is a Warp3D driver

Quote:
I used the old Storm Mesa 3.0 code off Aminet, early days but hopefully I can use it for something cool.
Looking forward to it
alexh is offline  
Old 18 May 2024, 19:02   #18
tomcat666
Retro Freak
 
tomcat666's Avatar
 
Join Date: Nov 2001
Location: Slovenia
Age: 51
Posts: 1,655
Thank you for working on this guys (I know a few people work on different parts of pistorm GL stuff currently, if you are interested in pistorm GL implementation do join us on the discord #software-amiga channel, so maybe there can be some collaboration and duplicate work could be avoided.)
tomcat666 is offline  
Old 18 May 2024, 20:57   #19
thellier
Registered User
 
Join Date: Sep 2011
Location: Paris/France
Posts: 275
* StormMesa is an OpenGL
* It got a software renderer or use Warp3D as 3D driver for hardware rendering
* So it can also use Wazp3D or Quarktex (WinUAE only) that are Warp3D compatible libraries
* Both can also use hard rendering inside WinUAE via OpenGL32.dll
* Quarktex package also have a full replacement agl.library (=stormmesa) with hard rendering inside WinUAE via OpenGL32.dll
* StormMesa has been rebuild/debugged :new sources are here :
https://aminet.net/package/util/libs/StormMesa2010

Note: Microbe3D library is NOT using StormMesa but Warp3D directly
http://thellier.free.fr/Docs/Microbe3D.html
thellier is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
AmiQuake new 68k Quake Port for AGA/RTG NovaCoder News 465 27 May 2024 10:12
Chocolate Doom port to 68K RTG NovaCoder News 34 22 February 2024 08:34
Grafx2 for Amiga OS 3.X (68K RTG) PerspexSphinx support.Apps 4 14 February 2022 07:17
Best open source, mod-able RTG-friendly FPS Engine running on 68k? eXeler0 Amiga scene 48 10 August 2016 23:38
68k + Picasso (RTG) Demos ?? Amiten Amiga scene 14 27 August 2013 17:39

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 01:00.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.11279 seconds with 16 queries