|
#include <proto/tinygl.h>
void display (void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glutSwapBuffers();
}
void _start()
{
glutInit(NULL,NULL);//&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
glutInitWindowSize(640, 480);
glutFullScreen();
glutCreateWindow(NULL);
glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
glClearDepth(1.0f);
glEnable(GL_DEPTH_TEST);
glMatrixMode(GL_PROJECTION);
gluPerspective(80, 640.0 / 480.0, 1.0, 5000.0);
glMatrixMode(GL_MODELVIEW);
glutDisplayFunc(display);
glutMainLoop();
}
CC = gcc
LD = ld
STRIP = strip
CFLAGS = -Os -s -ffast-math -fomit-frame-pointer -noixemul -ISDK:tinygl-sdk/include
LIBS = -lGL
INTRO_OBJS = intro.o
all: intro
intro: $(INTRO_OBJS)
$(LD) -o $@ $(INTRO_OBJS) $(LIBS)
$(STRIP) -s -R .comment -R .gnu.version $@
chmod u+x $@
clean:
rm -f *.o intro
gcc -Os -s -ffast-math -fomit-frame-pointer -noixemul -ISDK:tinygl-sdk/include -c -o intro.o intro.c
ld -o intro intro.o -lGL -lc
/gg/ppc-morphos/lib/libGL.a(sharedinit.o): In function `__CSTP_init_TinyGLBase':
sharedinit.o(.text+0x1a): undefined reference to `SysBase'
sharedinit.o(.text+0x26): undefined reference to `SysBase'
/gg/ppc-morphos/lib/libGL.a(sharedinit.o): In function `__DSTP_cleanup_TinyGLBase':
sharedinit.o(.text+0xca): undefined reference to `SysBase'
sharedinit.o(.text+0xd6): undefined reference to `SysBase'
make: *** [intro] Error 1
#include <mgl/gl.h>
struct GfxBase *GfxBase;
struct IntuitionBase *IntuitionBase;
struct Library *CyberGfxBase;
struct Library *UtilityBase;
struct Library *TinyGLBase;
GLContext *__tglContext;
void QuitTinyGL(void)
{
if(TinyGLBase)
{
if(__tglContext)
GLClose(__tglContext);
CloseLibrary( TinyGLBase );
TinyGLBase = NULL;
}
CloseLibrary(UtilityBase);
CloseLibrary(CyberGfxBase);
CloseLibrary((struct Library *)IntuitionBase);
CloseLibrary((struct Library *)GfxBase);
}
int InitTinyGL(void)
{
/* apps expect these libs are open */
GfxBase = (struct GfxBase *)OpenLibrary("graphics.library", 50L);
IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library", 50L);
CyberGfxBase = OpenLibrary("cybergraphics.library", 50L);
UtilityBase = OpenLibrary("utility.library", 50L);
TinyGLBase = (struct Library *)OpenLibrary("tinygl.library",0);
if( !GfxBase || !IntuitionBase || !CyberGfxBase || !UtilityBase || !TinyGLBase )
{
QuitTinyGL();
return 1;
}
__tglContext = GLInit();
return 0;
}
void display ( void )
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glutSwapBuffers();
}
int main(int argc, char **argv)
{
InitTinyGL();
glutInit(NULL, NULL);
glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
glutInitWindowSize(640, 480);
glutFullScreen();
glutCreateWindow(NULL);
glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
glClearDepth(1.0f);
glEnable(GL_DEPTH_TEST);
glMatrixMode(GL_PROJECTION);
gluPerspective(80, 640.0 / 480.0, 1.0, 5000.0);
glMatrixMode(GL_MODELVIEW);
glutDisplayFunc(display);
glutMainLoop();
QuitTinyGL();
return 0;
}
#include <proto/exec.h>
#include <proto/tinygl.h>
#include <stdio.h>
static void display(void);
struct ExecBase *SysBase;
struct Library *TinyGLBase;
GLContext *__tglContext;
#define __TEXTSECTION__ __attribute__((section(".text")))
int entry(void)
{
SysBase = *(struct ExecBase **) 4;
TinyGLBase = OpenLibrary("tinygl.library", 50);
if (TinyGLBase)
{
__tglContext = GLInit();
if (__tglContext)
{
glutInit(NULL,NULL);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
glutInitWindowSize(640, 480);
glutFullScreen();
glutCreateWindow(NULL);
glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
glClearDepth(1.0f);
glEnable(GL_DEPTH_TEST);
glMatrixMode(GL_PROJECTION);
gluPerspective(80, 640.0 / 480.0, 1.0, 5000.0);
glMatrixMode(GL_MODELVIEW);
glutDisplayFunc(display);
glutMainLoop();
GLClose(__tglContext);
}
CloseLibrary(TinyGLBase);
}
exit(0);
return 0;
}
static void display(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glutSwapBuffers();
}
/* __abox__ symbol is required or else the binary is loaded as PowerUP app */
const int __abox__ __TEXTSECTION__ = 1;
/*
** This program uses the device interface to play a sampled sound.
** The input is read from THE DEFAULT INPUT, make sure you
** start it with "PlayTest pri < mysample.raw" !
** Where pri is a number from -128 to +127 (may be omitted)
** The sample should be 8 bit signed, mono (see TYPE).
**
** PLEASE NOTE that earlier versions of this example contained a bug
** that sometimes DeleteIORequest'ed a pointer that was AllocMem'ed!
*/
#include <devices/ahi.h>
#include <dos/dosasl.h>
#include <exec/memory.h>
#include <proto/exec.h>
#include <proto/dos.h>
#include <proto/ahi.h>
#include <stdlib.h>
#define FREQUENCY 8000
#define TYPE AHIST_M8S
#define BUFFERSIZE 20000
#ifndef M_PI
#define M_PI 3.14159265
#endif
void clean(LONG rc);
struct ExecBase *SysBase;
struct MsgPort *AHImp = NULL;
struct AHIRequest *AHIios[2] = {NULL,NULL};
struct AHIRequest *AHIio = NULL;
APTR AHIiocopy = NULL;
BYTE AHIDevice = -1;
BYTE buffer1[BUFFERSIZE];
BYTE buffer2[BUFFERSIZE];
#define __TEXTSECTION__ __attribute__((section(".text")))
//int main(int argc, char *argv[])
int entry(void)
{
SysBase = *(struct ExecBase **) 4;
BYTE *p1=buffer1,*p2=buffer2;
void *tmp;
ULONG signals,length;
struct AHIRequest *link = NULL;
BYTE pri = 0;
//Printf("Sound priority: %ldn", pri);
if((AHImp=CreateMsgPort()) != NULL) {
if((AHIio=(struct AHIRequest *)CreateIORequest(AHImp,sizeof(struct AHIRequest))) != NULL) {
AHIio->ahir_Version = 4;
AHIDevice=OpenDevice(AHINAME,0,(struct IORequest *)AHIio,0);
}
}
if(AHIDevice) {
//Printf("Unable to open %s/0 version 4n",AHINAME);
clean(RETURN_FAIL);
}
// Make a copy of the request (for double buffering)
AHIiocopy = AllocMem(sizeof(struct AHIRequest), MEMF_ANY);
if(! AHIiocopy) {
clean(RETURN_FAIL);
}
CopyMem(AHIio, AHIiocopy, sizeof(struct AHIRequest));
AHIios[0]=AHIio;
AHIios[1]=AHIiocopy;
SetIoErr(0);
LONG i;
for(i=0; i<BUFFERSIZE;++i) p1[i] = (BYTE)(255*sin(2*M_PI*40*i/FREQUENCY));
for(;;) {
// Fill buffer
length = BUFFERSIZE;//Read(Input(),p1,BUFFERSIZE);
// Play buffer
AHIios[0]->ahir_Std.io_Message.mn_Node.ln_Pri = pri;
AHIios[0]->ahir_Std.io_Command = CMD_WRITE;
AHIios[0]->ahir_Std.io_Data = p1;
AHIios[0]->ahir_Std.io_Length = length;
AHIios[0]->ahir_Std.io_Offset = 0;
AHIios[0]->ahir_Frequency = FREQUENCY;
AHIios[0]->ahir_Type = TYPE;
AHIios[0]->ahir_Volume = 0x10000; // Full volume
AHIios[0]->ahir_Position = 0x8000; // Centered
AHIios[0]->ahir_Link = link;
SendIO((struct IORequest *) AHIios[0]);
if(link) {
// Wait until the last buffer is finished (== the new buffer is started)
signals=Wait(SIGBREAKF_CTRL_C | (1L << AHImp->mp_SigBit));
// Check for Ctrl-C and abort if pressed
if(signals & SIGBREAKF_CTRL_C) {
SetIoErr(ERROR_BREAK);
break;
}
// Remove the reply and abort on error
if(WaitIO((struct IORequest *) link)) {
SetIoErr(ERROR_WRITE_PROTECTED);
break;
}
}
// Check for end-of-sound, and wait until it is finished before aborting
if(length != BUFFERSIZE) {
WaitIO((struct IORequest *) AHIios[0]);
break;
}
link = AHIios[0];
// Swap buffer and request pointers, and restart
tmp = p1;
p1 = p2;
p2 = tmp;
tmp = AHIios[0];
AHIios[0] = AHIios[1];
AHIios[1] = tmp;
}
// Abort any pending iorequests
AbortIO((struct IORequest *) AHIios[0]);
WaitIO((struct IORequest *) AHIios[0]);
if(link) { // Only if the second request was started
AbortIO((struct IORequest *) AHIios[1]);
WaitIO((struct IORequest *) AHIios[1]);
}
if(IoErr()) {
//PrintFault(IoErr(), argv[0] );
clean(RETURN_ERROR);
}
clean(RETURN_OK);
return 0; // Make compiler happy
}
void clean(LONG rc)
{
if(!AHIDevice)
CloseDevice((struct IORequest *)AHIio);
DeleteIORequest((struct IORequest *)AHIio);
FreeMem(AHIiocopy,sizeof(struct AHIRequest));
DeleteMsgPort(AHImp);
//exit(rc);
}
/* __abox__ symbol is required or else the binary is loaded as PowerUP app */
const int __abox__ __TEXTSECTION__ = 1;
gcc -Os -s -ffast-math -fomit-frame-pointer -noixemul -nostartfiles -ISDK:tinygl-sdk/include -c -o play.o play.c
play.c: In function 'entry':
play.c:49: warning: assignment from incompatible pointer type
play.c:83: warning: incompatible implicit declaration of built-in function 'sin'
play.c:158: warning: initialization from incompatible pointer type
gcc -Os -s -ffast-math -fomit-frame-pointer -noixemul -nostartfiles -ISDK:tinygl-sdk/include -o play play.o
/bin/../lib/gcc-lib/ppc-morphos/4.4.4/../../../../ppc-morphos/lib/libnix/libauto.a(__openliberror.o): In function `__openliberror':
__openliberror.o(.text+0xac): undefined reference to `exit'
collect2: ld returned 1 exit status
make: *** [play] Error 1
Ram Disk:> echo >test.c "int main(void){return 0;}"
Ram Disk:> ls
Clipboards ENV T test.c
Ram Disk:> gcc -noixemul test.c -Wl,-Map=foobar.map,--traditional-format
Ram Disk:> ls
Clipboards ENV T a.out foobar.map test.c
#include <proto/exec.h>
#include <proto/tinygl.h>
#include <stdio.h>
static void display(void);
struct ExecBase *SysBase;
struct Library *TinyGLBase;
GLContext *__tglContext;
static ULONG i;
#define __TEXTSECTION__ __attribute__((section(".text")))
int entry(void)
{
SysBase = *(struct ExecBase **) 4;
TinyGLBase = OpenLibrary("tinygl.library", 50);
if (TinyGLBase)
{
i=160;
__tglContext = GLInit();
if (__tglContext)
{
glutInit(NULL,NULL);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
glutInitWindowSize(640, 480);
glutFullScreen();
glutCreateWindow(NULL);
glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
glClearDepth(1.0f);
glEnable(GL_DEPTH_TEST);
glMatrixMode(GL_PROJECTION);
gluPerspective(80, 640.0 / 480.0, 1.0, 5000.0);
glMatrixMode(GL_MODELVIEW);
glutDisplayFunc(display);
glutMainLoop();
GLClose(__tglContext);
}
CloseLibrary(TinyGLBase);
}
return 0;
}
static void display(void)
{
i++;
glClearColor(((i&255)/255.0f), 0.0f, 0.0f, 0.5f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glutSwapBuffers();
}
/* __abox__ symbol is required or else the binary is loaded as PowerUP app */
const int __abox__ __TEXTSECTION__ = 1;
#include <devices/ahi.h>
#include <proto/exec.h>
#include <proto/dos.h>
#include <proto/tinygl.h>
#include <proto/ahi.h>
#include <stdio.h>
#define FREQUENCY 8000
#define TYPE AHIST_M8S
#define BUFFERSIZE 20000
static void display(void);
struct ExecBase *SysBase;
struct DosLibrary *DOSBase;
struct Library *TinyGLBase;
struct Library *AHIBase;
GLContext *__tglContext;
static struct MsgPort *AHImp = NULL;
static struct AHIRequest *AHIios[2] = {NULL,NULL};
static struct AHIRequest *AHIio = NULL;
static APTR AHIiocopy = NULL;
static BYTE AHIDevice = -1;
static BYTE buffer1[BUFFERSIZE];
static BYTE buffer2[BUFFERSIZE];
static BYTE *p1=buffer1,*p2=buffer2;
static void *tmp;
static ULONG signals, length = BUFFERSIZE, i;
static struct AHIRequest *link = NULL;
static struct Task *self;
#define __TEXTSECTION__ __attribute__((section(".text")))
int entry(void)
{
SysBase = *(struct ExecBase **) 4;
DOSBase = OpenLibrary("dos.library", 50);
TinyGLBase = OpenLibrary("tinygl.library", 50);
if (TinyGLBase)
{
self = FindTask(NULL);
// Initialize AHI device
AHImp=CreateMsgPort();
if(AHImp != NULL)
{
AHIio=(struct AHIRequest *)CreateIORequest(AHImp,sizeof(struct AHIRequest));
AHIio->ahir_Version = 4;
AHIDevice=OpenDevice(AHINAME,0,(struct IORequest *)AHIio,0);
}
// Make a copy of the request (for double buffering)
AHIiocopy = AllocMem(sizeof(struct AHIRequest), MEMF_ANY);
CopyMem(AHIio, AHIiocopy, sizeof(struct AHIRequest));
AHIios[0]=AHIio;
AHIios[1]=AHIiocopy;
SetIoErr(0);
// Fill sound buffers
for(i=0; i<BUFFERSIZE;i++) {
p1[i] = (i<<1)&255;
}
for (i=BUFFERSIZE-1; i < (BUFFERSIZE<<1); i++) {
p2[i-BUFFERSIZE] = (i<<1)&255;
}
i=160;
__tglContext = GLInit();
if (__tglContext)
{
glutInit(NULL,NULL);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
glutInitWindowSize(640, 480);
glutFullScreen();
glutCreateWindow(NULL);
glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
glClearDepth(1.0f);
glEnable(GL_DEPTH_TEST);
glMatrixMode(GL_PROJECTION);
gluPerspective(80, 640.0 / 480.0, 1.0, 5000.0);
glMatrixMode(GL_MODELVIEW);
glutIdleFunc(display);
glutMainLoop();
GLClose(__tglContext);
}
// Abort any pending iorequests
AbortIO((struct IORequest *) AHIios[0]);
WaitIO((struct IORequest *) AHIios[0]);
if(link) // Only if the second request was started
{
AbortIO((struct IORequest *) AHIios[1]);
WaitIO((struct IORequest *) AHIios[1]);
}
CloseLibrary(DOSBase);
CloseLibrary(TinyGLBase);
}
return 0;
}
static void display(void)
{
if(link)
{
//struct Message *ms = GetMsg(AHImp);
Signal(self, SIGBREAKF_CTRL_D);
// Wait until the last buffer is finished (== the new buffer is started)
signals = Wait(SIGBREAKF_CTRL_D | (1L << AHImp->mp_SigBit));
}
if (signals & (1L << AHImp->mp_SigBit)) {
// Swap buffer and request pointers, and restart
tmp = p1;
p1 = p2;
p2 = tmp;
tmp = AHIios[0];
AHIios[0] = AHIios[1];
AHIios[1] = tmp;
}
// Play buffer
if (signals & (1L << AHImp->mp_SigBit) || !link)
{
length = BUFFERSIZE;
AHIios[0]->ahir_Std.io_Message.mn_Node.ln_Pri = 8;
AHIios[0]->ahir_Std.io_Command = CMD_WRITE;
AHIios[0]->ahir_Std.io_Data = p1;
AHIios[0]->ahir_Std.io_Length = length;
AHIios[0]->ahir_Std.io_Offset = 0;
AHIios[0]->ahir_Frequency = FREQUENCY;
AHIios[0]->ahir_Type = TYPE;
AHIios[0]->ahir_Volume = 0x10000; // Full volume
AHIios[0]->ahir_Position = 0x8000; // Centered
AHIios[0]->ahir_Link = link;
SendIO((struct IORequest *) AHIios[0]);
}
link = AHIios[0];
i++;
glClearColor(0.0f, 0.0f, ((i&255)/255.0f), 0.5f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glutSwapBuffers();
}
/* __abox__ symbol is required or else the binary is loaded as PowerUP app */
const int __abox__ __TEXTSECTION__ = 1;
/*
* 4Kb Intro startup by Pedro Gil (Balrog Soft)
* www.amigaskool.net
*
* TinyGL and AHI device startup code.
*
* Special thanks to Piru for his small opts,
* and Morphzone.org people!
*
*/
#include <devices/ahi.h>
#include <proto/exec.h>
#include <proto/dos.h>
#include <proto/tinygl.h>
#include <proto/ahi.h>
#include <stdio.h>
#define FREQUENCY 8000
#define TYPE AHIST_M8S
#define BUFFERSIZE 20000
static void display(void);
struct ExecBase *SysBase;
struct DosLibrary *DOSBase;
struct Library *TinyGLBase;
struct Library *AHIBase;
GLContext *__tglContext;
static struct MsgPort *AHImp = NULL;
static struct AHIRequest *AHIios[2] = {NULL,NULL};
static struct AHIRequest *AHIio = NULL;
static APTR AHIiocopy = NULL;
static BYTE AHIDevice = -1;
static BYTE buffer1[BUFFERSIZE], buffer2[BUFFERSIZE];
static BYTE *p1=buffer1,*p2=buffer2;
static void *tmp;
static BOOL init = TRUE;
static ULONG signals, i, n = 1;
static struct AHIRequest *link = NULL;
static struct Task *self;
#define __TEXTSECTION__ __attribute__((section(".text")))
int entry(void)
{
SysBase = *(struct ExecBase **) 4;
DOSBase = OpenLibrary("dos.library", 50);
TinyGLBase = OpenLibrary("tinygl.library", 50);
if (TinyGLBase)
{
self = FindTask(NULL);
// Initialize AHI device
AHImp=CreateMsgPort();
if(AHImp != NULL)
{
AHIio=(struct AHIRequest *)CreateIORequest(AHImp,sizeof(struct AHIRequest));
AHIio->ahir_Version = 4;
AHIDevice=OpenDevice(AHINAME,0,(struct IORequest *)AHIio,0);
}
// Make a copy of the request (for double buffering)
AHIiocopy = AllocMem(sizeof(struct AHIRequest), MEMF_ANY);
CopyMem(AHIio, AHIiocopy, sizeof(struct AHIRequest));
AHIios[0]=AHIio;
AHIios[1]=AHIiocopy;
// Fill sound buffers
for(i=0; i<BUFFERSIZE;i++) {
p1[i] = (i*n)&255;
if ((i & 1023) == 0) n ++;
}
for (i=BUFFERSIZE-1; i < (BUFFERSIZE<<1); i++) {
p2[i-BUFFERSIZE] = (i*n)&255;
if ((i & 1023) == 0) n --;
}
i=160;
__tglContext = GLInit();
if (__tglContext)
{
glutInit(NULL,NULL);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
glutInitWindowSize(640, 480);
glutFullScreen();
glutCreateWindow(NULL);
glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
glClearDepth(1.0f);
glEnable(GL_DEPTH_TEST);
glMatrixMode(GL_PROJECTION);
gluPerspective(80, 640.0 / 480.0, 1.0, 5000.0);
glMatrixMode(GL_MODELVIEW);
glutIdleFunc(display);
glutMainLoop();
GLClose(__tglContext);
}
// Abort any pending iorequests
AbortIO((struct IORequest *) AHIios[0]);
WaitIO((struct IORequest *) AHIios[0]);
if(link) // Only if the second request was started
{
AbortIO((struct IORequest *) AHIios[1]);
WaitIO((struct IORequest *) AHIios[1]);
}
CloseLibrary(TinyGLBase);
CloseLibrary(DOSBase);
}
return 0;
}
static void display(void)
{
// Play buffer
if ((signals & (1L << AHImp->mp_SigBit) || init))
{
AHIios[0]->ahir_Std.io_Message.mn_Node.ln_Pri = 0;
AHIios[0]->ahir_Std.io_Command = CMD_WRITE;
AHIios[0]->ahir_Std.io_Data = p1;
AHIios[0]->ahir_Std.io_Length = BUFFERSIZE;
AHIios[0]->ahir_Std.io_Offset = 0;
AHIios[0]->ahir_Frequency = FREQUENCY;
AHIios[0]->ahir_Type = TYPE;
AHIios[0]->ahir_Volume = 0x10000; // Full volume
AHIios[0]->ahir_Position = 0x8000; // Centered
AHIios[0]->ahir_Link = link;
SendIO((struct IORequest *) AHIios[0]);
if (init && link)
init = FALSE;
}
if(link)
{
// Send a fake signal to not break the loop
Signal(self, SIGBREAKF_CTRL_D);
signals = Wait(SIGBREAKF_CTRL_D | (1L << AHImp->mp_SigBit));
}
link = AHIios[0];
if ((signals & (1L << AHImp->mp_SigBit)) || init)
{
if (!init)
WaitIO((struct IORequest *) AHIios[1]);
// Swap buffer and request pointers, and restart
tmp = p1;
p1 = p2;
p2 = tmp;
tmp = AHIios[0];
AHIios[0] = AHIios[1];
AHIios[1] = tmp;
}
i++;
glClearColor(0.0f, 0.0f, ((i&255)/255.0f), 0.5f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glutSwapBuffers();
}
/* __abox__ symbol is required or else the binary is loaded as PowerUP app */
const int __abox__ __TEXTSECTION__ = 1;
|