#include <proto/exec.h>
#include <proto/powersdl.h>
//#include <proto/powersdl_gfx.h>
#include <iostream>
struct Library *PowerSDLBase=nullptr;
//struct Library *PowerSDLGfxBase=nullptr;
using namespace std;
static void setupOpengl(int width, int height) {
}
static void drawScreen() {
}
int main(int argc, char *argv[]) {
cout << "begin ..." << endl;
/* mos */
if ((PowerSDLBase = OpenLibrary((STRPTR)"powersdl.library", 16))==nullptr){
cout<<"could not open powersdl.library"<<endl;
return -1;
}
/*if ((PowerSDLGfxBase = OpenLibrary((STRPTR)"powersdl_gfx.library", 16))==nullptr){
cout<<"could not open powersdl_gfx.library"<<endl;
return -2;
}*/
int res = SDL_Init(SDL_INIT_VIDEO);
if (res) {
cout << "could not init sdl, result=" << res << ", error=" << SDL_GetError() << endl;
}
SDL_Surface *screen = SDL_SetVideoMode(640, 480, 0, SDL_OPENGL);
if (screen == nullptr) {
cout << "could set display mode, error=" << SDL_GetError() << endl;
}
setupOpengl(640, 480);
SDL_Event event;
bool b = true;
while (b) {
res = SDL_PollEvent(&event);
if (res) {
switch (event.type) {
case SDL_KEYDOWN:
cout << "key down event" << endl;
break;
case SDL_KEYUP:
cout << "key up event" << endl;
break;
case SDL_MOUSEMOTION:
cout << "mouse motion event" << endl;
break;
case SDL_MOUSEBUTTONDOWN:
cout << "mouse button down event" << endl;
break;
case SDL_MOUSEBUTTONUP:
cout << "mouse button up event" << endl;
break;
case SDL_QUIT:
cout << "quit event" << endl;
b = false;
break;
}
}
drawScreen();
SDL_Delay(40);
}
SDL_Quit();
/* mos */
CloseLibrary(PowerSDLBase);
//CloseLibrary(PowerSDLGfxBase);
cout << "end!" << endl;
return 0;
}
In file included from /System/Development/GG/usr/include/proto/powersdl.h:12:0,
from test_sdl.cpp:2:
/System/Development/GG/usr/include/clib/powersdl_protos.h:79:69: error: conflicting declaration of C function 'Uint32 SDL_MapRGB(SDL_PixelFormat*, Uint8, Uint8, Uint8)'
Uint32 SDL_MapRGB(SDL_PixelFormat *format, Uint8 r, Uint8 g, Uint8 b);
^
In file included from /System/Development/GG/usr/include/SDL/SDL_mouse.h:32:0,
from /System/Development/GG/usr/include/SDL/SDL_events.h:35,
from /System/Development/GG/usr/include/SDL/SDL.h:37,
from /System/Development/GG/usr/include/clib/powersdl_protos.h:16,
from /System/Development/GG/usr/include/proto/powersdl.h:12,
from test_sdl.cpp:2:
/System/Development/GG/usr/include/SDL/SDL_video.h:492:32: note: previous declaration 'Uint32 SDL_MapRGB(const SDL_PixelFormat*, Uint8, Uint8, Uint8)'
extern DECLSPEC Uint32 SDLCALL SDL_MapRGB
^
In file included from /System/Development/GG/usr/include/proto/powersdl.h:12:0,
from test_sdl.cpp:2:
/System/Development/GG/usr/include/clib/powersdl_protos.h:80:79: error: conflicting declaration of C function 'Uint32 SDL_MapRGBA(SDL_PixelFormat*, Uint8, Uint8, Uint8, Uint8)'
Uint32 SDL_MapRGBA(SDL_PixelFormat *format, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
^
In file included from /System/Development/GG/usr/include/SDL/SDL_mouse.h:32:0,
from /System/Development/GG/usr/include/SDL/SDL_events.h:35,
from /System/Development/GG/usr/include/SDL/SDL.h:37,
from /System/Development/GG/usr/include/clib/powersdl_protos.h:16,
from /System/Development/GG/usr/include/proto/powersdl.h:12,
from test_sdl.cpp:2:
/System/Development/GG/usr/include/SDL/SDL_video.h:499:32: note: previous declaration 'Uint32 SDL_MapRGBA(const SDL_PixelFormat*, Uint8, Uint8, Uint8, Uint8)'
extern DECLSPEC Uint32 SDLCALL SDL_MapRGBA
^
In file included from /System/Development/GG/usr/include/proto/powersdl.h:12:0,
from test_sdl.cpp:2:
/System/Development/GG/usr/include/clib/powersdl_protos.h:91:79: error: conflicting declaration of C function 'void SDL_GetRGB(Uint32, SDL_PixelFormat*, Uint8*, Uint8*, Uint8*)'
void SDL_GetRGB(Uint32 pix, SDL_PixelFormat *fmt, Uint8 *r, Uint8 *g, Uint8 *b);
^
In file included from /System/Development/GG/usr/include/SDL/SDL_mouse.h:32:0,
from /System/Development/GG/usr/include/SDL/SDL_events.h:35,
from /System/Development/GG/usr/include/SDL/SDL.h:37,
from /System/Development/GG/usr/include/clib/powersdl_protos.h:16,
from /System/Development/GG/usr/include/proto/powersdl.h:12,
from test_sdl.cpp:2:
/System/Development/GG/usr/include/SDL/SDL_video.h:506:30: note: previous declaration 'void SDL_GetRGB(Uint32, const SDL_PixelFormat*, Uint8*, Uint8*, Uint8*)'
extern DECLSPEC void SDLCALL SDL_GetRGB(Uint32 pixel,
^
In file included from /System/Development/GG/usr/include/proto/powersdl.h:12:0,
from test_sdl.cpp:2:
/System/Development/GG/usr/include/clib/powersdl_protos.h:92:90: error: conflicting declaration of C function 'void SDL_GetRGBA(Uint32, SDL_PixelFormat*, Uint8*, Uint8*, Uint8*, Uint8*)'
void SDL_GetRGBA(Uint32 pix, SDL_PixelFormat *fmt, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a);
^
In file included from /System/Development/GG/usr/include/SDL/SDL_mouse.h:32:0,
from /System/Development/GG/usr/include/SDL/SDL_events.h:35,
from /System/Development/GG/usr/include/SDL/SDL.h:37,
from /System/Development/GG/usr/include/clib/powersdl_protos.h:16,
from /System/Development/GG/usr/include/proto/powersdl.h:12,
from test_sdl.cpp:2:
/System/Development/GG/usr/include/SDL/SDL_video.h:513:30: note: previous declaration 'void SDL_GetRGBA(Uint32, const SDL_PixelFormat*, Uint8*, Uint8*, Uint8*, Uint8*)'
extern DECLSPEC void SDLCALL SDL_GetRGBA(Uint32 pixel,
//#include <proto/exec.h>
//#include <proto/powersdl.h>
//#include <proto/powersdl_gfx.h>
#include <SDL/SDL.h>
#include <GL/gl.h>
#include <iostream>
//struct Library *PowerSDLBase=nullptr;
//struct Library *PowerSDLGfxBase=nullptr;
using namespace std;
static void setupOpengl(int width, int height) {
float ratio = (float) width / (float) height;
glShadeModel(GL_SMOOTH);
glCullFace(GL_BACK);
glFrontFace(GL_CCW);
glEnable(GL_CULL_FACE);
glClearColor(0, 0, 0, 0);
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60.0, ratio, 1.0, 1024.0);
}
static void drawScreen() {
/* Our angle of rotation. */
static float angle = 0.0f;
static GLfloat v0[] = {-1.0f, -1.0f, 1.0f};
static GLfloat v1[] = {1.0f, -1.0f, 1.0f};
static GLfloat v2[] = {1.0f, 1.0f, 1.0f};
static GLfloat v3[] = {-1.0f, 1.0f, 1.0f};
static GLfloat v4[] = {-1.0f, -1.0f, -1.0f};
static GLfloat v5[] = {1.0f, -1.0f, -1.0f};
static GLfloat v6[] = {1.0f, 1.0f, -1.0f};
static GLfloat v7[] = {-1.0f, 1.0f, -1.0f};
static GLubyte red[] = {255, 0, 0, 255};
static GLubyte green[] = {0, 255, 0, 255};
static GLubyte blue[] = {0, 0, 255, 255};
static GLubyte white[] = {255, 255, 255, 255};
static GLubyte yellow[] = {0, 255, 255, 255};
static GLubyte black[] = {0, 0, 0, 255};
static GLubyte orange[] = {255, 255, 0, 255};
static GLubyte purple[] = {255, 0, 255, 0};
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0.0, 0.0, -5.0);
glRotatef(angle, 0.0, 1.0, 0.0);
if (++angle > 360.0f) {
angle = 0.0f;
}
glBegin(GL_TRIANGLES);
glColor4ubv(red);
glVertex3fv(v0);
glColor4ubv(green);
glVertex3fv(v1);
glColor4ubv(blue);
glVertex3fv(v2);
glColor4ubv(red);
glVertex3fv(v0);
glColor4ubv(blue);
glVertex3fv(v2);
glColor4ubv(white);
glVertex3fv(v3);
glColor4ubv(green);
glVertex3fv(v1);
glColor4ubv(black);
glVertex3fv(v5);
glColor4ubv(orange);
glVertex3fv(v6);
glColor4ubv(green);
glVertex3fv(v1);
glColor4ubv(orange);
glVertex3fv(v6);
glColor4ubv(blue);
glVertex3fv(v2);
glColor4ubv(black);
glVertex3fv(v5);
glColor4ubv(yellow);
glVertex3fv(v4);
glColor4ubv(purple);
glVertex3fv(v7);
glColor4ubv(black);
glVertex3fv(v5);
glColor4ubv(purple);
glVertex3fv(v7);
glColor4ubv(orange);
glVertex3fv(v6);
glColor4ubv(yellow);
glVertex3fv(v4);
glColor4ubv(red);
glVertex3fv(v0);
glColor4ubv(white);
glVertex3fv(v3);
glColor4ubv(yellow);
glVertex3fv(v4);
glColor4ubv(white);
glVertex3fv(v3);
glColor4ubv(purple);
glVertex3fv(v7);
glColor4ubv(white);
glVertex3fv(v3);
glColor4ubv(blue);
glVertex3fv(v2);
glColor4ubv(orange);
glVertex3fv(v6);
glColor4ubv(white);
glVertex3fv(v3);
glColor4ubv(orange);
glVertex3fv(v6);
glColor4ubv(purple);
glVertex3fv(v7);
glColor4ubv(green);
glVertex3fv(v1);
glColor4ubv(red);
glVertex3fv(v0);
glColor4ubv(yellow);
glVertex3fv(v4);
glColor4ubv(green);
glVertex3fv(v1);
glColor4ubv(yellow);
glVertex3fv(v4);
glColor4ubv(black);
glVertex3fv(v5);
glEnd();
SDL_GL_SwapBuffers();
}
int main(int argc, char *argv[]) {
cout << "begin ..." << endl;
/* mos */
/*if ((PowerSDLBase = OpenLibrary((STRPTR)"powersdl.library", 16))==nullptr){
cout<<"could not open powersdl.library"<<endl;
return -1;
}*/
/*if ((PowerSDLGfxBase = OpenLibrary((STRPTR)"powersdl_gfx.library", 11))==nullptr){
cout<<"could not open powersdl_gfx.library"<<endl;
return -2;
} */
int res = SDL_Init(SDL_INIT_VIDEO);
if (res) {
cout << "could not init sdl, result=" << res << ", error=" << SDL_GetError() << endl;
}
SDL_Surface *screen = SDL_SetVideoMode(640, 480, 0, SDL_OPENGL);
if (screen == nullptr) {
cout << "could set display mode, error=" << SDL_GetError() << endl;
}
setupOpengl(640, 480);
SDL_Event event;
bool b = true;
while (b) {
res = SDL_PollEvent(&event);
if (res) {
switch (event.type) {
case SDL_KEYDOWN:
cout << "key down event" << endl;
break;
case SDL_KEYUP:
cout << "key up event" << endl;
break;
case SDL_MOUSEMOTION:
cout << "mouse motion event" << endl;
break;
case SDL_MOUSEBUTTONDOWN:
cout << "mouse button down event" << endl;
break;
case SDL_MOUSEBUTTONUP:
cout << "mouse button up event" << endl;
break;
case SDL_QUIT:
cout << "quit event" << endl;
b = false;
break;
}
}
drawScreen();
SDL_Delay(40);
}
SDL_Quit();
/* mos */
//CloseLibrary(PowerSDLBase);
//CloseLibrary(PowerSDLGfxBase);
cout << "end!" << endl;
return 0;
}
[1] [ramlib] [Open] [MOSSYS:LIBS/powersdl.library.elf] [Lesen] [Fehlgeschlagen]
[2] [ramlib] [Open] [MOSSYS:LIBS/powersdl.library.elf] [Lesen] [Fehlgeschlagen]
[3] [ramlib] [Load] [MOSSYS:LIBS/powersdl.library.elf] [] [Fehlgeschlagen]
[4] [ramlib] [Open] [MOSSYS:LIBS/powersdl.library] [Lesen] [Fehlgeschlagen]
[5] [ramlib] [Open] [MOSSYS:LIBS/powersdl.library] [Lesen] [Fehlgeschlagen]
[6] [ramlib] [Load] [MOSSYS:LIBS/powersdl.library] [] [Fehlgeschlagen]
[7] [ramlib] [Open] [LIBS:powersdl.library.elf] [Lesen] [Fehlgeschlagen]
[8] [ramlib] [Open] [LIBS:powersdl.library.elf] [Lesen] [Fehlgeschlagen]
[9] [ramlib] [Load] [LIBS:powersdl.library.elf] [] [Fehlgeschlagen]
[10] [ramlib] [Open] [powersdl.library.elf] [Lesen] [Fehlgeschlagen]
[11] [ramlib] [Open] [powersdl.library.elf] [Lesen] [Fehlgeschlagen]
[12] [ramlib] [Load] [powersdl.library.elf] [] [Fehlgeschlagen]
[13] [test_sdl] [Open] [PROGDIR:Catalogs/deutsch/PowerSDL.catalog] [Lesen] [Fehlgeschlagen]
[14] [test_sdl] [Open] [MOSSYS:LOCALE/Catalogs/deutsch/PowerSDL.catalog] [Lesen] [Fehlgeschlagen]
[15] [test_sdl] [Open] [LOCALE:Catalogs/deutsch/PowerSDL.catalog] [Lesen] [Fehlgeschlagen]
[16] [ramlib] [Open] [MOSSYS:LIBS/tinygl.library.elf] [Lesen] [Fehlgeschlagen]
[17] [ramlib] [Open] [MOSSYS:LIBS/tinygl.library.elf] [Lesen] [Fehlgeschlagen]
[18] [ramlib] [Load] [MOSSYS:LIBS/tinygl.library.elf] [] [Fehlgeschlagen]
[19] [test_sdl] [Open] [TGLDEBUG] [Lesen] [Fehlgeschlagen]
[20] [test_sdl] [Open] [TGLNOMIP] [Lesen] [Fehlgeschlagen]
[21] [test_sdl] [Open] [TGLLOWQTEXTURES] [Lesen] [Fehlgeschlagen]
[22] [test_sdl] [Open] [TGLSYNC] [Lesen] [Fehlgeschlagen]
[23] [test_sdl] [Open] [SDL_VIDEO_CENTERED] [Lesen] [Fehlgeschlagen]
[24] [Shell Process] [Open] [shellppc.prefs] [Lesen] [Fehlgeschlagen]
[4] [Shell Process] [ChangeDir] [Work:tmp] [] []
[5] [Shell Process] [Open] [test_sdl] [Lesen] [Ok]
[6] [Shell Process] [Load] [test_sdl] [] [Ok]
[7] [Shell Process] [Open] [test_sdl] [Lesen] [Ok]
[8] [Shell Process] [ChangeDir] [Work:tmp] [] []
[9] [ramlib] [Load] [MOSSYS:LIBS/powersdl.library.elf] [] [Fehlgeschlagen]
[10] [ramlib] [Open] [MOSSYS:LIBS/powersdl.library.elf] [Lesen] [Fehlgeschlagen]
[11] [ramlib] [Open] [MOSSYS:LIBS/powersdl.library.elf] [Lesen] [Fehlgeschlagen]
[12] [ramlib] [Load] [MOSSYS:LIBS/powersdl.library] [] [Fehlgeschlagen]
[13] [ramlib] [Open] [MOSSYS:LIBS/powersdl.library] [Lesen] [Fehlgeschlagen]
[14] [ramlib] [Open] [MOSSYS:LIBS/powersdl.library] [Lesen] [Fehlgeschlagen]
[15] [ramlib] [Load] [LIBS:powersdl.library.elf] [] [Fehlgeschlagen]
[16] [ramlib] [Open] [LIBS:powersdl.library.elf] [Lesen] [Fehlgeschlagen]
[17] [ramlib] [Open] [LIBS:powersdl.library.elf] [Lesen] [Fehlgeschlagen]
[18] [ramlib] [Load] [powersdl.library.elf] [] [Fehlgeschlagen]
[19] [ramlib] [Open] [powersdl.library.elf] [Lesen] [Fehlgeschlagen]
[20] [ramlib] [Open] [powersdl.library.elf] [Lesen] [Fehlgeschlagen]
[21] [ramlib] [Load] [LIBS:powersdl.library] [] [Ok]
[22] [ramlib] [Open] [LIBS:powersdl.library] [Lesen] [Ok]
[23] [test_sdl] [Open] [NIL:] [Lesen] [Ok]
[24] [test_sdl] [Open] [NIL:] [Schreiben] [Ok]
[25] [test_sdl] [Open] [NIL:] [Lesen] [Ok]
[26] [test_sdl] [Open] [NIL:] [Schreiben] [Ok]
[27] [test_sdl] [ChangeDir] [Ram Disk:ENV] [] []
[28] [test_sdl] [Open] [SDL_CGX_PREFERENCES] [Lesen] [Ok]
[29] [test_sdl] [ChangeDir] [Work:tmp] [] []
[30] [test_sdl] [Open] [PROGDIR:Catalogs/deutsch/PowerSDL.catalog] [Lesen] [Fehlgeschlagen]
[31] [test_sdl] [Open] [MOSSYS:LOCALE/Catalogs/deutsch/PowerSDL.catalog] [Lesen] [Fehlgeschlagen]
[32] [test_sdl] [Open] [LOCALE:Catalogs/deutsch/PowerSDL.catalog] [Lesen] [Fehlgeschlagen]
[33] [test_sdl] [ChangeDir] [Work:tmp] [] []
[34] [ramlib] [Load] [MOSSYS:LIBS/tinygl.library.elf] [] [Fehlgeschlagen]
[35] [ramlib] [Open] [MOSSYS:LIBS/tinygl.library.elf] [Lesen] [Fehlgeschlagen]
[36] [ramlib] [Open] [MOSSYS:LIBS/tinygl.library.elf] [Lesen] [Fehlgeschlagen]
[37] [ramlib] [Load] [MOSSYS:LIBS/tinygl.library] [] [Ok]
[38] [ramlib] [Open] [MOSSYS:LIBS/tinygl.library] [Lesen] [Ok]
[39] [test_sdl] [ChangeDir] [System:MorphOS/Libs/tinygl] [] []
[40] [test_sdl] [Load] [System:MorphOS/Libs/tinygl/r200.library] [] [Ok]
[41] [test_sdl] [Open] [System:MorphOS/Libs/tinygl/r200.library] [Lesen] [Ok]
[42] [test_sdl] [Load] [System:MorphOS/Libs/tinygl/r300.library] [] [Ok]
[43] [test_sdl] [Open] [System:MorphOS/Libs/tinygl/r300.library] [Lesen] [Ok]
[44] [test_sdl] [ChangeDir] [Work:tmp] [] []
[45] [test_sdl] [ChangeDir] [Ram Disk:ENV] [] []
[46] [test_sdl] [Open] [TGLDEBUG] [Lesen] [Fehlgeschlagen]
[47] [test_sdl] [ChangeDir] [Work:tmp] [] []
[48] [test_sdl] [ChangeDir] [Ram Disk:ENV] [] []
[49] [test_sdl] [Open] [TGLNOMIP] [Lesen] [Fehlgeschlagen]
[50] [test_sdl] [ChangeDir] [Work:tmp] [] []
[51] [test_sdl] [ChangeDir] [Ram Disk:ENV] [] []
[52] [test_sdl] [Open] [TGLLOWQTEXTURES] [Lesen] [Fehlgeschlagen]
[53] [test_sdl] [ChangeDir] [Work:tmp] [] []
[54] [test_sdl] [ChangeDir] [Ram Disk:ENV] [] []
[55] [test_sdl] [Open] [TGLSYNC] [Lesen] [Fehlgeschlagen]
[56] [test_sdl] [ChangeDir] [Work:tmp] [] []
[57] [test_sdl] [LockScreen] [Workbench] [] [Ok]
[58] [test_sdl] [LockScreen] [Workbench] [] [Ok]
[59] [test_sdl] [ChangeDir] [Ram Disk:ENV] [] []
[60] [test_sdl] [Open] [SDL_VIDEO_CENTERED] [Lesen] [Fehlgeschlagen]
[61] [test_sdl] [ChangeDir] [Work:tmp] [] []
#define GL_GLEXT_PROTOTYPES
#ifdef __APPLE__
#include <gl.h>
#include <glu.h>
#else
#include <GL/gl.h>
#include <GL/glu.h>
#endif
#include <iostream>
#include <SDL/SDL.h>
using namespace std;
static void setupOpenGl(int width, int height) {
const float ratio = (float) width / (float) height;
glShadeModel(GL_SMOOTH);
glCullFace(GL_BACK);
glFrontFace(GL_CCW);
glEnable(GL_CULL_FACE);
glClearColor(0, 0, 0, 0);
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60.0, ratio, 1.0, 1024.0);
}
static void drawScreen() {
static float angle = 0.0f;
static GLfloat v0[] = {-1.0f, -1.0f, 1.0f};
static GLfloat v1[] = {1.0f, -1.0f, 1.0f};
static GLfloat v2[] = {1.0f, 1.0f, 1.0f};
static GLfloat v3[] = {-1.0f, 1.0f, 1.0f};
static GLfloat v4[] = {-1.0f, -1.0f, -1.0f};
static GLfloat v5[] = {1.0f, -1.0f, -1.0f};
static GLfloat v6[] = {1.0f, 1.0f, -1.0f};
static GLfloat v7[] = {-1.0f, 1.0f, -1.0f};
static GLubyte red[] = {255, 0, 0, 255};
static GLubyte green[] = {0, 255, 0, 255};
static GLubyte blue[] = {0, 0, 255, 255};
static GLubyte white[] = {255, 255, 255, 255};
static GLubyte yellow[] = {0, 255, 255, 255};
static GLubyte black[] = {0, 0, 0, 255};
static GLubyte orange[] = {255, 255, 0, 255};
static GLubyte purple[] = {255, 0, 255, 0};
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0.0, 0.0, -5.0);
glRotatef(angle, 0.0, 1.0, 0.0);
if (++angle > 360.0f) {
angle = 0.0f;
}
glBegin(GL_TRIANGLES);
glColor4ubv(red);
glVertex3fv(v0);
glColor4ubv(green);
glVertex3fv(v1);
glColor4ubv(blue);
glVertex3fv(v2);
glColor4ubv(red);
glVertex3fv(v0);
glColor4ubv(blue);
glVertex3fv(v2);
glColor4ubv(white);
glVertex3fv(v3);
glColor4ubv(green);
glVertex3fv(v1);
glColor4ubv(black);
glVertex3fv(v5);
glColor4ubv(orange);
glVertex3fv(v6);
glColor4ubv(green);
glVertex3fv(v1);
glColor4ubv(orange);
glVertex3fv(v6);
glColor4ubv(blue);
glVertex3fv(v2);
glColor4ubv(black);
glVertex3fv(v5);
glColor4ubv(yellow);
glVertex3fv(v4);
glColor4ubv(purple);
glVertex3fv(v7);
glColor4ubv(black);
glVertex3fv(v5);
glColor4ubv(purple);
glVertex3fv(v7);
glColor4ubv(orange);
glVertex3fv(v6);
glColor4ubv(yellow);
glVertex3fv(v4);
glColor4ubv(red);
glVertex3fv(v0);
glColor4ubv(white);
glVertex3fv(v3);
glColor4ubv(yellow);
glVertex3fv(v4);
glColor4ubv(white);
glVertex3fv(v3);
glColor4ubv(purple);
glVertex3fv(v7);
glColor4ubv(white);
glVertex3fv(v3);
glColor4ubv(blue);
glVertex3fv(v2);
glColor4ubv(orange);
glVertex3fv(v6);
glColor4ubv(white);
glVertex3fv(v3);
glColor4ubv(orange);
glVertex3fv(v6);
glColor4ubv(purple);
glVertex3fv(v7);
glColor4ubv(green);
glVertex3fv(v1);
glColor4ubv(red);
glVertex3fv(v0);
glColor4ubv(yellow);
glVertex3fv(v4);
glColor4ubv(green);
glVertex3fv(v1);
glColor4ubv(yellow);
glVertex3fv(v4);
glColor4ubv(black);
glVertex3fv(v5);
glEnd();
SDL_GL_SwapBuffers();
}
int main(int argc, char *argv[]) {
cout << "begin ..." << endl;
int res = SDL_Init(SDL_INIT_VIDEO);
if (res) {
cout << "could not init sdl, result=" << res << ", error=" << SDL_GetError() << endl;
return -1;
}
SDL_Surface *screen = SDL_SetVideoMode(640, 480, 0, SDL_OPENGL);
if (screen == nullptr) {
cout << "could set display mode, error=" << SDL_GetError() << endl;
return -2;
}
SDL_WM_SetCaption("sdl_test", nullptr);
setupOpenGl(640, 480);
SDL_Event events[16];
bool b = true;
while (b) {
SDL_PumpEvents();
res = SDL_PeepEvents(events, 16, SDL_GETEVENT,
SDL_KEYDOWNMASK |
SDL_KEYUPMASK |
SDL_MOUSEMOTIONMASK |
SDL_MOUSEBUTTONDOWNMASK |
SDL_MOUSEBUTTONUPMASK |
SDL_QUITMASK);
for (int i = 0; i < res; ++i) {
switch (events[i].type) {
case SDL_KEYDOWN:
cout << "key down event" << endl;
break;
case SDL_KEYUP:
cout << "key up event" << endl;
break;
case SDL_MOUSEMOTION:
cout << "mouse motion event, x=" << events[i].motion.x << ", y=" << events[i].motion.y << endl;
break;
case SDL_MOUSEBUTTONDOWN:
cout << "mouse button down event" << endl;
break;
case SDL_MOUSEBUTTONUP:
cout << "mouse button up event" << endl;
break;
case SDL_QUIT:
cout << "quit event" << endl;
b = false;
break;
}
}
drawScreen();
SDL_Delay(40);
}
SDL_Quit();
cout << "end!" << endl;
return 0;
}