English Amiga Board


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

 
 
Thread Tools
Old 27 June 2024, 20:11   #41
riker77
Registered User
 
Join Date: Oct 2012
Location: Germany
Posts: 24
Quote:
Originally Posted by klx300r View Post
same here (see vid below) ...what type of Pi you using?
I'm running the PiStrom32lite with a CM4 at 2.2GHz in my A1200.
riker77 is offline  
Old 28 June 2024, 14:06   #42
NovaCoder
Registered User
 
NovaCoder's Avatar
 
Join Date: Sep 2007
Location: Melbourne/Australia
Posts: 4,430
okay I've updated the double buffering and pixel rendering to use the same routines that I use for ScummVM RTG, should work fine now.
Attached Files
File Type: lha MesaGearsNova.lha (638.1 KB, 11 views)
NovaCoder is offline  
Old 28 June 2024, 16:48   #43
jeff b00toNic
Registered User
 
jeff b00toNic's Avatar
 
Join Date: Nov 2011
Location: Arnsberg Germany
Age: 45
Posts: 207
Now it runs well, if the background transition from black to white is intentional.

Are you planning something special to do with it?
jeff b00toNic is offline  
Old 28 June 2024, 19:42   #44
klx300r
Registered User
 
klx300r's Avatar
 
Join Date: Oct 2007
Location: ManCave, Canada
Posts: 1,646
Thumbs up

@ NovaCoder

this one is much better on PiStorm32-3A+

https://www.dropbox.com/scl/fi/06zag...6plr1jrsm&dl=0
klx300r is offline  
Old 28 June 2024, 19:48   #45
klx300r
Registered User
 
klx300r's Avatar
 
Join Date: Oct 2007
Location: ManCave, Canada
Posts: 1,646
Quote:
Originally Posted by riker77 View Post
I'm running the PiStrom32lite with a CM4 at 2.2GHz in my A1200.
thanks it's good to know for comparison sake btw I'm running PiStorm32 with a 3A+
klx300r is offline  
Old 28 June 2024, 23:26   #46
NovaCoder
Registered User
 
NovaCoder's Avatar
 
Join Date: Sep 2007
Location: Melbourne/Australia
Posts: 4,430
Quote:
Originally Posted by klx300r View Post
@ NovaCoder

this one is much better on PiStorm32-3A+

https://www.dropbox.com/scl/fi/06zag...6plr1jrsm&dl=0

Quote:
Originally Posted by jeff b00toNic View Post
Now it runs well, if the background transition from black to white is intentional.

Are you planning something special to do with it?
Cool

Yes it's intentional with the background.

I'm thinking about combining it with SDL 2 which will allow some more advanced ports. Would love to do a Half-life port, always wanted to do that one but you really need OpenGL and SDL 2 support for that. It would be a huge amount of work though, not sure if I have the time & energy these days.


Code comparison time...


Original Mesa:

Code:
struct amigamesa_context
{
	void *gl_ctx;                   /* the core library context */
	struct amigamesa_visual  *visual; /* the visual context */
	struct amigamesa_buffer  *buffer; /* the buffer context */

	struct amigamesa_context *share;

	unsigned long flags;                    /*0x1 = own visuel, 0x2 = own buffer
						  0x4 = forbid 3D HW, 0x8 = fullscreen mode */


	unsigned long pixel;                    /* current color index or RGBA pixel value */
	unsigned long clearpixel;       /* pixel for clearing the color buffers */

	/* etc... */
	struct Window *window;                  /* Not neaded if in dubbelbuff needed */                /* the Intuition window */
	struct RastPort *front_rp;      /* front rastport */
	struct RastPort *back_rp;               /* back rastport */
	int    SwapCounter;                     /* which buffer is active */
	UBYTE* FrontArray;                                      /* for multibuffering */
	UBYTE* BackArray;                                       /*a pen Array big as drawing area for use in dubelbuff mode*/
	struct RastPort *rp;                    /* current rastport */
	struct Screen *Screen;                  /* current screen*/
	struct TmpRas *tmpras;                  /* tmpras rastport */
	struct RastPort *temprp;
	struct DBufInfo *dbufinfo;              /* OS3.0 multibuffering */

	GLuint depth;                                           /* bits per pixel (1, 8, 24, etc) */
	GLuint bppix;                           /* bytes per pixel */
	GLuint bprow;                           /* bytes per row */
	GLuint fmt;                             /* color format */

	GLuint  width, height;                          /* drawable area */
	GLint           left, bottom;                           /* offsets due to window border */
	GLint           right, top;             /* right, top offsets, needed for correct resizing */
	GLint           RealWidth,RealHeight;   /* the drawingareas real size*/
	GLint           FixedWidth,FixedHeight; /* The internal buffer real size speeds up the drawing a bit*/
	long*           ColorTable;             /* LUT8 display: ARGB -> real pen conversion */
						/* ARGB display: ARGB -> GL pen conversion */
	long*           ColorTable2;            /* LUT8 display: table of allocated pens */
						/* ARGB display: GL pen -> ARGB conversion */
	UBYTE penconv[256];                     /* pen conversion from GL color to real color */
	UBYTE penconvinv[256];                  /* pen conversion from real color to GL color */
	UBYTE dtable[256];
	UBYTE bugfix[256];
	UBYTE *imageline;                                       /* One Line for WritePixelRow renders */
	GLuint *rgb_buffer;                                     /*back buffer when in RGBA mode OLD DElete?*/

	void (*InitDD)(void *  );                                                                  /* keep track of witch drawing rutines should be used */
	void (*Dispose) (struct amigamesa_context *c);          /* Use this when AmigaMesaDestroyContext is called */
	void (*SwapBuffer) (struct amigamesa_context *c);       /* Use this when AmigaMesaSwapBuffers is called */
	ULONG ColTable[256];
	ULONG ColTable2[256];
	ULONG oldFPU;                           /* old rounding mode */
	UBYTE pixelargb[4];
	ULONG specialalloc;
	UBYTE dmatrix[128+8];
	struct ScreenBuffer *sbuf1;              /* OS3.0 multibuffering */
	struct ScreenBuffer *sbuf2;              /* OS3.0 multibuffering */
	struct MsgPort* dbport;                  /* OS3.0 multibuffering */
	int drawbufferflag;                     /* GL double buffering support  */
	int readbufferflag;                     /*              "               */
	int backarrayflag;                      /*              "               */
	UBYTE* DrawBuffer;                      /*              "               */
	UBYTE* ReadBuffer;                      /*              "               */
	struct RastPort *back2_rp;              /* second back rastport */
	struct RastPort *draw_rp;
	void *hwdriver;                         /* hwdriver private structure */
	struct ScreenBuffer *sbuf3;             /* third screen buffer */
	struct ScreenBuffer *sbuf_initial;      /* initial screen buffer */

	struct timerequest *timerio;
	struct MsgPort *timerport;
};
My version:

Code:
struct amigamesa_context {
	GLcontext *gl_ctx; /* The core GL/Mesa context */
	GLvisual *gl_visual; /* Describes the buffers */
	GLframebuffer *gl_buffer; /* Depth, stencil, accum, etc buffers */

	GLuint depth; /* Bits per pixel (1, 8, 24, etc) */
	GLuint width, height; /* Drawable area */
	GLuint bppix; /* Bytes per pixel */
	GLuint bprow; /* Bytes per row */
	GLuint fmt; /* Color format */

	GLuint clear_color; /* Color for clearing the pixel buffer */
	GLubyte *back_buffer; /* Pixel buffer */

	// Amiga specific stuff.
	struct Window *hardware_window; /* Intuition window */
	struct Screen *hardware_screen; /* Intuition screen */
};
I'll probably slowly add more functionality to my hacked version (window support etc) so it will get more complicated (and therefore messy LoL).
Attached Files
File Type: c MesaTest.c (9.9 KB, 5 views)

Last edited by NovaCoder; Yesterday at 07:23.
NovaCoder is offline  
Old 28 June 2024, 23:41   #47
klx300r
Registered User
 
klx300r's Avatar
 
Join Date: Oct 2007
Location: ManCave, Canada
Posts: 1,646
Thumbs up

Quote:
Originally Posted by NovaCoder View Post
Cool

I'm thinking about combining it with SDL 2 which will allow some more advanced ports. Depends if I have the time.

Awesome news
klx300r is offline  
Old Today, 06:45   #48
NovaCoder
Registered User
 
NovaCoder's Avatar
 
Join Date: Sep 2007
Location: Melbourne/Australia
Posts: 4,430
Added a cute little starfield demo..

I also got a more advanced demo working (featuring lighting and texture mapping) but it was very slow, seems to be too much for just the CPU when you push the more advanced effects.
Attached Files
File Type: lha MesaStars.lha (1.22 MB, 5 views)
NovaCoder is offline  
Old Today, 09:10   #49
Mr-Z
Registered User
 
Join Date: Sep 2016
Location: Netherlands
Posts: 91
Quote:
Originally Posted by NovaCoder View Post
Added a cute little starfield demo..

I also got a more advanced demo working (featuring lighting and texture mapping) but it was very slow, seems to be too much for just the CPU when you push the more advanced effects.

It runs but seems to exit after a few seconds.
Mr-Z is offline  
Old Today, 09:41   #50
NovaCoder
Registered User
 
NovaCoder's Avatar
 
Join Date: Sep 2007
Location: Melbourne/Australia
Posts: 4,430
Quote:
Originally Posted by Mr-Z View Post
It runs but seems to exit after a few seconds.
Yep it's a time limited demo
NovaCoder is offline  
Old Today, 11:36   #51
arti
Registered User
 
Join Date: Jul 2008
Location: Poland
Posts: 666
Just recently I've found this OpenGL Toolkit Utility (GLUT).
I'm suprised how easy it is to use and how many stuff it supports:
easy window creating, keys and joy input etc.
And you only need GL/glut.h and link libgl.a

Gears code:
Code:
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <GL/glut.h>

#ifndef M_PI
#define M_PI 3.14159265
#endif

static GLint T0 = 0;
static GLint Frames = 0;


/**

  Draw a gear wheel.  You'll probably want to call this function when
  building a display list since we do a lot of trig here.
 
  Input:  inner_radius - radius of hole at center
          outer_radius - radius at center of teeth
          width - width of gear
          teeth - number of teeth
          tooth_depth - depth of tooth

 **/

static void
gear(GLfloat inner_radius, GLfloat outer_radius, GLfloat width,
  GLint teeth, GLfloat tooth_depth)
{
  GLint i;
  GLfloat r0, r1, r2;
  GLfloat angle, da;
  GLfloat u, v, len;

  r0 = inner_radius;
  r1 = outer_radius - tooth_depth / 2.0;
  r2 = outer_radius + tooth_depth / 2.0;

  da = 2.0 * M_PI / teeth / 4.0;

  glShadeModel(GL_FLAT);

  glNormal3f(0.0, 0.0, 1.0);

  /* draw front face */
  glBegin(GL_QUAD_STRIP);
  for (i = 0; i <= teeth; i++) {
    angle = i * 2.0 * M_PI / teeth;
    glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5);
    glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5);
    if (i < teeth) {
      glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5);
      glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), width * 0.5);
    }
  }
  glEnd();

  /* draw front sides of teeth */
  glBegin(GL_QUADS);
  da = 2.0 * M_PI / teeth / 4.0;
  for (i = 0; i < teeth; i++) {
    angle = i * 2.0 * M_PI / teeth;

    glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5);
    glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), width * 0.5);
    glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), width * 0.5);
    glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), width * 0.5);
  }
  glEnd();

  glNormal3f(0.0, 0.0, -1.0);

  /* draw back face */
  glBegin(GL_QUAD_STRIP);
  for (i = 0; i <= teeth; i++) {
    angle = i * 2.0 * M_PI / teeth;
    glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5);
    glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5);
    if (i < teeth) {
      glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), -width * 0.5);
      glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5);
    }
  }
  glEnd();

  /* draw back sides of teeth */
  glBegin(GL_QUADS);
  da = 2.0 * M_PI / teeth / 4.0;
  for (i = 0; i < teeth; i++) {
    angle = i * 2.0 * M_PI / teeth;

    glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), -width * 0.5);
    glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), -width * 0.5);
    glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5);
    glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5);
  }
  glEnd();

  /* draw outward faces of teeth */
  glBegin(GL_QUAD_STRIP);
  for (i = 0; i < teeth; i++) {
    angle = i * 2.0 * M_PI / teeth;

    glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5);
    glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5);
    u = r2 * cos(angle + da) - r1 * cos(angle);
    v = r2 * sin(angle + da) - r1 * sin(angle);
    len = sqrt(u * u + v * v);
    u /= len;
    v /= len;
    glNormal3f(v, -u, 0.0);
    glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), width * 0.5);
    glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5);
    glNormal3f(cos(angle), sin(angle), 0.0);
    glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), width * 0.5);
    glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), -width * 0.5);
    u = r1 * cos(angle + 3 * da) - r2 * cos(angle + 2 * da);
    v = r1 * sin(angle + 3 * da) - r2 * sin(angle + 2 * da);
    glNormal3f(v, -u, 0.0);
    glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), width * 0.5);
    glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), -width * 0.5);
    glNormal3f(cos(angle), sin(angle), 0.0);
  }

  glVertex3f(r1 * cos(0), r1 * sin(0), width * 0.5);
  glVertex3f(r1 * cos(0), r1 * sin(0), -width * 0.5);

  glEnd();

  glShadeModel(GL_SMOOTH);

  /* draw inside radius cylinder */
  glBegin(GL_QUAD_STRIP);
  for (i = 0; i <= teeth; i++) {
    angle = i * 2.0 * M_PI / teeth;
    glNormal3f(-cos(angle), -sin(angle), 0.0);
    glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5);
    glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5);
  }
  glEnd();

}

static GLfloat view_rotx = 20.0, view_roty = 30.0, view_rotz = 0.0;
static GLint gear1, gear2, gear3;
static GLfloat angle = 0.0;

static void
draw(void)
{
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

  glPushMatrix();
  glRotatef(view_rotx, 1.0, 0.0, 0.0);
  glRotatef(view_roty, 0.0, 1.0, 0.0);
  glRotatef(view_rotz, 0.0, 0.0, 1.0);

  glPushMatrix();
  glTranslatef(-3.0, -2.0, 0.0);
  glRotatef(angle, 0.0, 0.0, 1.0);
  glCallList(gear1);
  glPopMatrix();

  glPushMatrix();
  glTranslatef(3.1, -2.0, 0.0);
  glRotatef(-2.0 * angle - 9.0, 0.0, 0.0, 1.0);
  glCallList(gear2);
  glPopMatrix();

  glPushMatrix();
  glTranslatef(-3.1, 4.2, 0.0);
  glRotatef(-2.0 * angle - 25.0, 0.0, 0.0, 1.0);
  glCallList(gear3);
  glPopMatrix();

  glPopMatrix();

  glutSwapBuffers();

  Frames++;
  {
     GLint t = glutGet(GLUT_ELAPSED_TIME);
     if (t - T0 >= 5000) {
        GLfloat seconds = (t - T0) / 1000.0;
        GLfloat fps = Frames / seconds;
        printf("%d frames in %g seconds = %g FPS\n", Frames, seconds, fps);
        T0 = t;
        Frames = 0;
     }
  }
}


static void
idle(void)
{
  angle += 2.0;
  glutPostRedisplay();
}

/* change view angle, exit upon ESC */
/* ARGSUSED1 */
static void
key(unsigned char k, int x, int y)
{
  switch (k) {
  case 'z':
    view_rotz += 5.0;
    break;
  case 'Z':
    view_rotz -= 5.0;
    break;
  case 27:  /* Escape */
    exit(0);
    break;
  default:
    return;
  }
  glutPostRedisplay();
}

/* change view angle */
/* ARGSUSED1 */
static void
special(int k, int x, int y)
{
  switch (k) {
  case GLUT_KEY_UP:
    view_rotx += 5.0;
    break;
  case GLUT_KEY_DOWN:
    view_rotx -= 5.0;
    break;
  case GLUT_KEY_LEFT:
    view_roty += 5.0;
    break;
  case GLUT_KEY_RIGHT:
    view_roty -= 5.0;
    break;
  default:
    return;
  }
  glutPostRedisplay();
}

/* new window size or exposure */
static void
reshape(int width, int height)
{
  GLfloat h = (GLfloat) height / (GLfloat) width;

  glViewport(0, 0, (GLint) width, (GLint) height);
  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  glFrustum(-1.0, 1.0, -h, h, 5.0, 60.0);
  glMatrixMode(GL_MODELVIEW);
  glLoadIdentity();
  glTranslatef(0.0, 0.0, -40.0);
}

static void
init(int argc, char *argv[])
{
  static GLfloat pos[4] =
  {5.0, 5.0, 10.0, 0.0};
  static GLfloat red[4] =
  {0.8, 0.1, 0.0, 1.0};
  static GLfloat green[4] =
  {0.0, 0.8, 0.2, 1.0};
  static GLfloat blue[4] =
  {0.2, 0.2, 1.0, 1.0};

  glLightfv(GL_LIGHT0, GL_POSITION, pos);
  glEnable(GL_CULL_FACE);
  glEnable(GL_LIGHTING);
  glEnable(GL_LIGHT0);
  glEnable(GL_DEPTH_TEST);

  /* make the gears */
  gear1 = glGenLists(1);
  glNewList(gear1, GL_COMPILE);
  glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red);
  gear(1.0, 4.0, 1.0, 20, 0.7);
  glEndList();

  gear2 = glGenLists(1);
  glNewList(gear2, GL_COMPILE);
  glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green);
  gear(0.5, 2.0, 2.0, 10, 0.7);
  glEndList();

  gear3 = glGenLists(1);
  glNewList(gear3, GL_COMPILE);
  glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue);
  gear(1.3, 2.0, 0.5, 10, 0.7);
  glEndList();

  glEnable(GL_NORMALIZE);

  if (argc > 1 && strcmp(argv[1], "-info")==0) {
     printf("GL_RENDERER   = %s\n", (char *) glGetString(GL_RENDERER));
     printf("GL_VERSION    = %s\n", (char *) glGetString(GL_VERSION));
     printf("GL_VENDOR     = %s\n", (char *) glGetString(GL_VENDOR));
     printf("GL_EXTENSIONS = %s\n", (char *) glGetString(GL_EXTENSIONS));
  }
}

void 
visible(int vis)
{
  if (vis == GLUT_VISIBLE)
    glutIdleFunc(idle);
  else
    glutIdleFunc(NULL);
}

int main(int argc, char *argv[])
{
  glutInit(&argc, argv);
  glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);

  glutInitWindowPosition(0, 0);
  glutInitWindowSize(300, 300);
  glutCreateWindow("Gears");
  init(argc, argv);

  glutDisplayFunc(draw);
  glutReshapeFunc(reshape);
  glutKeyboardFunc(key);
  glutSpecialFunc(special);
  glutVisibilityFunc(visible);

  glutMainLoop();
  return 0;             /* ANSI C requires main to return int. */
}
I will try to use it in Wipeout.
Attached Files
File Type: lha gears.lha (20.7 KB, 6 views)
arti 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 17:54.

Top

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