Acme-MITHALDU-BleedingOpenGL
view release on metacpan or search on metacpan
pogl_glut.xs view on Meta::CPAN
/* Last saved: Tue 02 Apr 2013 02:45:10 PM */
/* Copyright (c) 1998 Kenneth Albanowski. All rights reserved.
* Copyright (c) 2007 Bob Free. All rights reserved.
* Copyright (c) 2009 Chris Marshall. All rights reserved.
* Copyright (c) 2015 Bob Free. All rights reserved.
* This program is free software; you can redistribute it and/or
* modify it under the same terms as Perl itself.
*/
#include <stdio.h>
#include "pgopogl.h"
/* glut_util.h is where you include the appropriate GLUT header
* file based on what is available. It also defines some constants
* that may not be defined everywhere. Replace this by user
* specified include information for the include and compile-time
* perl constants rather than some special cases
*/
#include "glut_util.h"
/* TODO: calculate this from the actual GLUT include file */
#ifndef GLUT_API_VERSION
#define GLUT_API_VERSION 4
#endif
static int _done_glutInit = 0;
static int _done_glutCloseFunc_warn = 0;
/* Macros for GLUT callback and handler declarations */
# define DO_perl_call_sv(handler, flag) perl_call_sv(handler, flag)
# define ENSURE_callback_thread
# define GLUT_PUSH_NEW_SV(sv) XPUSHs(sv_2mortal(newSVsv(sv)))
# define GLUT_PUSH_NEW_IV(i) XPUSHs(sv_2mortal(newSViv(i)))
# define GLUT_PUSH_NEW_U8(c) XPUSHs(sv_2mortal(newSViv((int)c)))
# define GLUT_EXTEND_STACK(sp,n)
# define GLUT_PUSHMARK(sp) PUSHMARK(sp)
/* Set up for all the GLUT callback handlers */
static AV * glut_handlers = 0;
/* Attach a handler to a window */
static void set_glut_win_handler(int win, int type, SV * data)
{
SV ** h;
AV * a;
if (!glut_handlers)
glut_handlers = newAV();
h = av_fetch(glut_handlers, win, FALSE);
if (!h) {
a = newAV();
av_store(glut_handlers, win, newRV_inc((SV*)a));
SvREFCNT_dec(a);
} else if (!SvOK(*h) || !SvROK(*h))
croak("Unable to establish glut handler");
else
a = (AV*)SvRV(*h);
av_store(a, type, newRV_inc(data));
SvREFCNT_dec(data);
}
/* Get a window's handler */
static SV * get_glut_win_handler(int win, int type)
{
SV ** h;
if (!glut_handlers)
croak("Unable to locate glut handler");
h = av_fetch(glut_handlers, win, FALSE);
if (!h || !SvOK(*h) || !SvROK(*h))
croak("Unable to locate glut handler");
h = av_fetch((AV*)SvRV(*h), type, FALSE);
if (!h || !SvOK(*h) || !SvROK(*h))
croak("Unable to locate glut handler");
return SvRV(*h);
}
/* Release a window's handlers */
static void destroy_glut_win_handlers(int win)
{
SV ** h;
pogl_glut.xs view on Meta::CPAN
#//# float glutStrokeLength (void *font, const unsigned char *string)
GLfloat
glutStrokeLength(font, string)
void * font
const unsigned char * string
CODE:
{
#if defined HAVE_FREEGLUT
glutStrokeLength(font, string);
#endif
}
OUTPUT:
RETVAL
#//# void glutStrokeString (void *fontID, const unsigned char *string)
void
glutStrokeString(font, string)
void * font
const unsigned char * string
CODE:
{
#if defined HAVE_FREEGLUT
glutStrokeString(font, string);
#endif
}
#//# void glutWarpPointer (int x, int y)
void
glutWarpPointer(x, y)
int x
int y
#//# void glutWireCylinder (GLdouble radius, GLdouble height, GLint slices, GLint stacks)
void
glutWireCylinder(radius, height, slices, stacks)
GLdouble radius
GLdouble height
GLint slices
GLint stacks
CODE:
{
#if defined HAVE_FREEGLUT
glutWireCylinder(radius, height, slices, stacks);
#endif
}
#//# void glutWireRhombicDodecahedron (void)
void
glutWireRhombicDodecahedron()
CODE:
{
#if defined HAVE_FREEGLUT
glutWireRhombicDodecahedron();
#endif
}
#endif
# /* FreeGLUT APIs */
#//# glutSetOption($option_flag, $value);
void
glutSetOption(option_flag, value)
GLenum option_flag
int value
CODE:
{
#if defined HAVE_FREEGLUT
glutSetOption(option_flag, value);
#endif
}
#//# glutLeaveMainLoop();
void
glutLeaveMainLoop()
CODE:
{
#if defined HAVE_FREEGLUT
glutLeaveMainLoop();
#else
int win = glutGetWindow();
glutDestroyWindow(win);
destroy_glut_win_handlers(win);
#endif
}
#//# glutMenuDestroyFunc(\&callback);
void
glutMenuDestroyFunc(handler=0, ...)
SV * handler
CODE:
{
#if defined HAVE_FREEGLUT
decl_gwh_xs(MenuDestroy)
#endif
}
#//# glutCloseFunc(\&callback);
void
glutCloseFunc(handler=0, ...)
SV * handler
CODE:
{
if (_done_glutCloseFunc_warn == 0) {
warn("glutCloseFunc: not implemented\n");
_done_glutCloseFunc_warn++;
}
}
#ifdef HAVE_FREEGLUT
#//# glutInitContextVersion($majorVersion, $minorVersion);
void
glutInitContextVersion(majorVersion, minorVersion)
int majorVersion
int minorVersion
CODE:
{
glutInitContextVersion(majorVersion, minorVersion);
}
#//# glutInitContextFlags($flags);
void
glutInitContextFlags(flags)
int flags
CODE:
{
glutInitContextFlags(flags);
}
#//# glutInitContextProfile($profile);
void
glutInitContextProfile(profile)
int profile
CODE:
{
glutInitContextProfile(profile);
}
#endif
( run in 1.996 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )