X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=src%2Fgacela_GL.c;h=c261fa2a1d9e4a8238da59da12f973061544ff20;hb=6a3d1ffb69036e6d4f1c239fd7d52f9bfc48d50c;hp=daf75f4e3b4b15ec7193674062aeb4d39efb8644;hpb=ddb41086a294d20c28c04b9aa20900acf3624506;p=gacela.git diff --git a/src/gacela_GL.c b/src/gacela_GL.c index daf75f4..c261fa2 100644 --- a/src/gacela_GL.c +++ b/src/gacela_GL.c @@ -27,6 +27,270 @@ gacela_glBegin (SCM mode) return SCM_UNSPECIFIED; } +SCM +gacela_glClear (SCM mask) +{ + glClear (scm_to_int (mask)); + return SCM_UNSPECIFIED; +} + +SCM +gacela_glClearColor (SCM red, SCM green, SCM blue, SCM alpha) +{ + glClearColor (scm_to_double (red), scm_to_double (green), scm_to_double (blue), scm_to_double (alpha)); + return SCM_UNSPECIFIED; +} + +SCM +gacela_glClearDepth (SCM depth) +{ + glClearDepth (scm_to_double (depth)); + return SCM_UNSPECIFIED; +} + +SCM +gacela_glColor3f (SCM red, SCM green, SCM blue) +{ + glColor3f (scm_to_double (red), scm_to_double (green), scm_to_double (blue)); + return SCM_UNSPECIFIED; +} + +SCM +gacela_glColor4f (SCM red, SCM green, SCM blue, SCM alpha) +{ + glColor4f (scm_to_double (red), scm_to_double (green), scm_to_double (blue), scm_to_double (alpha)); + return SCM_UNSPECIFIED; +} + +SCM +gacela_glDepthFunc (SCM func) +{ + glDepthFunc (scm_to_int (func)); + return SCM_UNSPECIFIED; +} + +SCM +gacela_glEnable (SCM cap) +{ + glEnable (scm_to_int (cap)); + return SCM_UNSPECIFIED; +} + +SCM +gacela_glDisable (SCM cap) +{ + glDisable (scm_to_int (cap)); + return SCM_UNSPECIFIED; +} + +SCM +gacela_glEnd (void) +{ + glEnd (); + return SCM_UNSPECIFIED; +} + +SCM +gacela_glHint (SCM target, SCM mode) +{ + glHint (scm_to_int (target), scm_to_int (mode)); + return SCM_UNSPECIFIED; +} + +SCM +gacela_glLoadIdentity (void) +{ + glLoadIdentity (); + return SCM_UNSPECIFIED; +} + +SCM +gacela_glMatrixMode (SCM mode) +{ + glMatrixMode (scm_to_int (mode)); + return SCM_UNSPECIFIED; +} + +SCM +gacela_glRotatef (SCM angle, SCM x, SCM y, SCM z) +{ + glRotatef (scm_to_double (angle), scm_to_double (x), scm_to_double (y), scm_to_double (z)); + return SCM_UNSPECIFIED; +} + +SCM +gacela_glShadeModel (SCM mode) +{ + glShadeModel (scm_to_int (mode)); + return SCM_UNSPECIFIED; +} + +SCM +gacela_glTranslatef (SCM x, SCM y, SCM z) +{ + glTranslatef (scm_to_double (x), scm_to_double (y), scm_to_double (z)); + return SCM_UNSPECIFIED; +} + +SCM +gacela_glVertex2f (SCM x, SCM y) +{ + glVertex2f (scm_to_double (x), scm_to_double (y)); + return SCM_UNSPECIFIED; +} + +SCM +gacela_glVertex3f (SCM x, SCM y, SCM z) +{ + glVertex3f (scm_to_double (x), scm_to_double (y), scm_to_double (z)); + return SCM_UNSPECIFIED; +} + +SCM +gacela_glViewport (SCM x, SCM y, SCM width, SCM height) +{ + glViewport (scm_to_int (x), scm_to_int (y), scm_to_int (width), scm_to_int (height)); + return SCM_UNSPECIFIED; +} + +SCM +gacela_glGenTextures (SCM n) +{ + SCM textures; + int nint = scm_to_int (n); + GLuint text[nint]; + int i; + + textures = scm_list_n (SCM_UNDEFINED); + glGenTextures (nint, &text[0]); + + for (i = nint - 1; i >= 0; i--) { + textures = scm_cons (scm_from_int (text[i]), textures); + } + + return textures; +} + +SCM +gacela_glDeleteTextures (SCM n, SCM textures) +{ + int nint = scm_to_int (n); + GLuint text[nint]; + int i; + + for (i = 0; i < nint; i++) { + text[i] = scm_to_int (scm_list_ref (textures, scm_from_int (i))); + } + + glDeleteTextures (nint, &text[0]); + return SCM_UNSPECIFIED; +} + +SCM +gacela_glBindTexture (SCM target, SCM texture) +{ + glBindTexture (scm_to_int (target), scm_to_int (texture)); + return SCM_UNSPECIFIED; +} + +SCM +gacela_glTexImage2D (SCM target, SCM level, SCM internalFormat, SCM width, SCM height, SCM border, SCM format, SCM type, SCM pixels) +{ + glTexImage2D (scm_to_int (target), scm_to_int (level), scm_to_int (internalFormat), scm_to_int (width), \ + scm_to_int (height), scm_to_int (border), scm_to_int (format), scm_to_int (type), \ + (GLvoid *)scm_to_int (pixels)); + return SCM_UNSPECIFIED; +} + +SCM +gacela_glTexParameteri (SCM target, SCM pname, SCM param) +{ + glTexParameteri (scm_to_int (target), scm_to_int (pname), scm_to_int (param)); + return SCM_UNSPECIFIED; +} + +SCM +gacela_glTexCoord2f (SCM s, SCM t) +{ + glTexCoord2f (scm_to_double (s), scm_to_double (t)); + return SCM_UNSPECIFIED; +} + +SCM +gacela_glLightfv (SCM light, SCM pname, SCM params) +{ + int n = scm_to_int (scm_length (params)); + GLfloat gl_params[n]; + int i; + + for (i = 0; i < n; i++) { + gl_params[i] = scm_to_double (scm_list_ref (params, scm_from_int (i))); + } + + glLightfv (scm_to_int (light), scm_to_int (pname), gl_params); + return SCM_UNSPECIFIED; +} + +SCM +gacela_glNormal3f (SCM nx, SCM ny, SCM nz) +{ + glNormal3f (scm_to_double (nx), scm_to_double (ny), scm_to_double (nz)); + return SCM_UNSPECIFIED; +} + +SCM +gacela_glBlendFunc (SCM sfactor, SCM dfactor) +{ + glBlendFunc (scm_to_int (sfactor), scm_to_int (dfactor)); + return SCM_UNSPECIFIED; +} + +SCM +gacela_glOrtho (SCM left, SCM right, SCM bottom, SCM top, SCM near_val, SCM far_val) +{ + glOrtho (scm_to_double (left), scm_to_double (right), scm_to_double (bottom), scm_to_double (top), \ + scm_to_double (near_val), scm_to_double (far_val)); + return SCM_UNSPECIFIED; +} + +SCM +gacela_glPushMatrix (void) +{ + glPushMatrix (); + return SCM_UNSPECIFIED; +} + +SCM +gacela_glPopMatrix (void) +{ + glPopMatrix (); + return SCM_UNSPECIFIED; +} + +SCM +gacela_gluPerspective (SCM fovy, SCM aspect, SCM zNear, SCM zFar) +{ + gluPerspective (scm_to_double (fovy), scm_to_double (aspect), scm_to_double (zNear), scm_to_double (zFar)); + return SCM_UNSPECIFIED; +} + +SCM +gacela_gluBuild2DMipmaps (SCM target, SCM internalFormat, SCM width, SCM height, SCM format, SCM type, SCM data) +{ + return scm_from_int (gluBuild2DMipmaps (scm_to_int (target), scm_to_int (internalFormat), scm_to_int (width), \ + scm_to_int (height), scm_to_int (format), scm_to_int (type), \ + (void *)scm_to_int (data))); +} + +SCM +gacela_gluLookAt (SCM eyeX, SCM eyeY, SCM eyeZ, SCM centerX, SCM centerY, SCM centerZ, SCM upX, SCM upY, SCM upZ) +{ + gluLookAt (scm_to_double (eyeX), scm_to_double (eyeY), scm_to_double (eyeZ), \ + scm_to_double (centerX), scm_to_double (centerY), scm_to_double (centerZ), \ + scm_to_double (upX), scm_to_double (upY), scm_to_double (upZ)); + return SCM_UNSPECIFIED; +} + void* GL_register_functions (void* data) @@ -95,6 +359,40 @@ GL_register_functions (void* data) scm_c_define_gsubr ("glBegin", 1, 0, 0, gacela_glBegin); + scm_c_define_gsubr ("glClear", 1, 0, 0, gacela_glClear); + scm_c_define_gsubr ("glClearColor", 4, 0, 0, gacela_glClearColor); + scm_c_define_gsubr ("glClearDepth", 1, 0, 0, gacela_glClearDepth); + scm_c_define_gsubr ("glColor3f", 3, 0, 0, gacela_glColor3f); + scm_c_define_gsubr ("glColor4f", 4, 0, 0, gacela_glColor4f); + scm_c_define_gsubr ("glDepthFunc", 1, 0, 0, gacela_glDepthFunc); + scm_c_define_gsubr ("glEnable", 1, 0, 0, gacela_glEnable); + scm_c_define_gsubr ("glDisable", 1, 0, 0, gacela_glDisable); + scm_c_define_gsubr ("glEnd", 0, 0, 0, gacela_glEnd); + scm_c_define_gsubr ("glHint", 2, 0, 0, gacela_glHint); + scm_c_define_gsubr ("glLoadIdentity", 0, 0, 0, gacela_glLoadIdentity); + scm_c_define_gsubr ("glMatrixMode", 1, 0, 0, gacela_glMatrixMode); + scm_c_define_gsubr ("glRotatef", 4, 0, 0, gacela_glRotatef); + scm_c_define_gsubr ("glShadeModel", 1, 0, 0, gacela_glShadeModel); + scm_c_define_gsubr ("glTranslatef", 3, 0, 0, gacela_glTranslatef); + scm_c_define_gsubr ("glVertex2f", 2, 0, 0, gacela_glVertex2f); + scm_c_define_gsubr ("glVertex3f", 3, 0, 0, gacela_glVertex3f); + scm_c_define_gsubr ("glViewport", 4, 0, 0, gacela_glViewport); + scm_c_define_gsubr ("glGenTextures", 1, 0, 0, gacela_glGenTextures); + scm_c_define_gsubr ("glDeleteTextures", 2, 0, 0, gacela_glDeleteTextures); + scm_c_define_gsubr ("glBindTexture", 2, 0, 0, gacela_glBindTexture); + scm_c_define_gsubr ("glTexImage2D", 9, 0, 0, gacela_glTexImage2D); + scm_c_define_gsubr ("glTexParameteri", 3, 0, 0, gacela_glTexParameteri); + scm_c_define_gsubr ("glTexCoord2f", 2, 0, 0, gacela_glTexCoord2f); + scm_c_define_gsubr ("glLightfv", 3, 0, 0, gacela_glLightfv); + scm_c_define_gsubr ("glNormal3f", 3, 0, 0, gacela_glNormal3f); + scm_c_define_gsubr ("glBlendFunc", 2, 0, 0, gacela_glBlendFunc); + scm_c_define_gsubr ("glOrtho", 6, 0, 0, gacela_glOrtho); + scm_c_define_gsubr ("glPushMatrix", 0, 0, 0, gacela_glPushMatrix); + scm_c_define_gsubr ("glPopMatrix", 0, 0, 0, gacela_glPopMatrix); + + scm_c_define_gsubr ("gluPerspective", 4, 0, 0, gacela_gluPerspective); + scm_c_define_gsubr ("gluBuild2DMipmaps", 7, 0, 0, gacela_gluBuild2DMipmaps); + scm_c_define_gsubr ("gluLookAt", 9, 0, 0, gacela_gluLookAt); return NULL; }