![]() |
![]() |
#1 |
Registered User
Join Date: Sep 2007
Location: Melbourne/Australia
Posts: 4,457
|
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); } 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? Last edited by NovaCoder; 17 May 2024 at 09:51. |
![]() |
![]() |
#3 |
Registered User
Join Date: Sep 2007
Location: Melbourne/Australia
Posts: 4,457
|
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. |
![]() |
![]() |
#4 |
Thalion Webshrine
Join Date: Jan 2004
Location: Oxford
Posts: 14,625
|
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? |
![]() |
![]() |
#5 | |
Registered User
Join Date: Sep 2007
Location: Melbourne/Australia
Posts: 4,457
|
Quote:
|
|
![]() |
![]() |
#6 |
Thalion Webshrine
Join Date: Jan 2004
Location: Oxford
Posts: 14,625
|
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 ] |
![]() |
![]() |
#7 |
Registered User
Join Date: Nov 2014
Location: Italy
Posts: 2,517
|
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. |
![]() |
![]() |
#8 | |
Thalion Webshrine
Join Date: Jan 2004
Location: Oxford
Posts: 14,625
|
Quote:
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. |
|
![]() |
![]() |
#9 |
Semi-Retired
Join Date: Mar 2012
Location: Leiden / The Netherlands
Posts: 2,064
|
StormMESA currently needs warp3d.library. It's sitting on top of Warp3D for HW 3D. StormMESA is gfx card agnostic.
|
![]() |
![]() |
#10 |
Semi-Retired
Join Date: Mar 2012
Location: Leiden / The Netherlands
Posts: 2,064
|
Also, StormMESA has a software rendering option through an ENV
|
![]() |
![]() |
#11 |
Registered User
Join Date: Nov 2014
Location: Italy
Posts: 2,517
|
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 |
![]() |
![]() |
#12 | |
Thalion Webshrine
Join Date: Jan 2004
Location: Oxford
Posts: 14,625
|
Quote:
https://github.com/RobDangerous/QuarkTex Wazp3D in WinUAE can also do something similar. |
|
![]() |
![]() |
#13 |
Registered User
Join Date: Jul 2008
Location: Poland
Posts: 678
|
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. |
![]() |
![]() |
#14 | |
Registered User
Join Date: Sep 2007
Location: Melbourne/Australia
Posts: 4,457
|
Quote:
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. |
|
![]() |
![]() |
#15 |
Registered User
Join Date: Sep 2021
Location: Los Angeles
Posts: 18
|
How did you compile the code? With which compiler?
Sent from my SM-F731U1 using Tapatalk |
![]() |
![]() |
#16 |
Registered User
Join Date: Sep 2007
Location: Melbourne/Australia
Posts: 4,457
|
|
![]() |
![]() |
#17 | ||
Thalion Webshrine
Join Date: Jan 2004
Location: Oxford
Posts: 14,625
|
Quote:
Quote:
|
||
![]() |
![]() |
#18 |
Retro Freak
Join Date: Nov 2001
Location: Slovenia
Age: 51
Posts: 1,706
|
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.)
|
![]() |
![]() |
#19 |
Registered User
Join Date: Sep 2011
Location: Paris/France
Posts: 279
|
* 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 |
![]() |
![]() |
#20 |
Registered User
Join Date: Sep 2007
Location: Melbourne/Australia
Posts: 4,457
|
I decided to try a slightly newer version of Mesa and managed to get 4.1 running, no idea what bugs it has. I built this quick test based on the supplied demo code.
I'll keep hacking away in my spare time and try to test it, if it works okay then maybe I can add it to SDL 2 ![]() ![]() I've already tried adding this to my AmiQuake port but for some reason it just shows a blank screen (doesn't crash though) Here's the demo code... Code:
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> #include <stdarg.h> #include <sys/time.h> #include <proto/exec.h> #include <proto/intuition.h> #include <proto/graphics.h> #include <proto/utility.h> #include <proto/cybergraphics.h> #include <cybergraphics/cybergraphics.h> #include <GL/amiga_mesa.h> #include <GL/glu.h> #define WIDTH 640 #define HEIGHT 480 #define DEPTH 16 // Hardware screen - Only used when running in fullscreen. static struct Screen *_hardwareScreen = NULL; // Hardware window - Used for both fullscreen and window modes. static struct Window *_hardwareWindow = NULL; struct Library *CyberGfxBase = NULL; AMesaContext *context = NULL; #define CI_OFFSET 16 GLboolean doubleBuffer = GL_TRUE; GLenum mode1, mode2; GLint size; float pntA[3] = { -160.0, 0.0, 0.0 }; float pntB[3] = { -130.0, 0.0, 0.0 }; float pntC[3] = { -40.0, -50.0, 0.0 }; float pntD[3] = { 30.0, 60.0, 0.0 }; enum { COLOR_BLACK = 0, COLOR_RED, COLOR_GREEN, COLOR_YELLOW, COLOR_BLUE, COLOR_MAGENTA, COLOR_CYAN, COLOR_WHITE }; static float RGBMap[9][3] = { {0, 0, 0}, {1, 0, 0}, {0, 1, 0}, {1, 1, 0}, {0, 0, 1}, {1, 0, 1}, {0, 1, 1}, {1, 1, 1}, {0.5, 0.5, 0.5} }; static void SetColor(int c) { glColor3fv(RGBMap[c]); } void exitT(void) { if (context) { amesa_destroy_context(context); context = NULL; } if (_hardwareWindow) { //ClearPointer(_hardwareWindow); CloseWindow(_hardwareWindow); _hardwareWindow = NULL; } if (_hardwareScreen) { // We opened the screen and therefore must close it (running in full screen mode). CloseScreen(_hardwareScreen); _hardwareScreen = NULL; } if (CyberGfxBase) { CloseLibrary(CyberGfxBase); CyberGfxBase = NULL; } } static struct Screen* CreateHardwareScreen(ULONG modeId, int width, int height, int bpp) { return OpenScreenTags(NULL, SA_Depth, bpp, SA_DisplayID, modeId, SA_Top, 0, SA_Left, 0, SA_Width, width, SA_Height, height, SA_Type, CUSTOMSCREEN, SA_Quiet, TRUE, SA_ShowTitle, FALSE, SA_Draggable, FALSE, SA_Exclusive, TRUE, SA_AutoScroll, FALSE, TAG_DONE); } static struct Window* CreateHardwareWindowFullScreen(int width, int height, struct Screen *sreen) { return OpenWindowTags(NULL, WA_Left, 0, WA_Top, 0, WA_Width, width, WA_Height, height, WA_CustomScreen, (ULONG )sreen, WA_Backdrop, TRUE, WA_Borderless, TRUE, WA_Activate, TRUE, WA_SimpleRefresh, TRUE, WA_NoCareRefresh, TRUE, WA_ReportMouse, FALSE, WA_RMBTrap, TRUE, WA_IDCMP, IDCMP_CLOSEWINDOW|IDCMP_ACTIVEWINDOW|IDCMP_INACTIVEWINDOW, TAG_END); } static void Init(void) { //GLint i; glClearColor(0.0, 0.0, 0.0, 0.0); glLineStipple(1, 0xF0E0); glBlendFunc(GL_SRC_ALPHA, GL_ONE); //if (!rgb) { //for (i = 0; i < 16; i++) { // glutSetColor(i + CI_OFFSET, i / 15.0, i / 15.0, 0.0); //} //} mode1 = GL_FALSE; mode2 = GL_FALSE; size = 1; } static void Reshape(int width, int height) { glViewport(0, 0, (GLint) width, (GLint) height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D(-175, 175, -175, 175); glMatrixMode(GL_MODELVIEW); } static void DrawSomething(void) { GLint i; glClear(GL_COLOR_BUFFER_BIT); glLineWidth(size); if (mode1) { glEnable(GL_LINE_STIPPLE); } else { glDisable(GL_LINE_STIPPLE); } if (mode2) { glEnable(GL_LINE_SMOOTH); glEnable(GL_BLEND); } else { glDisable(GL_LINE_SMOOTH); glDisable(GL_BLEND); } glPushMatrix(); glShadeModel( GL_FLAT ); for (i = 0; i < 360; i += 5) { glRotatef(5.0, 0,0,1); glColor3f(1.0, 1.0, 0.0); glBegin(GL_LINE_STRIP); glVertex3fv(pntA); glVertex3fv(pntB); glEnd(); glPointSize(1); SetColor(COLOR_GREEN); glBegin(GL_POINTS); glVertex3fv(pntA); glVertex3fv(pntB); glEnd(); } glPopMatrix(); glFlush(); if (doubleBuffer) { amesa_swap_buffers(context); } } static int test = 0; // hack static AMesaContext* AmigaMesaCreateContextTags(long Tag1, ...) { return amesa_create_context((struct TagItem*) &Tag1); } 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_DoubleBuf, GL_TRUE, AMA_Fullscreen, GL_TRUE, TAG_END); amesa_make_current(context); Init(); Reshape(WIDTH, HEIGHT); while (test < 10) { DrawSomething(); test++; } return EXIT_SUCCESS; } Last edited by NovaCoder; 23 June 2024 at 10:06. |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
![]() |
||||
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 |
|
|