h -> hpp, project file update

git-svn-id: https://projectm.svn.sourceforge.net/svnroot/projectm/personal/carm/dev-1.0@256 6778bc44-b910-0410-a7a0-be141de4315d
This commit is contained in:
w1z7ard
2007-07-08 23:02:20 +00:00
parent 268133cbee
commit b88d33d290
10 changed files with 2991 additions and 2991 deletions

View File

@ -29,11 +29,11 @@
#include <windows.h>
#endif
#include <projectM-engine/carbontoprojectM.h>
#include <projectM-engine/carbontoprojectM.hpp>
#include <projectM-engine/Common.hpp>
#include <projectM-engine/BeatDetect.h>
#include <projectM-engine/PCM.h>
#include <projectM-engine/projectM.h>
#include <projectM-engine/BeatDetect.hpp>
#include <projectM-engine/PCM.hpp>
#include <projectM-engine/projectM.hpp>
//#include <projectM-engine/menu.h>
#ifdef WIN32

View File

@ -1,390 +1,390 @@
#include <iostream>
using namespace std;
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <math.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <libvisual/libvisual.h>
#include <libprojectM/BeatDetect.h>
#include <libprojectM/PCM.h>
#include <libprojectM/projectM.h>
#include <libprojectM/console_interface.h>
#include "lvtoprojectM.h"
#if HAVE_CONFIG_H
#include <config.h>
#endif
#define CONFIG_FILE "/config"
#define PRESETS_DIR "/presets"
#define FONTS_DIR "/fonts"
void read_config();
int texsize=512;
int gx=32,gy=24;
int wvw=512,wvh=512;
int fvw=1024,fvh=768;
int fps=30, fullscreen=0;
/* Private context sensitive data goes here, */
typedef struct {
projectM *PM;
} ProjectmPrivate;
extern "C" int lv_projectm_init (VisPluginData *plugin);
extern "C" int lv_projectm_cleanup (VisPluginData *plugin);
extern "C" int lv_projectm_requisition (VisPluginData *plugin, int *width, int *height);
extern "C" int lv_projectm_dimension (VisPluginData *plugin, VisVideo *video, int width, int height);
extern "C" int lv_projectm_events (VisPluginData *plugin, VisEventQueue *events);
extern "C" VisPalette *lv_projectm_palette (VisPluginData *plugin);
extern "C" int lv_projectm_render (VisPluginData *plugin, VisVideo *video, VisAudio *audio);
VISUAL_PLUGIN_API_VERSION_VALIDATOR
/* Main plugin stuff */
/* The get_plugin_info function provides the libvisual plugin registry, and plugin loader
* with the very basic plugin information */
extern "C" const VisPluginInfo *get_plugin_info (int *count)
{
/* Initialize the plugin specific data structure
* with pointers to the functions that represent
* the plugin interface it's implementation, more info:
* http://libvisual.sourceforge.net/newdocs/docs/html/struct__VisActorPlugin.html */
static VisActorPlugin actor[1];
static VisPluginInfo info[1];
actor[0].requisition = lv_projectm_requisition;
actor[0].palette = lv_projectm_palette;
actor[0].render = lv_projectm_render;
actor[0].vidoptions.depth = VISUAL_VIDEO_DEPTH_GL; /* We want GL clearly */
info[0].type = VISUAL_PLUGIN_TYPE_ACTOR;
info[0].plugname = "projectM";
info[0].name = "libvisual projectM";
info[0].author = "Peter Sperl";
info[0].version = "1.00";
info[0].about = "projectM";
info[0].help = "";
info[0].init = lv_projectm_init;
info[0].cleanup = lv_projectm_cleanup;
info[0].events = lv_projectm_events;
info[0].plugin = VISUAL_OBJECT (&actor[0]);
*count = sizeof (info) / sizeof (*info);
VISUAL_VIDEO_ATTRIBUTE_OPTIONS_GL_ENTRY(actor[0].vidoptions, VISUAL_GL_ATTRIBUTE_ALPHA_SIZE, 8);
VISUAL_VIDEO_ATTRIBUTE_OPTIONS_GL_ENTRY(actor[0].vidoptions, VISUAL_GL_ATTRIBUTE_DEPTH_SIZE, 16);
VISUAL_VIDEO_ATTRIBUTE_OPTIONS_GL_ENTRY(actor[0].vidoptions, VISUAL_GL_ATTRIBUTE_DOUBLEBUFFER, 1);
VISUAL_VIDEO_ATTRIBUTE_OPTIONS_GL_ENTRY(actor[0].vidoptions, VISUAL_GL_ATTRIBUTE_RED_SIZE, 8);
VISUAL_VIDEO_ATTRIBUTE_OPTIONS_GL_ENTRY(actor[0].vidoptions, VISUAL_GL_ATTRIBUTE_GREEN_SIZE, 8);
VISUAL_VIDEO_ATTRIBUTE_OPTIONS_GL_ENTRY(actor[0].vidoptions, VISUAL_GL_ATTRIBUTE_BLUE_SIZE, 8);
return info;
}
/* This function is called before we really start rendering, it's the init function */
extern "C" int lv_projectm_init (VisPluginData *plugin)
{
char projectM_data[1024];
ProjectmPrivate *priv;
read_config();
/* Allocate the projectm private data structure, and register it as a private */
priv = new ProjectmPrivate;
visual_mem_set (priv, 0, sizeof (ProjectmPrivate));
//priv = visual_mem_new0 (ProjectmPrivate, 1);
visual_object_set_private (VISUAL_OBJECT (plugin), priv);
//FIXME
priv->PM = visual_mem_new0 (projectM, 1);
//globalPM = (projectM *)wipemalloc( sizeof( projectM ) );
priv->PM->projectM_reset();
//projectM_reset( globalPM );
priv->PM->fullscreen = 0; //fullscreen;
priv->PM->renderTarget->texsize = texsize;
priv->PM->renderTarget->usePbuffers = 1;
priv->PM->gx=gx;
priv->PM->gy=gy;
priv->PM->fps=fps;
strcpy(projectM_data, PROJECTM_DATADIR);
strcpy(projectM_data+strlen(PROJECTM_DATADIR), FONTS_DIR);
projectM_data[strlen(PROJECTM_DATADIR)+strlen(FONTS_DIR)]='\0';
priv->PM->fontURL = (char *)malloc( sizeof( char ) * 512 );
strcpy( priv->PM->fontURL, projectM_data );
strcpy(projectM_data+strlen(PROJECTM_DATADIR), PRESETS_DIR);
projectM_data[strlen(PROJECTM_DATADIR)+strlen(PRESETS_DIR)]='\0';
priv->PM->presetURL = (char *)malloc( sizeof( char ) * 512 );
strcpy( priv->PM->presetURL, projectM_data );
priv->PM->projectM_init();
priv->PM->projectM_resetGL( wvw, wvh );
return 0;
}
extern "C" int lv_projectm_cleanup (VisPluginData *plugin)
{
ProjectmPrivate *priv = (ProjectmPrivate*)visual_object_get_private (VISUAL_OBJECT (plugin));
/* Cleanup, and thus also free our private */
visual_mem_free (priv->PM);
visual_mem_free (priv);
return 0;
}
/* This is used to ask a plugin if it can handle a certain size, and if not, to
* set the size it wants by putting a value in width, height that represents the
* required size */
extern "C" int lv_projectm_requisition (VisPluginData *plugin, int *width, int *height)
{
int reqw, reqh;
/* Size negotiate with the window */
reqw = *width;
reqh = *height;
if (reqw < 64)
reqw = 64;
if (reqh < 64)
reqh = 64;
*width = reqw;
*height = reqh;
return 0;
}
extern "C" int lv_projectm_dimension (VisPluginData *plugin, VisVideo *video, int width, int height)
{
ProjectmPrivate *priv = (ProjectmPrivate*)visual_object_get_private (VISUAL_OBJECT (plugin));
visual_video_set_dimension (video, width, height);
priv->PM->projectM_resetGL( width, height );
return 0;
}
/* This is the main event loop, where all kind of events can be handled, more information
* regarding these can be found at:
* http://libvisual.sourceforge.net/newdocs/docs/html/union__VisEvent.html
*/
extern "C" int lv_projectm_events (VisPluginData *plugin, VisEventQueue *events)
{
ProjectmPrivate *priv = (ProjectmPrivate*)visual_object_get_private (VISUAL_OBJECT (plugin));
VisEvent ev;
VisParamEntry *param;
projectMEvent evt;
projectMKeycode key;
projectMModifier mod;
while (visual_event_queue_poll (events, &ev))
{
switch (ev.type)
{
case VISUAL_EVENT_KEYUP:
evt = lv2pmEvent( ev.type );
key = lv2pmKeycode( ev.event.keyboard.keysym.sym );
mod = lv2pmModifier( ev.event.keyboard.keysym.mod );
priv->PM->key_handler(PROJECTM_KEYDOWN, key,mod);
break;
case VISUAL_EVENT_RESIZE:
lv_projectm_dimension (plugin, ev.event.resize.video,
ev.event.resize.width, ev.event.resize.height);
break;
default: /* to avoid warnings */
break;
}
}
return 0;
}
/* Using this function we can update the palette when we're in 8bits mode, which
* we aren't with projectm, so just ignore :) */
extern "C" VisPalette *lv_projectm_palette (VisPluginData *plugin)
{
return NULL;
}
/* This is where the real rendering happens! This function is what we call, many times
* a second to get our graphical frames. */
extern "C" int lv_projectm_render (VisPluginData *plugin, VisVideo *video, VisAudio *audio)
{
ProjectmPrivate *priv = (ProjectmPrivate*)visual_object_get_private (VISUAL_OBJECT (plugin));
VisBuffer pcmb;
float pcm[2][512];
//short pcms[2][512];
int i;
visual_buffer_set_data_pair (&pcmb, pcm[0], sizeof (pcm[0]));
visual_audio_get_sample (audio, &pcmb, VISUAL_AUDIO_CHANNEL_LEFT);
visual_buffer_set_data_pair (&pcmb, pcm[1], sizeof (pcm[1]));
visual_audio_get_sample (audio, &pcmb, VISUAL_AUDIO_CHANNEL_RIGHT);
/*
for (i = 0; i < 512; i++) {
pcms[0][i] = pcm[0][i] * 32768.0;
pcms[1][i] = pcm[1][i] * 32768.0;
}
addPCM16Data(pcms,512);
*/
priv->PM->beatDetect->pcm->addPCMfloat(*pcm,512);
priv->PM->renderFrame();
return 0;
}
void read_config()
{
int n;
char num[80];
FILE *in;
FILE *out;
char* home;
char projectM_home[1024];
char projectM_config[1024];
strcpy(projectM_config, PROJECTM_DATADIR);
strcpy(projectM_config+strlen(PROJECTM_DATADIR), CONFIG_FILE);
projectM_config[strlen(PROJECTM_DATADIR)+strlen(CONFIG_FILE)]='\0';
home=getenv("HOME");
strcpy(projectM_home, home);
strcpy(projectM_home+strlen(home), "/.projectM/config");
projectM_home[strlen(home)+strlen("/.projectM/config")]='\0';
if ((in = fopen(projectM_home, "r")) != 0)
{
printf("reading ~/.projectM/config \n");
}
else
{
printf("trying to create ~/.projectM/config \n");
strcpy(projectM_home, home);
strcpy(projectM_home+strlen(home), "/.projectM");
projectM_home[strlen(home)+strlen("/.projectM")]='\0';
mkdir(projectM_home,0755);
strcpy(projectM_home, home);
strcpy(projectM_home+strlen(home), "/.projectM/config");
projectM_home[strlen(home)+strlen("/.projectM/config")]='\0';
if((out = fopen(projectM_home,"w"))!=0)
{
if ((in = fopen(projectM_config, "r")) != 0)
{
while(fgets(num,80,in)!=NULL)
{
fputs(num,out);
}
fclose(in);
fclose(out);
if ((in = fopen(projectM_home, "r")) != 0)
{ printf("created ~/.projectM/config successfully\n"); }
else{printf("This shouldn't happen, using implementation defualts\n");return;}
}
else{printf("Cannot find projectM default config, using implementation defaults\n");return;}
}
else
{
printf("Cannot create ~/.projectM/config, using default config file\n");
if ((in = fopen(projectM_config, "r")) != 0)
{ printf("Successfully opened default config file\n");}
else{ printf("Using implementation defaults, your system is really messed up, I'm suprised we even got this far\n"); return;}
}
}
fgets(num, 80, in); fgets(num, 80, in); fgets(num, 80, in);
if(fgets(num, 80, in) != NULL) sscanf (num, "%d", &texsize);
fgets(num, 80, in);
if(fgets(num, 80, in) != NULL) sscanf (num, "%d", &gx);
fgets(num, 80, in);
if(fgets(num, 80, in) != NULL) sscanf (num, "%d", &gy);
fgets(num, 80, in);
if(fgets(num, 80, in) != NULL) sscanf (num, "%d", &wvw);
fgets(num, 80, in);
if(fgets(num, 80, in) != NULL) sscanf (num, "%d", &wvh);
fgets(num, 80, in);
if(fgets(num, 80, in) != NULL) sscanf (num, "%d", &fvw);
fgets(num, 80, in);
if(fgets(num, 80, in) != NULL) sscanf (num, "%d", &fvh);
fgets(num, 80, in);
if(fgets(num, 80, in) != NULL) sscanf (num, "%d", &fps);
fgets(num, 80, in);
if(fgets(num, 80, in) != NULL) sscanf (num, "%d", &fullscreen);
/*
fgets(num, 80, in);
fgets(num, 80, in);
n=0;
while (num[n]!=' ' && num[n]!='\n' && n < 80 && num[n]!=EOF)
{
disp[n]=num[n];
n++;
}
disp[n]=0;
// sprintf(disp,"%s",num );
setenv("DISPLAY",disp,1);
printf("%s %d\n", disp,strlen(disp));
setenv("LD_PRELOAD", "/usr/lib/tls/libGL.so.1.0.4496", 1);
*/
fclose(in);
}
#include <iostream>
using namespace std;
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <math.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <libvisual/libvisual.h>
#include <libprojectM/BeatDetect.hpp>
#include <libprojectM/PCM.hpp>
#include <libprojectM/projectM.hpp>
#include <libprojectM/console_interface.h>
#include "lvtoprojectM.hpp"
#if HAVE_CONFIG_H
#include <config.h>
#endif
#define CONFIG_FILE "/config"
#define PRESETS_DIR "/presets"
#define FONTS_DIR "/fonts"
void read_config();
int texsize=512;
int gx=32,gy=24;
int wvw=512,wvh=512;
int fvw=1024,fvh=768;
int fps=30, fullscreen=0;
/* Private context sensitive data goes here, */
typedef struct {
projectM *PM;
} ProjectmPrivate;
extern "C" int lv_projectm_init (VisPluginData *plugin);
extern "C" int lv_projectm_cleanup (VisPluginData *plugin);
extern "C" int lv_projectm_requisition (VisPluginData *plugin, int *width, int *height);
extern "C" int lv_projectm_dimension (VisPluginData *plugin, VisVideo *video, int width, int height);
extern "C" int lv_projectm_events (VisPluginData *plugin, VisEventQueue *events);
extern "C" VisPalette *lv_projectm_palette (VisPluginData *plugin);
extern "C" int lv_projectm_render (VisPluginData *plugin, VisVideo *video, VisAudio *audio);
VISUAL_PLUGIN_API_VERSION_VALIDATOR
/* Main plugin stuff */
/* The get_plugin_info function provides the libvisual plugin registry, and plugin loader
* with the very basic plugin information */
extern "C" const VisPluginInfo *get_plugin_info (int *count)
{
/* Initialize the plugin specific data structure
* with pointers to the functions that represent
* the plugin interface it's implementation, more info:
* http://libvisual.sourceforge.net/newdocs/docs/html/struct__VisActorPlugin.html */
static VisActorPlugin actor[1];
static VisPluginInfo info[1];
actor[0].requisition = lv_projectm_requisition;
actor[0].palette = lv_projectm_palette;
actor[0].render = lv_projectm_render;
actor[0].vidoptions.depth = VISUAL_VIDEO_DEPTH_GL; /* We want GL clearly */
info[0].type = VISUAL_PLUGIN_TYPE_ACTOR;
info[0].plugname = "projectM";
info[0].name = "libvisual projectM";
info[0].author = "Peter Sperl";
info[0].version = "1.00";
info[0].about = "projectM";
info[0].help = "";
info[0].init = lv_projectm_init;
info[0].cleanup = lv_projectm_cleanup;
info[0].events = lv_projectm_events;
info[0].plugin = VISUAL_OBJECT (&actor[0]);
*count = sizeof (info) / sizeof (*info);
VISUAL_VIDEO_ATTRIBUTE_OPTIONS_GL_ENTRY(actor[0].vidoptions, VISUAL_GL_ATTRIBUTE_ALPHA_SIZE, 8);
VISUAL_VIDEO_ATTRIBUTE_OPTIONS_GL_ENTRY(actor[0].vidoptions, VISUAL_GL_ATTRIBUTE_DEPTH_SIZE, 16);
VISUAL_VIDEO_ATTRIBUTE_OPTIONS_GL_ENTRY(actor[0].vidoptions, VISUAL_GL_ATTRIBUTE_DOUBLEBUFFER, 1);
VISUAL_VIDEO_ATTRIBUTE_OPTIONS_GL_ENTRY(actor[0].vidoptions, VISUAL_GL_ATTRIBUTE_RED_SIZE, 8);
VISUAL_VIDEO_ATTRIBUTE_OPTIONS_GL_ENTRY(actor[0].vidoptions, VISUAL_GL_ATTRIBUTE_GREEN_SIZE, 8);
VISUAL_VIDEO_ATTRIBUTE_OPTIONS_GL_ENTRY(actor[0].vidoptions, VISUAL_GL_ATTRIBUTE_BLUE_SIZE, 8);
return info;
}
/* This function is called before we really start rendering, it's the init function */
extern "C" int lv_projectm_init (VisPluginData *plugin)
{
char projectM_data[1024];
ProjectmPrivate *priv;
read_config();
/* Allocate the projectm private data structure, and register it as a private */
priv = new ProjectmPrivate;
visual_mem_set (priv, 0, sizeof (ProjectmPrivate));
//priv = visual_mem_new0 (ProjectmPrivate, 1);
visual_object_set_private (VISUAL_OBJECT (plugin), priv);
//FIXME
priv->PM = visual_mem_new0 (projectM, 1);
//globalPM = (projectM *)wipemalloc( sizeof( projectM ) );
priv->PM->projectM_reset();
//projectM_reset( globalPM );
priv->PM->fullscreen = 0; //fullscreen;
priv->PM->renderTarget->texsize = texsize;
priv->PM->renderTarget->usePbuffers = 1;
priv->PM->gx=gx;
priv->PM->gy=gy;
priv->PM->fps=fps;
strcpy(projectM_data, PROJECTM_DATADIR);
strcpy(projectM_data+strlen(PROJECTM_DATADIR), FONTS_DIR);
projectM_data[strlen(PROJECTM_DATADIR)+strlen(FONTS_DIR)]='\0';
priv->PM->fontURL = (char *)malloc( sizeof( char ) * 512 );
strcpy( priv->PM->fontURL, projectM_data );
strcpy(projectM_data+strlen(PROJECTM_DATADIR), PRESETS_DIR);
projectM_data[strlen(PROJECTM_DATADIR)+strlen(PRESETS_DIR)]='\0';
priv->PM->presetURL = (char *)malloc( sizeof( char ) * 512 );
strcpy( priv->PM->presetURL, projectM_data );
priv->PM->projectM_init();
priv->PM->projectM_resetGL( wvw, wvh );
return 0;
}
extern "C" int lv_projectm_cleanup (VisPluginData *plugin)
{
ProjectmPrivate *priv = (ProjectmPrivate*)visual_object_get_private (VISUAL_OBJECT (plugin));
/* Cleanup, and thus also free our private */
visual_mem_free (priv->PM);
visual_mem_free (priv);
return 0;
}
/* This is used to ask a plugin if it can handle a certain size, and if not, to
* set the size it wants by putting a value in width, height that represents the
* required size */
extern "C" int lv_projectm_requisition (VisPluginData *plugin, int *width, int *height)
{
int reqw, reqh;
/* Size negotiate with the window */
reqw = *width;
reqh = *height;
if (reqw < 64)
reqw = 64;
if (reqh < 64)
reqh = 64;
*width = reqw;
*height = reqh;
return 0;
}
extern "C" int lv_projectm_dimension (VisPluginData *plugin, VisVideo *video, int width, int height)
{
ProjectmPrivate *priv = (ProjectmPrivate*)visual_object_get_private (VISUAL_OBJECT (plugin));
visual_video_set_dimension (video, width, height);
priv->PM->projectM_resetGL( width, height );
return 0;
}
/* This is the main event loop, where all kind of events can be handled, more information
* regarding these can be found at:
* http://libvisual.sourceforge.net/newdocs/docs/html/union__VisEvent.html
*/
extern "C" int lv_projectm_events (VisPluginData *plugin, VisEventQueue *events)
{
ProjectmPrivate *priv = (ProjectmPrivate*)visual_object_get_private (VISUAL_OBJECT (plugin));
VisEvent ev;
VisParamEntry *param;
projectMEvent evt;
projectMKeycode key;
projectMModifier mod;
while (visual_event_queue_poll (events, &ev))
{
switch (ev.type)
{
case VISUAL_EVENT_KEYUP:
evt = lv2pmEvent( ev.type );
key = lv2pmKeycode( ev.event.keyboard.keysym.sym );
mod = lv2pmModifier( ev.event.keyboard.keysym.mod );
priv->PM->key_handler(PROJECTM_KEYDOWN, key,mod);
break;
case VISUAL_EVENT_RESIZE:
lv_projectm_dimension (plugin, ev.event.resize.video,
ev.event.resize.width, ev.event.resize.height);
break;
default: /* to avoid warnings */
break;
}
}
return 0;
}
/* Using this function we can update the palette when we're in 8bits mode, which
* we aren't with projectm, so just ignore :) */
extern "C" VisPalette *lv_projectm_palette (VisPluginData *plugin)
{
return NULL;
}
/* This is where the real rendering happens! This function is what we call, many times
* a second to get our graphical frames. */
extern "C" int lv_projectm_render (VisPluginData *plugin, VisVideo *video, VisAudio *audio)
{
ProjectmPrivate *priv = (ProjectmPrivate*)visual_object_get_private (VISUAL_OBJECT (plugin));
VisBuffer pcmb;
float pcm[2][512];
//short pcms[2][512];
int i;
visual_buffer_set_data_pair (&pcmb, pcm[0], sizeof (pcm[0]));
visual_audio_get_sample (audio, &pcmb, VISUAL_AUDIO_CHANNEL_LEFT);
visual_buffer_set_data_pair (&pcmb, pcm[1], sizeof (pcm[1]));
visual_audio_get_sample (audio, &pcmb, VISUAL_AUDIO_CHANNEL_RIGHT);
/*
for (i = 0; i < 512; i++) {
pcms[0][i] = pcm[0][i] * 32768.0;
pcms[1][i] = pcm[1][i] * 32768.0;
}
addPCM16Data(pcms,512);
*/
priv->PM->beatDetect->pcm->addPCMfloat(*pcm,512);
priv->PM->renderFrame();
return 0;
}
void read_config()
{
int n;
char num[80];
FILE *in;
FILE *out;
char* home;
char projectM_home[1024];
char projectM_config[1024];
strcpy(projectM_config, PROJECTM_DATADIR);
strcpy(projectM_config+strlen(PROJECTM_DATADIR), CONFIG_FILE);
projectM_config[strlen(PROJECTM_DATADIR)+strlen(CONFIG_FILE)]='\0';
home=getenv("HOME");
strcpy(projectM_home, home);
strcpy(projectM_home+strlen(home), "/.projectM/config");
projectM_home[strlen(home)+strlen("/.projectM/config")]='\0';
if ((in = fopen(projectM_home, "r")) != 0)
{
printf("reading ~/.projectM/config \n");
}
else
{
printf("trying to create ~/.projectM/config \n");
strcpy(projectM_home, home);
strcpy(projectM_home+strlen(home), "/.projectM");
projectM_home[strlen(home)+strlen("/.projectM")]='\0';
mkdir(projectM_home,0755);
strcpy(projectM_home, home);
strcpy(projectM_home+strlen(home), "/.projectM/config");
projectM_home[strlen(home)+strlen("/.projectM/config")]='\0';
if((out = fopen(projectM_home,"w"))!=0)
{
if ((in = fopen(projectM_config, "r")) != 0)
{
while(fgets(num,80,in)!=NULL)
{
fputs(num,out);
}
fclose(in);
fclose(out);
if ((in = fopen(projectM_home, "r")) != 0)
{ printf("created ~/.projectM/config successfully\n"); }
else{printf("This shouldn't happen, using implementation defualts\n");return;}
}
else{printf("Cannot find projectM default config, using implementation defaults\n");return;}
}
else
{
printf("Cannot create ~/.projectM/config, using default config file\n");
if ((in = fopen(projectM_config, "r")) != 0)
{ printf("Successfully opened default config file\n");}
else{ printf("Using implementation defaults, your system is really messed up, I'm suprised we even got this far\n"); return;}
}
}
fgets(num, 80, in); fgets(num, 80, in); fgets(num, 80, in);
if(fgets(num, 80, in) != NULL) sscanf (num, "%d", &texsize);
fgets(num, 80, in);
if(fgets(num, 80, in) != NULL) sscanf (num, "%d", &gx);
fgets(num, 80, in);
if(fgets(num, 80, in) != NULL) sscanf (num, "%d", &gy);
fgets(num, 80, in);
if(fgets(num, 80, in) != NULL) sscanf (num, "%d", &wvw);
fgets(num, 80, in);
if(fgets(num, 80, in) != NULL) sscanf (num, "%d", &wvh);
fgets(num, 80, in);
if(fgets(num, 80, in) != NULL) sscanf (num, "%d", &fvw);
fgets(num, 80, in);
if(fgets(num, 80, in) != NULL) sscanf (num, "%d", &fvh);
fgets(num, 80, in);
if(fgets(num, 80, in) != NULL) sscanf (num, "%d", &fps);
fgets(num, 80, in);
if(fgets(num, 80, in) != NULL) sscanf (num, "%d", &fullscreen);
/*
fgets(num, 80, in);
fgets(num, 80, in);
n=0;
while (num[n]!=' ' && num[n]!='\n' && n < 80 && num[n]!=EOF)
{
disp[n]=num[n];
n++;
}
disp[n]=0;
// sprintf(disp,"%s",num );
setenv("DISPLAY",disp,1);
printf("%s %d\n", disp,strlen(disp));
setenv("LD_PRELOAD", "/usr/lib/tls/libGL.so.1.0.4496", 1);
*/
fclose(in);
}

View File

@ -1,156 +1,156 @@
/**
* projectM -- Milkdrop-esque visualisation SDK
* Copyright (C)2003-2007 projectM Team
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* See 'LICENSE.txt' included within this release
*
*/
/**
* $Id: sdltoprojectM.h,v 1.1 2004/10/08 00:35:28 cvs Exp $
*
* Translates SDL -> projectM variables
*
* $Log: sdltoprojectM.h,v $
* Revision 1.1 2004/10/08 00:35:28 cvs
* Moved and imported
*
* Revision 1.1.1.1 2004/10/04 12:56:00 cvs
* Imported
*
*/
#include <libvisual/libvisual.h>
projectMEvent lv2pmEvent( VisEventType event ) {
switch ( event ) {
case VISUAL_EVENT_RESIZE:
return PROJECTM_VIDEORESIZE;
case VISUAL_EVENT_KEYUP:
return PROJECTM_KEYUP;
case VISUAL_EVENT_KEYDOWN:
return PROJECTM_KEYDOWN;
default:
return PROJECTM_KEYUP;
}
}
projectMKeycode lv2pmKeycode( VisKey keysym )
{
switch ( keysym )
{
case VKEY_F1:
return PROJECTM_K_F1;
case VKEY_F2:
return PROJECTM_K_F2;
case VKEY_F3:
return PROJECTM_K_F3;
case VKEY_F4:
return PROJECTM_K_F4;
case VKEY_F5:
return PROJECTM_K_F5;
case VKEY_F6:
return PROJECTM_K_F6;
case VKEY_F7:
return PROJECTM_K_F7;
case VKEY_F8:
return PROJECTM_K_F8;
case VKEY_F9:
return PROJECTM_K_F9;
case VKEY_F10:
return PROJECTM_K_F10;
case VKEY_F11:
return PROJECTM_K_F11;
case VKEY_F12:
return PROJECTM_K_F12;
case VKEY_ESCAPE:
return PROJECTM_K_ESCAPE;
case VKEY_a:
return PROJECTM_K_a;
case VKEY_b:
return PROJECTM_K_b;
case VKEY_c:
return PROJECTM_K_c;
case VKEY_d:
return PROJECTM_K_d;
case VKEY_e:
return PROJECTM_K_e;
case VKEY_f:
return PROJECTM_K_f;
case VKEY_g:
return PROJECTM_K_g;
case VKEY_h:
return PROJECTM_K_h;
case VKEY_i:
return PROJECTM_K_i;
case VKEY_j:
return PROJECTM_K_j;
case VKEY_k:
return PROJECTM_K_k;
case VKEY_l:
return PROJECTM_K_l;
case VKEY_m:
return PROJECTM_K_m;
case VKEY_n:
return PROJECTM_K_n;
case VKEY_o:
return PROJECTM_K_o;
case VKEY_p:
return PROJECTM_K_p;
case VKEY_q:
return PROJECTM_K_q;
case VKEY_r:
return PROJECTM_K_r;
case VKEY_s:
return PROJECTM_K_s;
case VKEY_t:
return PROJECTM_K_t;
case VKEY_u:
return PROJECTM_K_u;
case VKEY_v:
return PROJECTM_K_v;
case VKEY_w:
return PROJECTM_K_w;
case VKEY_x:
return PROJECTM_K_x;
case VKEY_y:
return PROJECTM_K_y;
case VKEY_z:
return PROJECTM_K_z;
case VKEY_UP:
return PROJECTM_K_UP;
case VKEY_RETURN:
return PROJECTM_K_RETURN;
case VKEY_RIGHT:
return PROJECTM_K_RIGHT;
case VKEY_LEFT:
return PROJECTM_K_LEFT;
case VKEY_DOWN:
return PROJECTM_K_DOWN;
case VKEY_PAGEUP:
return PROJECTM_K_PAGEUP;
case VKEY_PAGEDOWN:
return PROJECTM_K_PAGEDOWN;
default:
return PROJECTM_K_NONE;
break;
}
}
projectMModifier lv2pmModifier( int mod ) {
return (projectMModifier) mod;
}
/**
* projectM -- Milkdrop-esque visualisation SDK
* Copyright (C)2003-2007 projectM Team
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* See 'LICENSE.txt' included within this release
*
*/
/**
* $Id: sdltoprojectM.hpp,v 1.1 2004/10/08 00:35:28 cvs Exp $
*
* Translates SDL -> projectM variables
*
* $Log: sdltoprojectM.hpp,v $
* Revision 1.1 2004/10/08 00:35:28 cvs
* Moved and imported
*
* Revision 1.1.1.1 2004/10/04 12:56:00 cvs
* Imported
*
*/
#include <libvisual/libvisual.h>
projectMEvent lv2pmEvent( VisEventType event ) {
switch ( event ) {
case VISUAL_EVENT_RESIZE:
return PROJECTM_VIDEORESIZE;
case VISUAL_EVENT_KEYUP:
return PROJECTM_KEYUP;
case VISUAL_EVENT_KEYDOWN:
return PROJECTM_KEYDOWN;
default:
return PROJECTM_KEYUP;
}
}
projectMKeycode lv2pmKeycode( VisKey keysym )
{
switch ( keysym )
{
case VKEY_F1:
return PROJECTM_K_F1;
case VKEY_F2:
return PROJECTM_K_F2;
case VKEY_F3:
return PROJECTM_K_F3;
case VKEY_F4:
return PROJECTM_K_F4;
case VKEY_F5:
return PROJECTM_K_F5;
case VKEY_F6:
return PROJECTM_K_F6;
case VKEY_F7:
return PROJECTM_K_F7;
case VKEY_F8:
return PROJECTM_K_F8;
case VKEY_F9:
return PROJECTM_K_F9;
case VKEY_F10:
return PROJECTM_K_F10;
case VKEY_F11:
return PROJECTM_K_F11;
case VKEY_F12:
return PROJECTM_K_F12;
case VKEY_ESCAPE:
return PROJECTM_K_ESCAPE;
case VKEY_a:
return PROJECTM_K_a;
case VKEY_b:
return PROJECTM_K_b;
case VKEY_c:
return PROJECTM_K_c;
case VKEY_d:
return PROJECTM_K_d;
case VKEY_e:
return PROJECTM_K_e;
case VKEY_f:
return PROJECTM_K_f;
case VKEY_g:
return PROJECTM_K_g;
case VKEY_h:
return PROJECTM_K_h;
case VKEY_i:
return PROJECTM_K_i;
case VKEY_j:
return PROJECTM_K_j;
case VKEY_k:
return PROJECTM_K_k;
case VKEY_l:
return PROJECTM_K_l;
case VKEY_m:
return PROJECTM_K_m;
case VKEY_n:
return PROJECTM_K_n;
case VKEY_o:
return PROJECTM_K_o;
case VKEY_p:
return PROJECTM_K_p;
case VKEY_q:
return PROJECTM_K_q;
case VKEY_r:
return PROJECTM_K_r;
case VKEY_s:
return PROJECTM_K_s;
case VKEY_t:
return PROJECTM_K_t;
case VKEY_u:
return PROJECTM_K_u;
case VKEY_v:
return PROJECTM_K_v;
case VKEY_w:
return PROJECTM_K_w;
case VKEY_x:
return PROJECTM_K_x;
case VKEY_y:
return PROJECTM_K_y;
case VKEY_z:
return PROJECTM_K_z;
case VKEY_UP:
return PROJECTM_K_UP;
case VKEY_RETURN:
return PROJECTM_K_RETURN;
case VKEY_RIGHT:
return PROJECTM_K_RIGHT;
case VKEY_LEFT:
return PROJECTM_K_LEFT;
case VKEY_DOWN:
return PROJECTM_K_DOWN;
case VKEY_PAGEUP:
return PROJECTM_K_PAGEUP;
case VKEY_PAGEDOWN:
return PROJECTM_K_PAGEDOWN;
default:
return PROJECTM_K_NONE;
break;
}
}
projectMModifier lv2pmModifier( int mod ) {
return (projectMModifier) mod;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,260 +1,260 @@
/**
* projectM -- Milkdrop-esque visualisation SDK
* Copyright (C)2003-2004 projectM Team
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* See 'LICENSE.txt' included within this release
*
*/
#include <math.h>
#include "projectM/projectM.h"
#include "event/sdltoprojectM.h"
#ifdef DEBUG
FILE *debugFile = NULL;
#endif
projectM_t *globalPM = NULL;
int dumpFrame = 0;
int frameNumber = 0;
GLubyte *fbuffer = NULL;
void renderLoop( projectM_t *pm, short pcm_data[2][512] ) {
int i;
int x, y;
int index;
/** Handle any keys... */
projectMEvent evt;
projectMKeycode key;
projectMModifier mod;
/** Process SDL events */
SDL_Event event;
while ( SDL_PollEvent( &event ) ) {
/** Translate into projectM codes and process */
evt = sdl2pmEvent( event );
key = sdl2pmKeycode( event.key.keysym.sym );
mod = sdl2pmModifier( event.key.keysym.mod );
if ( evt == PROJECTM_KEYDOWN ) {
key_handler( evt, key, mod );
}
}
/** Add the waveform data */
addPCM16( pcm_data );
/** Render the new frame */
renderFrame( pm );
if ( dumpFrame ) {
char fname[1024];
FILE *f;
sprintf( fname, "projectM_%08d.ppm", frameNumber++ );
f = fopen( fname, "wb" );
fprintf( f, "P3\n#\n%d %d\n255\n", pm->wvw, pm->wvh );
glReadPixels( 0, 0, pm->wvw, pm->wvh, GL_RGB, GL_UNSIGNED_BYTE, fbuffer );
index = 0;
for ( y = 0 ; y < pm->wvh ; y++ ) {
for ( x = 0 ; x < pm->wvw ; x++ ) {
fprintf( f, "%d %d %d ", fbuffer[index++], fbuffer[index++], fbuffer[index++] );
}
fprintf( f, "\n" );
}
fclose( f );
}
SDL_GL_SwapBuffers();
}
int main( int argc, char **argv ) {
/** Variables */
int fullscreen = 0;
int width = 512,
height = 512;
SDL_Surface *screen;
#ifdef DEBUG
int value;
int rgb_size[3];
#endif
const SDL_VideoInfo* info = NULL;
int bpp = 0;
/* Flags we will pass into SDL_SetVideoMode. */
int flags = 0;
#ifdef DEBUG
#ifdef WIN32
/** Init debug */
debugFile = fopen( "c:\\projectMvis.txt", "wb" );
#else
debugFile = fopen( "/tmp/projectMvis.txt", "wb" );
#endif /** WIN32 */
#endif /** DEBUG */
/** Allocate the SDL windows */
/* Information about the current video settings. */
/* First, initialize SDL's video subsystem. */
if( SDL_Init( SDL_INIT_VIDEO ) < 0 ) {
/* Failed, exit. */
#ifdef DEBUG
fprintf( debugFile, "Video initialization failed: %s\n",
SDL_GetError( ) );
#endif
//projectM_vtable.disable_plugin (&projectM_vtable);
return PROJECTM_ERROR;
}
/* Let's get some video information. */
info = SDL_GetVideoInfo( );
if( !info ) {
/* This should probably never happen. */
#ifdef DEBUG
fprintf( debugFile, "Video query failed: %s\n",
SDL_GetError( ) );
#endif
// projectM_vtable.disable_plugin (&projectM_vtable);
return PROJECTM_ERROR;
}
bpp = info->vfmt->BitsPerPixel;
// SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 5 );
// SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 5 );
// SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 5 );
SDL_GL_SetAttribute( SDL_GL_ACCUM_RED_SIZE, 8 );
SDL_GL_SetAttribute( SDL_GL_ACCUM_GREEN_SIZE, 8 );
SDL_GL_SetAttribute( SDL_GL_ACCUM_BLUE_SIZE, 8 );
SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, 8 );
SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 );
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
if (fullscreen==0)
flags = SDL_OPENGL | SDL_HWSURFACE;
else flags = SDL_OPENGL | SDL_HWSURFACE |SDL_FULLSCREEN;
// w = 512; h = 512; bpp = 16;
#ifdef DEBUG
fprintf( debugFile, "pre SDL_SetVideoMode()\n" );
#endif
screen = SDL_SetVideoMode( width, height, bpp, flags ) ;
#ifdef DEBUG
fprintf( debugFile, "post SDL_SetVideoMode()\n" );
#endif
if(screen == NULL ) {
/*
* This could happen for a variety of reasons,
* including DISPLAY not being set, the specified
* resolution not being available, etc.
*/
#ifdef DEBUG
fprintf( debugFile, "Video mode set failed: %s\n",
SDL_GetError( ) );
#endif
// projectM_vtable.disable_plugin (&projectM_vtable);
return PROJECTM_ERROR;
}
#ifdef DEBUG
fprintf(debugFile, "Screen BPP: %d\n", SDL_GetVideoSurface()->format->BitsPerPixel);
fprintf(debugFile, "\n");
fprintf( debugFile, "Vendor : %s\n", glGetString( GL_VENDOR ) );
fprintf( debugFile, "Renderer : %s\n", glGetString( GL_RENDERER ) );
fprintf( debugFile, "Version : %s\n", glGetString( GL_VERSION ) );
fprintf( debugFile, "Extensions : %s\n", glGetString( GL_EXTENSIONS ) );
fprintf(debugFile, "\n");
rgb_size[0] = 8;
rgb_size[1] = 8;
rgb_size[2] = 8;
SDL_GL_GetAttribute( SDL_GL_RED_SIZE, &value );
fprintf( debugFile, "SDL_GL_RED_SIZE: requested %d, got %d\n", rgb_size[0],value);
SDL_GL_GetAttribute( SDL_GL_GREEN_SIZE, &value );
fprintf( debugFile, "SDL_GL_GREEN_SIZE: requested %d, got %d\n", rgb_size[1],value);
SDL_GL_GetAttribute( SDL_GL_BLUE_SIZE, &value );
fprintf( debugFile, "SDL_GL_BLUE_SIZE: requested %d, got %d\n", rgb_size[2],value);
SDL_GL_GetAttribute( SDL_GL_DEPTH_SIZE, &value );
fprintf( debugFile, "SDL_GL_DEPTH_SIZE: requested %d, got %d\n", bpp, value );
SDL_GL_GetAttribute( SDL_GL_DOUBLEBUFFER, &value );
fprintf( debugFile, "SDL_GL_DOUBLEBUFFER: requested 1, got %d\n", value );
#ifdef PANTS
if ( fsaa ) {
SDL_GL_GetAttribute( SDL_GL_MULTISAMPLEBUFFERS, &value );
printf( "SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value );
SDL_GL_GetAttribute( SDL_GL_MULTISAMPLESAMPLES, &value );
printf( "SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa, value );
}
#endif
#endif
/** Setup some window stuff */
SDL_WM_SetCaption( PROJECTM_TITLE, NULL );
/** Initialise projectM */
globalPM = (projectM_t *)malloc( sizeof( projectM_t ) );
projectM_reset( globalPM );
globalPM->fullscreen = 0;
globalPM->renderTarget->texsize = 1024;
// globalPM->renderTarget->origCcontext = (void *)aglGetCurrentContext();
#ifdef DEBUG
if ( debugFile != NULL ) {
fprintf( debugFile, "current context: %X\n",
globalPM->renderTarget->origContext );
fflush( debugFile );
}
#endif
#ifdef MACOS
globalPM->fontURL = (char *)malloc( sizeof( char ) * 512 );
strcpy( globalPM->fontURL, "../../fonts" );
globalPM->presetURL = (char *)malloc( sizeof( char ) * 512 );
strcpy( globalPM->presetURL, "../../presets" );
#else
globalPM->fontURL = (char *)malloc( sizeof( char ) * 512 );
strcpy( globalPM->fontURL, "c:\\tmp\\projectM\\fonts" );
globalPM->presetURL = (char *)malloc( sizeof( char ) * 512 );
strcpy( globalPM->presetURL, "c:\\tmp\\projectM\\presets_test" );
#endif /** MACOS */
projectM_init( globalPM );
projectM_resetGL( globalPM, width, height );
/** Allocate the buffer for frame dumping, if applicable */
if ( dumpFrame ) {
fbuffer = (GLubyte *)malloc( sizeof( GLubyte ) * globalPM->wvw * globalPM->wvh * 3 );
}
/** Initialise the thread */
// renderLoop( globalPM );
main123( argc, argv );
return PROJECTM_SUCCESS;
}
/**
* projectM -- Milkdrop-esque visualisation SDK
* Copyright (C)2003-2004 projectM Team
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* See 'LICENSE.txt' included within this release
*
*/
#include <math.h>
#include "projectM/projectM.hpp"
#include "event/sdltoprojectM.hpp"
#ifdef DEBUG
FILE *debugFile = NULL;
#endif
projectM_t *globalPM = NULL;
int dumpFrame = 0;
int frameNumber = 0;
GLubyte *fbuffer = NULL;
void renderLoop( projectM_t *pm, short pcm_data[2][512] ) {
int i;
int x, y;
int index;
/** Handle any keys... */
projectMEvent evt;
projectMKeycode key;
projectMModifier mod;
/** Process SDL events */
SDL_Event event;
while ( SDL_PollEvent( &event ) ) {
/** Translate into projectM codes and process */
evt = sdl2pmEvent( event );
key = sdl2pmKeycode( event.key.keysym.sym );
mod = sdl2pmModifier( event.key.keysym.mod );
if ( evt == PROJECTM_KEYDOWN ) {
key_handler( evt, key, mod );
}
}
/** Add the waveform data */
addPCM16( pcm_data );
/** Render the new frame */
renderFrame( pm );
if ( dumpFrame ) {
char fname[1024];
FILE *f;
sprintf( fname, "projectM_%08d.ppm", frameNumber++ );
f = fopen( fname, "wb" );
fprintf( f, "P3\n#\n%d %d\n255\n", pm->wvw, pm->wvh );
glReadPixels( 0, 0, pm->wvw, pm->wvh, GL_RGB, GL_UNSIGNED_BYTE, fbuffer );
index = 0;
for ( y = 0 ; y < pm->wvh ; y++ ) {
for ( x = 0 ; x < pm->wvw ; x++ ) {
fprintf( f, "%d %d %d ", fbuffer[index++], fbuffer[index++], fbuffer[index++] );
}
fprintf( f, "\n" );
}
fclose( f );
}
SDL_GL_SwapBuffers();
}
int main( int argc, char **argv ) {
/** Variables */
int fullscreen = 0;
int width = 512,
height = 512;
SDL_Surface *screen;
#ifdef DEBUG
int value;
int rgb_size[3];
#endif
const SDL_VideoInfo* info = NULL;
int bpp = 0;
/* Flags we will pass into SDL_SetVideoMode. */
int flags = 0;
#ifdef DEBUG
#ifdef WIN32
/** Init debug */
debugFile = fopen( "c:\\projectMvis.txt", "wb" );
#else
debugFile = fopen( "/tmp/projectMvis.txt", "wb" );
#endif /** WIN32 */
#endif /** DEBUG */
/** Allocate the SDL windows */
/* Information about the current video settings. */
/* First, initialize SDL's video subsystem. */
if( SDL_Init( SDL_INIT_VIDEO ) < 0 ) {
/* Failed, exit. */
#ifdef DEBUG
fprintf( debugFile, "Video initialization failed: %s\n",
SDL_GetError( ) );
#endif
//projectM_vtable.disable_plugin (&projectM_vtable);
return PROJECTM_ERROR;
}
/* Let's get some video information. */
info = SDL_GetVideoInfo( );
if( !info ) {
/* This should probably never happen. */
#ifdef DEBUG
fprintf( debugFile, "Video query failed: %s\n",
SDL_GetError( ) );
#endif
// projectM_vtable.disable_plugin (&projectM_vtable);
return PROJECTM_ERROR;
}
bpp = info->vfmt->BitsPerPixel;
// SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 5 );
// SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 5 );
// SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 5 );
SDL_GL_SetAttribute( SDL_GL_ACCUM_RED_SIZE, 8 );
SDL_GL_SetAttribute( SDL_GL_ACCUM_GREEN_SIZE, 8 );
SDL_GL_SetAttribute( SDL_GL_ACCUM_BLUE_SIZE, 8 );
SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, 8 );
SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 );
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
if (fullscreen==0)
flags = SDL_OPENGL | SDL_HWSURFACE;
else flags = SDL_OPENGL | SDL_HWSURFACE |SDL_FULLSCREEN;
// w = 512; h = 512; bpp = 16;
#ifdef DEBUG
fprintf( debugFile, "pre SDL_SetVideoMode()\n" );
#endif
screen = SDL_SetVideoMode( width, height, bpp, flags ) ;
#ifdef DEBUG
fprintf( debugFile, "post SDL_SetVideoMode()\n" );
#endif
if(screen == NULL ) {
/*
* This could happen for a variety of reasons,
* including DISPLAY not being set, the specified
* resolution not being available, etc.
*/
#ifdef DEBUG
fprintf( debugFile, "Video mode set failed: %s\n",
SDL_GetError( ) );
#endif
// projectM_vtable.disable_plugin (&projectM_vtable);
return PROJECTM_ERROR;
}
#ifdef DEBUG
fprintf(debugFile, "Screen BPP: %d\n", SDL_GetVideoSurface()->format->BitsPerPixel);
fprintf(debugFile, "\n");
fprintf( debugFile, "Vendor : %s\n", glGetString( GL_VENDOR ) );
fprintf( debugFile, "Renderer : %s\n", glGetString( GL_RENDERER ) );
fprintf( debugFile, "Version : %s\n", glGetString( GL_VERSION ) );
fprintf( debugFile, "Extensions : %s\n", glGetString( GL_EXTENSIONS ) );
fprintf(debugFile, "\n");
rgb_size[0] = 8;
rgb_size[1] = 8;
rgb_size[2] = 8;
SDL_GL_GetAttribute( SDL_GL_RED_SIZE, &value );
fprintf( debugFile, "SDL_GL_RED_SIZE: requested %d, got %d\n", rgb_size[0],value);
SDL_GL_GetAttribute( SDL_GL_GREEN_SIZE, &value );
fprintf( debugFile, "SDL_GL_GREEN_SIZE: requested %d, got %d\n", rgb_size[1],value);
SDL_GL_GetAttribute( SDL_GL_BLUE_SIZE, &value );
fprintf( debugFile, "SDL_GL_BLUE_SIZE: requested %d, got %d\n", rgb_size[2],value);
SDL_GL_GetAttribute( SDL_GL_DEPTH_SIZE, &value );
fprintf( debugFile, "SDL_GL_DEPTH_SIZE: requested %d, got %d\n", bpp, value );
SDL_GL_GetAttribute( SDL_GL_DOUBLEBUFFER, &value );
fprintf( debugFile, "SDL_GL_DOUBLEBUFFER: requested 1, got %d\n", value );
#ifdef PANTS
if ( fsaa ) {
SDL_GL_GetAttribute( SDL_GL_MULTISAMPLEBUFFERS, &value );
printf( "SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value );
SDL_GL_GetAttribute( SDL_GL_MULTISAMPLESAMPLES, &value );
printf( "SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa, value );
}
#endif
#endif
/** Setup some window stuff */
SDL_WM_SetCaption( PROJECTM_TITLE, NULL );
/** Initialise projectM */
globalPM = (projectM_t *)malloc( sizeof( projectM_t ) );
projectM_reset( globalPM );
globalPM->fullscreen = 0;
globalPM->renderTarget->texsize = 1024;
// globalPM->renderTarget->origCcontext = (void *)aglGetCurrentContext();
#ifdef DEBUG
if ( debugFile != NULL ) {
fprintf( debugFile, "current context: %X\n",
globalPM->renderTarget->origContext );
fflush( debugFile );
}
#endif
#ifdef MACOS
globalPM->fontURL = (char *)malloc( sizeof( char ) * 512 );
strcpy( globalPM->fontURL, "../../fonts" );
globalPM->presetURL = (char *)malloc( sizeof( char ) * 512 );
strcpy( globalPM->presetURL, "../../presets" );
#else
globalPM->fontURL = (char *)malloc( sizeof( char ) * 512 );
strcpy( globalPM->fontURL, "c:\\tmp\\projectM\\fonts" );
globalPM->presetURL = (char *)malloc( sizeof( char ) * 512 );
strcpy( globalPM->presetURL, "c:\\tmp\\projectM\\presets_test" );
#endif /** MACOS */
projectM_init( globalPM );
projectM_resetGL( globalPM, width, height );
/** Allocate the buffer for frame dumping, if applicable */
if ( dumpFrame ) {
fbuffer = (GLubyte *)malloc( sizeof( GLubyte ) * globalPM->wvw * globalPM->wvh * 3 );
}
/** Initialise the thread */
// renderLoop( globalPM );
main123( argc, argv );
return PROJECTM_SUCCESS;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,293 +1,293 @@
/**
* projectM -- Milkdrop-esque visualisation SDK
* Copyright (C)2003-2004 projectM Team
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* See 'LICENSE.txt' included within this release
*
*/
#include <math.h>
#include <projectM.h>
#include <sdltoprojectM.h>
#ifdef DEBUG
FILE *debugFile = NULL;
#endif
projectM *globalPM = NULL;
int dumpFrame = 0;
int frameNumber = 0;
GLubyte *fbuffer = NULL;
extern void addPCM16(short [2][512]);
void renderLoop( projectM *pm ) {
int i;
int x, y;
int index;
short pcm_data[2][512];
while ( 1 ) {
projectMEvent evt;
projectMKeycode key;
projectMModifier mod;
/** Process SDL events */
SDL_Event event;
while ( SDL_PollEvent( &event ) ) {
/** Translate into projectM codes and process */
evt = sdl2pmEvent( event );
key = sdl2pmKeycode( event.key.keysym.sym );
mod = sdl2pmModifier( event.key.keysym.mod );
if ( evt == PROJECTM_KEYDOWN ) {
pm->key_handler( evt, key, mod );
}
}
/** Produce some fake PCM data to stuff into projectM */
if ( pm->count % 5 == 0 ) {
for ( i = 0 ; i < 512 ; i++ ) {
pcm_data[0][i] = 0;
pcm_data[1][i] = 0;
}
} else {
for ( i = 0 ; i < 512 ; i++ ) {
if ( i % 2 == 0 ) {
pcm_data[0][i] = (float)( rand() / ( (float)RAND_MAX ) * (pow(2,14) ) );
pcm_data[1][i] = (float)( rand() / ( (float)RAND_MAX ) * (pow(2,14) ) );
} else {
pcm_data[0][i] = (float)( rand() / ( (float)RAND_MAX ) * (pow(2,14) ) );
pcm_data[1][i] = (float)( rand() / ( (float)RAND_MAX ) * (pow(2,14) ) );
}
if ( i % 2 == 1 ) {
pcm_data[0][i] = -pcm_data[0][i];
pcm_data[1][i] = -pcm_data[1][i];
}
}
}
/** Add the waveform data */
//addPCM16( pcm_data );
/** Render the new frame */
pm->renderFrame();
if ( dumpFrame ) {
char fname[1024];
FILE *f;
sprintf( fname, "projectM_%08d.ppm", frameNumber++ );
f = fopen( fname, "wb" );
fprintf( f, "P3\n#\n%d %d\n255\n", pm->wvw, pm->wvh );
glReadPixels( 0, 0, pm->wvw, pm->wvh, GL_RGB, GL_UNSIGNED_BYTE, fbuffer );
index = 0;
for ( y = 0 ; y < pm->wvh ; y++ ) {
for ( x = 0 ; x < pm->wvw ; x++ ) {
fprintf( f, "%d %d %d ", fbuffer[index++], fbuffer[index++], fbuffer[index++] );
}
fprintf( f, "\n" );
}
fclose( f );
}
SDL_GL_SwapBuffers();
}
printf("Worker thread: Exiting\n");
}
int main( int argc, char *argv[] ) {
/** Variables */
int fullscreen = 0;
int width = 784,
height = 784;
SDL_Surface *screen;
#ifdef DEBUG
int value;
int rgb_size[3];
#endif
const SDL_VideoInfo* info = NULL;
int bpp = 0;
/* Flags we will pass into SDL_SetVideoMode. */
int flags = 0;
#ifdef DEBUG
#ifdef WIN32
/** Init debug */
debugFile = fopen( "c:\\projectMvis.txt", "wb" );
#else
debugFile = fopen( "/tmp/projectMvis.txt", "wb" );
#endif /** WIN32 */
#endif /** DEBUG */
/** Allocate the SDL windows */
/* Information about the current video settings. */
/* First, initialize SDL's video subsystem. */
if( SDL_Init( SDL_INIT_VIDEO ) < 0 ) {
/* Failed, exit. */
#ifdef DEBUG
fprintf( debugFile, "Video initialization failed: %s\n",
SDL_GetError( ) );
#endif
//projectM_vtable.disable_plugin (&projectM_vtable);
return PROJECTM_ERROR;
}
/* Let's get some video information. */
info = SDL_GetVideoInfo( );
if( !info ) {
/* This should probably never happen. */
#ifdef DEBUG
fprintf( debugFile, "Video query failed: %s\n",
SDL_GetError( ) );
#endif
// projectM_vtable.disable_plugin (&projectM_vtable);
return PROJECTM_ERROR;
}
bpp = info->vfmt->BitsPerPixel;
// SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 5 );
// SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 5 );
// SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 5 );
//SDL_GL_SetAttribute( SDL_GL_ACCUM_RED_SIZE, 8 );
// SDL_GL_SetAttribute( SDL_GL_ACCUM_GREEN_SIZE, 8 );
// SDL_GL_SetAttribute( SDL_GL_ACCUM_BLUE_SIZE, 8 );
SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, 8 );
SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 );
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
if (fullscreen==0)
flags = SDL_OPENGL | SDL_HWSURFACE;
else flags = SDL_OPENGL | SDL_HWSURFACE |SDL_FULLSCREEN;
// w = 512; h = 512; bpp = 16;
#ifdef DEBUG
fprintf( debugFile, "pre SDL_SetVideoMode()\n" );
#endif
screen = SDL_SetVideoMode( width, height, bpp, flags ) ;
#ifdef DEBUG
fprintf( debugFile, "post SDL_SetVideoMode()\n" );
#endif
if(screen == NULL ) {
/*
* This could happen for a variety of reasons,
* including DISPLAY not being set, the specified
* resolution not being available, etc.
*/
#ifdef DEBUG
fprintf( debugFile, "Video mode set failed: %s\n",
SDL_GetError( ) );
#endif
// projectM_vtable.disable_plugin (&projectM_vtable);
return PROJECTM_ERROR;
}
#ifdef DEBUG
fprintf(debugFile, "Screen BPP: %d\n", SDL_GetVideoSurface()->format->BitsPerPixel);
fprintf(debugFile, "\n");
fprintf( debugFile, "Vendor : %s\n", glGetString( GL_VENDOR ) );
fprintf( debugFile, "Renderer : %s\n", glGetString( GL_RENDERER ) );
fprintf( debugFile, "Version : %s\n", glGetString( GL_VERSION ) );
fprintf( debugFile, "Extensions : %s\n", glGetString( GL_EXTENSIONS ) );
fprintf(debugFile, "\n");
rgb_size[0] = 8;
rgb_size[1] = 8;
rgb_size[2] = 8;
SDL_GL_GetAttribute( SDL_GL_RED_SIZE, &value );
fprintf( debugFile, "SDL_GL_RED_SIZE: requested %d, got %d\n", rgb_size[0],value);
SDL_GL_GetAttribute( SDL_GL_GREEN_SIZE, &value );
fprintf( debugFile, "SDL_GL_GREEN_SIZE: requested %d, got %d\n", rgb_size[1],value);
SDL_GL_GetAttribute( SDL_GL_BLUE_SIZE, &value );
fprintf( debugFile, "SDL_GL_BLUE_SIZE: requested %d, got %d\n", rgb_size[2],value);
SDL_GL_GetAttribute( SDL_GL_DEPTH_SIZE, &value );
fprintf( debugFile, "SDL_GL_DEPTH_SIZE: requested %d, got %d\n", bpp, value );
SDL_GL_GetAttribute( SDL_GL_DOUBLEBUFFER, &value );
fprintf( debugFile, "SDL_GL_DOUBLEBUFFER: requested 1, got %d\n", value );
#ifdef PANTS
if ( fsaa ) {
SDL_GL_GetAttribute( SDL_GL_MULTISAMPLEBUFFERS, &value );
printf( "SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value );
SDL_GL_GetAttribute( SDL_GL_MULTISAMPLESAMPLES, &value );
printf( "SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa, value );
}
#endif
#endif
/** Setup some window stuff */
SDL_WM_SetCaption( PROJECTM_TITLE, NULL );
/** Initialise projectM */
globalPM = (projectM *)malloc( sizeof( projectM ) );
globalPM->projectM_reset();
globalPM->fullscreen = 0;
// globalPM->renderTarget->texsize = 1024;
// globalPM->renderTarget->context1 = (void *)aglGetCurrentContext();
#ifdef DEBUG22
if ( debugFile != NULL ) {
fprintf( debugFile, "current context: %X\n",
globalPM->renderTarget->context1 );
fflush( debugFile );
}
#endif
#ifdef MACOS
globalPM->fontURL = (char *)malloc( sizeof( char ) * 512 );
strcpy( globalPM->fontURL, "../../fonts" );
globalPM->presetURL = (char *)malloc( sizeof( char ) * 512 );
strcpy( globalPM->presetURL, "../../presets" );
#endif
#ifdef WIN32
globalPM->fontURL = (char *)malloc( sizeof( char ) * 512 );
strcpy( globalPM->fontURL, "c:\\tmp\\projectM\\fonts" );
globalPM->presetURL = (char *)malloc( sizeof( char ) * 512 );
strcpy( globalPM->presetURL, "c:\\tmp\\projectM\\presets_test" );
#endif
#ifdef LINUX
globalPM->fontURL = (char *)malloc( sizeof( char ) * 512 );
strcpy( globalPM->fontURL, "/etc/projectM/fonts" );
globalPM->presetURL = (char *)malloc( sizeof( char ) * 512 );
strcpy( globalPM->presetURL, "/etc/projectM/presets" );
#endif
globalPM->projectM_init();
globalPM->projectM_resetGL( width, height );
/** Allocate the buffer for frame dumping, if applicable */
if ( dumpFrame ) {
fbuffer = (GLubyte *)malloc( sizeof( GLubyte ) * globalPM->wvw * globalPM->wvh * 3 );
}
/** Initialise the thread */
renderLoop( globalPM );
return PROJECTM_SUCCESS;
}
/**
* projectM -- Milkdrop-esque visualisation SDK
* Copyright (C)2003-2004 projectM Team
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* See 'LICENSE.txt' included within this release
*
*/
#include <math.h>
#include <projectM.hpp>
#include <sdltoprojectM.hpp>
#ifdef DEBUG
FILE *debugFile = NULL;
#endif
projectM *globalPM = NULL;
int dumpFrame = 0;
int frameNumber = 0;
GLubyte *fbuffer = NULL;
extern void addPCM16(short [2][512]);
void renderLoop( projectM *pm ) {
int i;
int x, y;
int index;
short pcm_data[2][512];
while ( 1 ) {
projectMEvent evt;
projectMKeycode key;
projectMModifier mod;
/** Process SDL events */
SDL_Event event;
while ( SDL_PollEvent( &event ) ) {
/** Translate into projectM codes and process */
evt = sdl2pmEvent( event );
key = sdl2pmKeycode( event.key.keysym.sym );
mod = sdl2pmModifier( event.key.keysym.mod );
if ( evt == PROJECTM_KEYDOWN ) {
pm->key_handler( evt, key, mod );
}
}
/** Produce some fake PCM data to stuff into projectM */
if ( pm->count % 5 == 0 ) {
for ( i = 0 ; i < 512 ; i++ ) {
pcm_data[0][i] = 0;
pcm_data[1][i] = 0;
}
} else {
for ( i = 0 ; i < 512 ; i++ ) {
if ( i % 2 == 0 ) {
pcm_data[0][i] = (float)( rand() / ( (float)RAND_MAX ) * (pow(2,14) ) );
pcm_data[1][i] = (float)( rand() / ( (float)RAND_MAX ) * (pow(2,14) ) );
} else {
pcm_data[0][i] = (float)( rand() / ( (float)RAND_MAX ) * (pow(2,14) ) );
pcm_data[1][i] = (float)( rand() / ( (float)RAND_MAX ) * (pow(2,14) ) );
}
if ( i % 2 == 1 ) {
pcm_data[0][i] = -pcm_data[0][i];
pcm_data[1][i] = -pcm_data[1][i];
}
}
}
/** Add the waveform data */
//addPCM16( pcm_data );
/** Render the new frame */
pm->renderFrame();
if ( dumpFrame ) {
char fname[1024];
FILE *f;
sprintf( fname, "projectM_%08d.ppm", frameNumber++ );
f = fopen( fname, "wb" );
fprintf( f, "P3\n#\n%d %d\n255\n", pm->wvw, pm->wvh );
glReadPixels( 0, 0, pm->wvw, pm->wvh, GL_RGB, GL_UNSIGNED_BYTE, fbuffer );
index = 0;
for ( y = 0 ; y < pm->wvh ; y++ ) {
for ( x = 0 ; x < pm->wvw ; x++ ) {
fprintf( f, "%d %d %d ", fbuffer[index++], fbuffer[index++], fbuffer[index++] );
}
fprintf( f, "\n" );
}
fclose( f );
}
SDL_GL_SwapBuffers();
}
printf("Worker thread: Exiting\n");
}
int main( int argc, char *argv[] ) {
/** Variables */
int fullscreen = 0;
int width = 784,
height = 784;
SDL_Surface *screen;
#ifdef DEBUG
int value;
int rgb_size[3];
#endif
const SDL_VideoInfo* info = NULL;
int bpp = 0;
/* Flags we will pass into SDL_SetVideoMode. */
int flags = 0;
#ifdef DEBUG
#ifdef WIN32
/** Init debug */
debugFile = fopen( "c:\\projectMvis.txt", "wb" );
#else
debugFile = fopen( "/tmp/projectMvis.txt", "wb" );
#endif /** WIN32 */
#endif /** DEBUG */
/** Allocate the SDL windows */
/* Information about the current video settings. */
/* First, initialize SDL's video subsystem. */
if( SDL_Init( SDL_INIT_VIDEO ) < 0 ) {
/* Failed, exit. */
#ifdef DEBUG
fprintf( debugFile, "Video initialization failed: %s\n",
SDL_GetError( ) );
#endif
//projectM_vtable.disable_plugin (&projectM_vtable);
return PROJECTM_ERROR;
}
/* Let's get some video information. */
info = SDL_GetVideoInfo( );
if( !info ) {
/* This should probably never happen. */
#ifdef DEBUG
fprintf( debugFile, "Video query failed: %s\n",
SDL_GetError( ) );
#endif
// projectM_vtable.disable_plugin (&projectM_vtable);
return PROJECTM_ERROR;
}
bpp = info->vfmt->BitsPerPixel;
// SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 5 );
// SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 5 );
// SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 5 );
//SDL_GL_SetAttribute( SDL_GL_ACCUM_RED_SIZE, 8 );
// SDL_GL_SetAttribute( SDL_GL_ACCUM_GREEN_SIZE, 8 );
// SDL_GL_SetAttribute( SDL_GL_ACCUM_BLUE_SIZE, 8 );
SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, 8 );
SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 );
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
if (fullscreen==0)
flags = SDL_OPENGL | SDL_HWSURFACE;
else flags = SDL_OPENGL | SDL_HWSURFACE |SDL_FULLSCREEN;
// w = 512; h = 512; bpp = 16;
#ifdef DEBUG
fprintf( debugFile, "pre SDL_SetVideoMode()\n" );
#endif
screen = SDL_SetVideoMode( width, height, bpp, flags ) ;
#ifdef DEBUG
fprintf( debugFile, "post SDL_SetVideoMode()\n" );
#endif
if(screen == NULL ) {
/*
* This could happen for a variety of reasons,
* including DISPLAY not being set, the specified
* resolution not being available, etc.
*/
#ifdef DEBUG
fprintf( debugFile, "Video mode set failed: %s\n",
SDL_GetError( ) );
#endif
// projectM_vtable.disable_plugin (&projectM_vtable);
return PROJECTM_ERROR;
}
#ifdef DEBUG
fprintf(debugFile, "Screen BPP: %d\n", SDL_GetVideoSurface()->format->BitsPerPixel);
fprintf(debugFile, "\n");
fprintf( debugFile, "Vendor : %s\n", glGetString( GL_VENDOR ) );
fprintf( debugFile, "Renderer : %s\n", glGetString( GL_RENDERER ) );
fprintf( debugFile, "Version : %s\n", glGetString( GL_VERSION ) );
fprintf( debugFile, "Extensions : %s\n", glGetString( GL_EXTENSIONS ) );
fprintf(debugFile, "\n");
rgb_size[0] = 8;
rgb_size[1] = 8;
rgb_size[2] = 8;
SDL_GL_GetAttribute( SDL_GL_RED_SIZE, &value );
fprintf( debugFile, "SDL_GL_RED_SIZE: requested %d, got %d\n", rgb_size[0],value);
SDL_GL_GetAttribute( SDL_GL_GREEN_SIZE, &value );
fprintf( debugFile, "SDL_GL_GREEN_SIZE: requested %d, got %d\n", rgb_size[1],value);
SDL_GL_GetAttribute( SDL_GL_BLUE_SIZE, &value );
fprintf( debugFile, "SDL_GL_BLUE_SIZE: requested %d, got %d\n", rgb_size[2],value);
SDL_GL_GetAttribute( SDL_GL_DEPTH_SIZE, &value );
fprintf( debugFile, "SDL_GL_DEPTH_SIZE: requested %d, got %d\n", bpp, value );
SDL_GL_GetAttribute( SDL_GL_DOUBLEBUFFER, &value );
fprintf( debugFile, "SDL_GL_DOUBLEBUFFER: requested 1, got %d\n", value );
#ifdef PANTS
if ( fsaa ) {
SDL_GL_GetAttribute( SDL_GL_MULTISAMPLEBUFFERS, &value );
printf( "SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value );
SDL_GL_GetAttribute( SDL_GL_MULTISAMPLESAMPLES, &value );
printf( "SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa, value );
}
#endif
#endif
/** Setup some window stuff */
SDL_WM_SetCaption( PROJECTM_TITLE, NULL );
/** Initialise projectM */
globalPM = (projectM *)malloc( sizeof( projectM ) );
globalPM->projectM_reset();
globalPM->fullscreen = 0;
// globalPM->renderTarget->texsize = 1024;
// globalPM->renderTarget->context1 = (void *)aglGetCurrentContext();
#ifdef DEBUG22
if ( debugFile != NULL ) {
fprintf( debugFile, "current context: %X\n",
globalPM->renderTarget->context1 );
fflush( debugFile );
}
#endif
#ifdef MACOS
globalPM->fontURL = (char *)malloc( sizeof( char ) * 512 );
strcpy( globalPM->fontURL, "../../fonts" );
globalPM->presetURL = (char *)malloc( sizeof( char ) * 512 );
strcpy( globalPM->presetURL, "../../presets" );
#endif
#ifdef WIN32
globalPM->fontURL = (char *)malloc( sizeof( char ) * 512 );
strcpy( globalPM->fontURL, "c:\\tmp\\projectM\\fonts" );
globalPM->presetURL = (char *)malloc( sizeof( char ) * 512 );
strcpy( globalPM->presetURL, "c:\\tmp\\projectM\\presets_test" );
#endif
#ifdef LINUX
globalPM->fontURL = (char *)malloc( sizeof( char ) * 512 );
strcpy( globalPM->fontURL, "/etc/projectM/fonts" );
globalPM->presetURL = (char *)malloc( sizeof( char ) * 512 );
strcpy( globalPM->presetURL, "/etc/projectM/presets" );
#endif
globalPM->projectM_init();
globalPM->projectM_resetGL( width, height );
/** Allocate the buffer for frame dumping, if applicable */
if ( dumpFrame ) {
fbuffer = (GLubyte *)malloc( sizeof( GLubyte ) * globalPM->wvw * globalPM->wvh * 3 );
}
/** Initialise the thread */
renderLoop( globalPM );
return PROJECTM_SUCCESS;
}

View File

@ -1,165 +1,165 @@
/**
* projectM -- Milkdrop-esque visualisation SDK
* Copyright (C)2003-2007 projectM Team
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* See 'LICENSE.txt' included within this release
*
*/
/**
* $Id: sdltoprojectM.h,v 1.1 2004/10/08 00:35:28 cvs Exp $
*
* Translates SDL -> projectM variables
*
* $Log: sdltoprojectM.h,v $
* Revision 1.1 2004/10/08 00:35:28 cvs
* Moved and imported
*
* Revision 1.1.1.1 2004/10/04 12:56:00 cvs
* Imported
*
*/
#ifndef _SDLTOPROJECTM_H
#define _SDLTOPROJECTM_H
#include "event.h"
//#include "projectM/projectM.h"
#ifdef WIN32
#include <SDL.h>
#else
#include <SDL/SDL.h>
#endif
projectMEvent sdl2pmEvent( SDL_Event event ) { \
switch ( event.type ) { \
case SDL_VIDEORESIZE:
return PROJECTM_VIDEORESIZE; \
case SDL_KEYUP: \
return PROJECTM_KEYUP; \
case SDL_KEYDOWN: \
return PROJECTM_KEYDOWN; \
default:
return PROJECTM_KEYUP; \
} \
} \
projectMKeycode sdl2pmKeycode( SDLKey keysym ) { \
switch ( keysym ) { \
case SDLK_F1: \
return PROJECTM_K_F1; \
case SDLK_F2: \
return PROJECTM_K_F2; \
case SDLK_F3: \
return PROJECTM_K_F3; \
case SDLK_F4: \
return PROJECTM_K_F4; \
case SDLK_F5: \
return PROJECTM_K_F5; \
case SDLK_F6: \
return PROJECTM_K_F6; \
case SDLK_F7: \
return PROJECTM_K_F7; \
case SDLK_F8: \
return PROJECTM_K_F8; \
case SDLK_F9: \
return PROJECTM_K_F9; \
case SDLK_F10: \
return PROJECTM_K_F10; \
case SDLK_F11: \
return PROJECTM_K_F11; \
case SDLK_F12: \
return PROJECTM_K_F12; \
case SDLK_ESCAPE: \
return PROJECTM_K_ESCAPE;
case SDLK_a:
return PROJECTM_K_a;
case SDLK_b:
return PROJECTM_K_b;
case SDLK_c:
return PROJECTM_K_c;
case SDLK_d:
return PROJECTM_K_d;
case SDLK_e:
return PROJECTM_K_e;
case SDLK_f:
return PROJECTM_K_f;
case SDLK_g:
return PROJECTM_K_g;
case SDLK_h:
return PROJECTM_K_h;
case SDLK_i:
return PROJECTM_K_i;
case SDLK_j:
return PROJECTM_K_j;
case SDLK_k:
return PROJECTM_K_k;
case SDLK_l:
return PROJECTM_K_l;
case SDLK_m:
return PROJECTM_K_m;
case SDLK_n:
return PROJECTM_K_n;
case SDLK_o:
return PROJECTM_K_o;
case SDLK_p:
return PROJECTM_K_p;
case SDLK_q:
return PROJECTM_K_q;
case SDLK_r:
return PROJECTM_K_r;
case SDLK_s:
return PROJECTM_K_s;
case SDLK_t:
return PROJECTM_K_t;
case SDLK_u:
return PROJECTM_K_u;
case SDLK_v:
return PROJECTM_K_v;
case SDLK_w:
return PROJECTM_K_w;
case SDLK_x:
return PROJECTM_K_x;
case SDLK_y:
return PROJECTM_K_y;
case SDLK_z:
return PROJECTM_K_z;
case SDLK_UP:
return PROJECTM_K_UP;
case SDLK_RETURN:
return PROJECTM_K_RETURN;
case SDLK_RIGHT:
return PROJECTM_K_RIGHT;
case SDLK_LEFT:
return PROJECTM_K_LEFT;
case SDLK_DOWN:
return PROJECTM_K_DOWN;
case SDLK_PAGEUP:
return PROJECTM_K_PAGEUP;
case SDLK_PAGEDOWN:
return PROJECTM_K_PAGEDOWN;
default: \
return PROJECTM_K_NONE; \
} \
} \
projectMModifier sdl2pmModifier( SDLMod mod ) { \
return PROJECTM_KMOD_LSHIFT; \
} \
#endif /** _SDLTOPROJECTM_H */
/**
* projectM -- Milkdrop-esque visualisation SDK
* Copyright (C)2003-2007 projectM Team
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* See 'LICENSE.txt' included within this release
*
*/
/**
* $Id: sdltoprojectM.hpp,v 1.1 2004/10/08 00:35:28 cvs Exp $
*
* Translates SDL -> projectM variables
*
* $Log: sdltoprojectM.hpp,v $
* Revision 1.1 2004/10/08 00:35:28 cvs
* Moved and imported
*
* Revision 1.1.1.1 2004/10/04 12:56:00 cvs
* Imported
*
*/
#ifndef _SDLTOPROJECTM_H
#define _SDLTOPROJECTM_H
#include "event.h"
//#include "projectM/projectM.hpp"
#ifdef WIN32
#include <SDL.h>
#else
#include <SDL/SDL.h>
#endif
projectMEvent sdl2pmEvent( SDL_Event event ) { \
switch ( event.type ) { \
case SDL_VIDEORESIZE:
return PROJECTM_VIDEORESIZE; \
case SDL_KEYUP: \
return PROJECTM_KEYUP; \
case SDL_KEYDOWN: \
return PROJECTM_KEYDOWN; \
default:
return PROJECTM_KEYUP; \
} \
} \
projectMKeycode sdl2pmKeycode( SDLKey keysym ) { \
switch ( keysym ) { \
case SDLK_F1: \
return PROJECTM_K_F1; \
case SDLK_F2: \
return PROJECTM_K_F2; \
case SDLK_F3: \
return PROJECTM_K_F3; \
case SDLK_F4: \
return PROJECTM_K_F4; \
case SDLK_F5: \
return PROJECTM_K_F5; \
case SDLK_F6: \
return PROJECTM_K_F6; \
case SDLK_F7: \
return PROJECTM_K_F7; \
case SDLK_F8: \
return PROJECTM_K_F8; \
case SDLK_F9: \
return PROJECTM_K_F9; \
case SDLK_F10: \
return PROJECTM_K_F10; \
case SDLK_F11: \
return PROJECTM_K_F11; \
case SDLK_F12: \
return PROJECTM_K_F12; \
case SDLK_ESCAPE: \
return PROJECTM_K_ESCAPE;
case SDLK_a:
return PROJECTM_K_a;
case SDLK_b:
return PROJECTM_K_b;
case SDLK_c:
return PROJECTM_K_c;
case SDLK_d:
return PROJECTM_K_d;
case SDLK_e:
return PROJECTM_K_e;
case SDLK_f:
return PROJECTM_K_f;
case SDLK_g:
return PROJECTM_K_g;
case SDLK_h:
return PROJECTM_K_h;
case SDLK_i:
return PROJECTM_K_i;
case SDLK_j:
return PROJECTM_K_j;
case SDLK_k:
return PROJECTM_K_k;
case SDLK_l:
return PROJECTM_K_l;
case SDLK_m:
return PROJECTM_K_m;
case SDLK_n:
return PROJECTM_K_n;
case SDLK_o:
return PROJECTM_K_o;
case SDLK_p:
return PROJECTM_K_p;
case SDLK_q:
return PROJECTM_K_q;
case SDLK_r:
return PROJECTM_K_r;
case SDLK_s:
return PROJECTM_K_s;
case SDLK_t:
return PROJECTM_K_t;
case SDLK_u:
return PROJECTM_K_u;
case SDLK_v:
return PROJECTM_K_v;
case SDLK_w:
return PROJECTM_K_w;
case SDLK_x:
return PROJECTM_K_x;
case SDLK_y:
return PROJECTM_K_y;
case SDLK_z:
return PROJECTM_K_z;
case SDLK_UP:
return PROJECTM_K_UP;
case SDLK_RETURN:
return PROJECTM_K_RETURN;
case SDLK_RIGHT:
return PROJECTM_K_RIGHT;
case SDLK_LEFT:
return PROJECTM_K_LEFT;
case SDLK_DOWN:
return PROJECTM_K_DOWN;
case SDLK_PAGEUP:
return PROJECTM_K_PAGEUP;
case SDLK_PAGEDOWN:
return PROJECTM_K_PAGEDOWN;
default: \
return PROJECTM_K_NONE; \
} \
} \
projectMModifier sdl2pmModifier( SDLMod mod ) { \
return PROJECTM_KMOD_LSHIFT; \
} \
#endif /** _SDLTOPROJECTM_H */

View File

@ -1,172 +1,172 @@
/**
* projectM -- Milkdrop-esque visualisation SDK
* Copyright (C)2003-2004 projectM Team
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* See 'LICENSE.txt' included within this release
*
*/
/**
* $Id: wxvisApp.cpp,v 1.6 2004/11/12 15:47:27 cvs Exp $
*
*/
#include <stdio.h>
#include <wx/wx.h>
#include <projectM-engine/projectM.h>
#include "wxvisApp.h"
#include "wxvisFrame.h"
#include "wxvisCanvas.h"
#ifdef DEBUG
FILE *debugFile = NULL;
#endif
projectM *globalPM = NULL;
IMPLEMENT_APP(wxvisApp)
BEGIN_EVENT_TABLE(wxvisApp,wxApp)
EVT_IDLE(wxvisApp::OnIdle)
END_EVENT_TABLE()
/** Parse command-line options and create the main wxvis windows */
bool wxvisApp::OnInit() {
#ifdef DEBUG
#ifndef WIN32
/** Open the debug file */
debugFile = fopen( "/tmp/wxvis.txt", "w" );
#else
/** Open the debug file */
debugFile = fopen( "c:\\wxvis.txt", "w" );
#endif /** __WXMAC__ */
#else
// debugFile = NULL;
#endif
#ifdef WIN32
/** Retrieve the key from the registry for the base installation directory */
installationRoot = (unsigned char *)malloc( sizeof( unsigned char ) * 1024 );
installationRoot[0] = '\0';
HKEY key;
if ( RegOpenKeyEx( HKEY_LOCAL_MACHINE, "SOFTWARE\\Archaeoptics\\wxvis3D",
0, KEY_QUERY_VALUE, &key ) != ERROR_SUCCESS ) {
// MessageBox( NULL, "Failed to open registry key: SOFTWARE\\Archaeoptics\\wxvis\nHelp and NPR textures may be unavailable!", "projectM", MB_OK | MB_ICONEXCLAMATION );
sprintf( (char *)installationRoot, "%s", "c:\\Program Files\\Archaeoptics\\wxvis3D" );
} else {
DWORD installRootType = REG_SZ;
DWORD installRootSize = 1024;
LONG rv = RegQueryValueEx( key, "InstallRoot", NULL, &installRootType, installationRoot, &installRootSize );
if ( rv != ERROR_SUCCESS ) {
/** This section causes things to crash weirdly... */
// MessageBox( NULL, "Failed to query registry key: SOFTWARE\\Archaeoptics\\wxvis\nHelp and textures may be unavailable!", "projectM", MB_OK | MB_ICONEXCLAMATION );
/* char msg[128];
sprintf( msg, "Error code: %d", rv );
wxMessageBox( msg, "projectM", wxOK | wxICON_EXCLAMATION ); */
sprintf( (char *)installationRoot, "%s", "c:\\Program Files\\Archaeoptics\\wxvis3D" );
}
RegCloseKey( key );
}
#ifdef DEBUG2
fprintf( debugFile, "Installation Root: %s\n", installationRoot );
fflush( debugFile );
#endif /** DEBUG */
#else
installationRoot = NULL;
#endif /** WIN32 */
/** Empty out various structures before initialisation */
_visFrame = NULL;
/** Load the icon */
_icon = wxIcon( "ARCHAEOPTICS_ICON" );
/** Create the rendering frame */
wxPoint pt;
wxSize sz;
pt.x = 50; pt.y = 50;
sz.x = 640; sz.y = 480;
_visFrame = new wxvisFrame( this, wxString( "projectM" ), pt, sz );
_visFrame->canvas = new wxvisCanvas( _visFrame );
_visFrame->SetIcon( _icon );
_visFrame->Show( TRUE );
/** Check depth and stencil capabilities */
int depthBits = _visFrame->canvas->getDepthBits();
int stencilBits = _visFrame->canvas->getStencilBits();
if ( depthBits < 24 || stencilBits < 1 ) {
char msg[256];
sprintf( msg, "Depth and stencil bit settings are sub-optimal\nBlack and White Ink Rendering and Elevation Extraction\nmay not work correctly\nDepth Bits: %d\nStencil Bits: %d\n(Should be at least 24 and 1)", depthBits, stencilBits );
// wxMessageBox( msg, "projectM", wxOK | wxICON_EXCLAMATION );
}
#ifdef WIN32
/** Update file associations */
/** Create the base wxvis key */
int rv;
rv = RegCreateKey( HKEY_CLASSES_ROOT, "projectM", &rootAssociationKey );
rv = RegSetValue( rootAssociationKey, "", REG_SZ, "MilkDrop Preset", 0 );
/** This sets the command line for "projectM" */
char exename[256];
sprintf( exename, "%s\\wxvis.exe %%1", installationRoot );
rv = RegCreateKey( HKEY_CLASSES_ROOT, "projectM", &rootAssociationKey );
rv = RegSetValue( rootAssociationKey, "shell\\open\\command", REG_SZ, exename, MAX_PATH );
/** Set the icon */
char iconname[256];
sprintf( iconname, "%s\\archaeoptics_icon_64x64.ico", installationRoot );
rv = RegCreateKey( HKEY_CLASSES_ROOT, "projectM", &rootAssociationKey );
rv = RegSetValue( rootAssociationKey, "DefaultIcon", REG_SZ, iconname, MAX_PATH );
#endif
/** Check for a model name on the command line */
#ifdef DEBUG2
fprintf( debugFile, "argc: %d\n", argc );
fflush( debugFile );
#endif
if ( argc >= 2 ) {
if ( ( strstr( argv[1], ".milk" ) != NULL ) ||
( strstr( argv[1], ".MILK" ) != NULL ) ) {
/** Load a fixed preset */
}
}
return TRUE;
}
/** Shuts down the application */
void wxvisApp::shutdown() {
/** Free local resources */
if ( _visFrame ) {
_visFrame->canvas->Destroy();
_visFrame->Destroy();
}
#ifdef DEBUG2
fclose( debugFile );
#endif /** DEBUG */
exit( 0 );
}
void wxvisApp::OnIdle( wxIdleEvent &event ) {
if ( _visFrame ) {
_visFrame->canvas->Refresh( FALSE );
}
}
/**
* projectM -- Milkdrop-esque visualisation SDK
* Copyright (C)2003-2004 projectM Team
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* See 'LICENSE.txt' included within this release
*
*/
/**
* $Id: wxvisApp.cpp,v 1.6 2004/11/12 15:47:27 cvs Exp $
*
*/
#include <stdio.h>
#include <wx/wx.h>
#include <projectM-engine/projectM.hpp>
#include "wxvisApp.h"
#include "wxvisFrame.h"
#include "wxvisCanvas.h"
#ifdef DEBUG
FILE *debugFile = NULL;
#endif
projectM *globalPM = NULL;
IMPLEMENT_APP(wxvisApp)
BEGIN_EVENT_TABLE(wxvisApp,wxApp)
EVT_IDLE(wxvisApp::OnIdle)
END_EVENT_TABLE()
/** Parse command-line options and create the main wxvis windows */
bool wxvisApp::OnInit() {
#ifdef DEBUG
#ifndef WIN32
/** Open the debug file */
debugFile = fopen( "/tmp/wxvis.txt", "w" );
#else
/** Open the debug file */
debugFile = fopen( "c:\\wxvis.txt", "w" );
#endif /** __WXMAC__ */
#else
// debugFile = NULL;
#endif
#ifdef WIN32
/** Retrieve the key from the registry for the base installation directory */
installationRoot = (unsigned char *)malloc( sizeof( unsigned char ) * 1024 );
installationRoot[0] = '\0';
HKEY key;
if ( RegOpenKeyEx( HKEY_LOCAL_MACHINE, "SOFTWARE\\Archaeoptics\\wxvis3D",
0, KEY_QUERY_VALUE, &key ) != ERROR_SUCCESS ) {
// MessageBox( NULL, "Failed to open registry key: SOFTWARE\\Archaeoptics\\wxvis\nHelp and NPR textures may be unavailable!", "projectM", MB_OK | MB_ICONEXCLAMATION );
sprintf( (char *)installationRoot, "%s", "c:\\Program Files\\Archaeoptics\\wxvis3D" );
} else {
DWORD installRootType = REG_SZ;
DWORD installRootSize = 1024;
LONG rv = RegQueryValueEx( key, "InstallRoot", NULL, &installRootType, installationRoot, &installRootSize );
if ( rv != ERROR_SUCCESS ) {
/** This section causes things to crash weirdly... */
// MessageBox( NULL, "Failed to query registry key: SOFTWARE\\Archaeoptics\\wxvis\nHelp and textures may be unavailable!", "projectM", MB_OK | MB_ICONEXCLAMATION );
/* char msg[128];
sprintf( msg, "Error code: %d", rv );
wxMessageBox( msg, "projectM", wxOK | wxICON_EXCLAMATION ); */
sprintf( (char *)installationRoot, "%s", "c:\\Program Files\\Archaeoptics\\wxvis3D" );
}
RegCloseKey( key );
}
#ifdef DEBUG2
fprintf( debugFile, "Installation Root: %s\n", installationRoot );
fflush( debugFile );
#endif /** DEBUG */
#else
installationRoot = NULL;
#endif /** WIN32 */
/** Empty out various structures before initialisation */
_visFrame = NULL;
/** Load the icon */
_icon = wxIcon( "ARCHAEOPTICS_ICON" );
/** Create the rendering frame */
wxPoint pt;
wxSize sz;
pt.x = 50; pt.y = 50;
sz.x = 640; sz.y = 480;
_visFrame = new wxvisFrame( this, wxString( "projectM" ), pt, sz );
_visFrame->canvas = new wxvisCanvas( _visFrame );
_visFrame->SetIcon( _icon );
_visFrame->Show( TRUE );
/** Check depth and stencil capabilities */
int depthBits = _visFrame->canvas->getDepthBits();
int stencilBits = _visFrame->canvas->getStencilBits();
if ( depthBits < 24 || stencilBits < 1 ) {
char msg[256];
sprintf( msg, "Depth and stencil bit settings are sub-optimal\nBlack and White Ink Rendering and Elevation Extraction\nmay not work correctly\nDepth Bits: %d\nStencil Bits: %d\n(Should be at least 24 and 1)", depthBits, stencilBits );
// wxMessageBox( msg, "projectM", wxOK | wxICON_EXCLAMATION );
}
#ifdef WIN32
/** Update file associations */
/** Create the base wxvis key */
int rv;
rv = RegCreateKey( HKEY_CLASSES_ROOT, "projectM", &rootAssociationKey );
rv = RegSetValue( rootAssociationKey, "", REG_SZ, "MilkDrop Preset", 0 );
/** This sets the command line for "projectM" */
char exename[256];
sprintf( exename, "%s\\wxvis.exe %%1", installationRoot );
rv = RegCreateKey( HKEY_CLASSES_ROOT, "projectM", &rootAssociationKey );
rv = RegSetValue( rootAssociationKey, "shell\\open\\command", REG_SZ, exename, MAX_PATH );
/** Set the icon */
char iconname[256];
sprintf( iconname, "%s\\archaeoptics_icon_64x64.ico", installationRoot );
rv = RegCreateKey( HKEY_CLASSES_ROOT, "projectM", &rootAssociationKey );
rv = RegSetValue( rootAssociationKey, "DefaultIcon", REG_SZ, iconname, MAX_PATH );
#endif
/** Check for a model name on the command line */
#ifdef DEBUG2
fprintf( debugFile, "argc: %d\n", argc );
fflush( debugFile );
#endif
if ( argc >= 2 ) {
if ( ( strstr( argv[1], ".milk" ) != NULL ) ||
( strstr( argv[1], ".MILK" ) != NULL ) ) {
/** Load a fixed preset */
}
}
return TRUE;
}
/** Shuts down the application */
void wxvisApp::shutdown() {
/** Free local resources */
if ( _visFrame ) {
_visFrame->canvas->Destroy();
_visFrame->Destroy();
}
#ifdef DEBUG2
fclose( debugFile );
#endif /** DEBUG */
exit( 0 );
}
void wxvisApp::OnIdle( wxIdleEvent &event ) {
if ( _visFrame ) {
_visFrame->canvas->Refresh( FALSE );
}
}

View File

@ -1,303 +1,303 @@
/**
* projectM -- Milkdrop-esque visualisation SDK
* Copyright (C)2003-2004 projectM Team
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* See 'LICENSE.txt' included within this release
*
*/
/**
* $Id: wxvisCanvas.cpp,v 1.5 2004/11/12 15:47:27 cvs Exp $
*
* Handles all the OpenGL drawing in the main wxvis display
*/
#include <wx/wx.h>
#ifdef WIN32
#include <windows.h>
#endif /** WIN32 */
#include <math.h>
#include <projectM-engine/wipemalloc.h>
#include <projectM-engine/BeatDetect.h>
#include <projectM-engine/PCM.h>
#include <projectM-engine/Preset.h>
#include "wxvisApp.h"
#include "wxvisFrame.h"
#include "wxvisCanvas.h"
/** Event handler table */
BEGIN_EVENT_TABLE(wxvisCanvas,wxGLCanvas)
EVT_SIZE(wxvisCanvas::OnSize)
EVT_PAINT(wxvisCanvas::OnPaint)
EVT_ERASE_BACKGROUND(wxvisCanvas::OnEraseBackground)
EVT_KEY_DOWN(wxvisCanvas::OnKeyPress)
END_EVENT_TABLE()
/** Create the OpenGL canvas */
wxvisCanvas::wxvisCanvas( wxFrame *parent, const wxWindowID id,
const wxPoint &pos, const wxSize &dims,
long style, const wxString &name ) :
wxGLCanvas( parent, (wxGLCanvas *)NULL, id,
pos, dims, style, name ) {
_parent = (wxvisFrame *)parent;
_hasInitialised = 0;
pm = NULL;
/** Create a semaphore to regulate thread access to the refresh function */
#ifdef WIN32
refreshSemaphore =
CreateSemaphore( NULL, 1, 1, "Redraw Semaphore" );
InitializeCriticalSection( &refreshMutex );
#endif
}
/** Repaint the canvas */
void wxvisCanvas::OnPaint( wxPaintEvent &event ) {
/** Acquire the semaphore before running... */
#ifdef WIN32
#ifdef DEBUG2
fprintf( debugFile, "-> OnPaint(): Acquiring mutex\n" );
fflush( debugFile );
#endif
// WaitForSingleObject( refreshSemaphore, INFINITE );
EnterCriticalSection( &refreshMutex );
#ifdef DEBUG2
fprintf( debugFile, "-> OnPaint(): Semaphore acquired[]\n" );
fflush( debugFile );
#endif
#endif
wxSize dims = GetClientSize();
/** Get the paint device context */
wxPaintDC dc( this );
/** Swap in the OpenGL context */
#ifndef __WXMOTIF__
if ( !GetContext() ) {
return;
}
#endif
SetCurrent();
/** See if we've initialised */
if ( !_hasInitialised ) {
printf( "here\n" );
initialise();
printf( "here2: %X\n", pm );
if ( pm != NULL ) {
printf( "here3\n" );
pm->projectM_resetGL( dims.x, dims.y );
printf( "here4\n" );
_hasInitialised = 1;
} else {
goto unlockAndExit;
}
}
int i;
short pcm_data[2][512];
/** Produce some fake PCM data to stuff into projectM */
if ( pm->count % 5 == 0 ) {
for ( i = 0 ; i < 512 ; i++ ) {
pcm_data[0][i] = 0;
pcm_data[1][i] = 0;
}
} else {
for ( i = 0 ; i < 512 ; i++ ) {
if ( i % 2 == 0 ) {
pcm_data[0][i] = (short)( (float)( rand() / ( (float)RAND_MAX ) * (pow(2,i%14) ) ) );
pcm_data[1][i] = (short)( (float)( rand() / ( (float)RAND_MAX ) * (pow(2,i/2%14) ) ) );
} else {
pcm_data[0][i] = (short)( (float)( rand() / ( (float)RAND_MAX ) * (pow(2,i/2%14) ) ) );
pcm_data[1][i] = (short)( (float)( rand() / ( (float)RAND_MAX ) * (pow(2,i%14) ) ) );
}
if ( i % 2 == 1 ) {
pcm_data[0][i] = -pcm_data[0][i];
pcm_data[1][i] = -pcm_data[1][i];
}
}
}
/** Add the waveform data */
DWRITE( "pm: %X\tbeatDetect: %X\tpcm: %X\tpcm_data: %X\n",
pm, pm->beatDetect, pm->beatDetect->pcm, pcm_data );
pm->beatDetect->pcm->addPCM16( pcm_data );
/** Render the new frame */
pm->renderFrame();
#ifdef PANTS
if ( dumpFrame ) {
char fname[1024];
FILE *f = fopen( fname, "wb" );
sprintf( fname, "projectM_%08d.ppm", frameNumber++ );
fprintf( f, "P3\n#\n%d %d\n255\n", pm->wvw, pm->wvh );
glReadPixels( 0, 0, pm->wvw, pm->wvh, GL_RGB, GL_UNSIGNED_BYTE, fbuffer );
index = 0;
for ( y = 0 ; y < pm->wvh ; y++ ) {
for ( x = 0 ; x < pm->wvw ; x++ ) {
fprintf( f, "%d %d %d ", fbuffer[index++], fbuffer[index++], fbuffer[index++] );
}
fprintf( f, "\n" );
}
fclose( f );
}
#endif
/** Buffer swap in here */
SwapBuffers();
unlockAndExit:
#ifdef WIN32
/** Unlock the mutex */
LeaveCriticalSection( &refreshMutex );
// ReleaseSemaphore( refreshSemaphore, 1, NULL );
#ifdef DEBUG2
fprintf( debugFile, "<- OnPaint(): Released semaphore[]\n" );
fflush( debugFile );
#endif
// ExitThread( 0 );
#endif
return;
}
/** Handles resize events */
void wxvisCanvas::OnSize( wxSizeEvent &event ) {
wxGLCanvas::OnSize( event );
int w, h;
GetClientSize( &w, &h );
/** Reset the viewport size */
#ifndef __WXMOTIF__
if ( GetContext() ) {
#endif
SetCurrent();
glViewport( 0, 0, w, h );
#ifndef __WXMOTIF__
}
#endif
if ( pm != NULL && pm->hasInit ) {
pm->projectM_resetGL( w, h );
}
}
/** Enables double-buffering, or a reasonable approximation thereof! */
void wxvisCanvas::OnEraseBackground( wxEraseEvent &event ) {
// Do nothing, to avoid flashing.
}
/** Initialise the context -- this only happens once */
void wxvisCanvas::initialise() {
#ifdef WIN32
/** Initialise font bitmap lists */
SelectObject( (HDC)GetHDC(), GetStockObject( SYSTEM_FONT ) );
glColor3f( 1, 1, 1 );
wglUseFontBitmaps( (HDC)GetHDC(), 0, 255, 1000 );
#else
#ifdef __WXMAC__
/** Initialise font bitmap lists */
short familyId = 0;
GetFNum( (const unsigned char *)"systemFont", &familyId );
aglUseFont( aglGetCurrentContext(), familyId, normal, 12, 0, 255, 1000 );
#endif
#endif
/** Initialise projectM */
pm = (projectM *)wipemalloc( sizeof( projectM ) );
pm->projectM_reset();
pm->fullscreen = 0;
pm->renderTarget->texsize = 1024;
#ifndef WIN32
pm->fontURL = (char *)malloc( sizeof( char ) * 512 );
strcpy( pm->fontURL, "../../fonts" );
pm->presetURL = (char *)malloc( sizeof( char ) * 512 );
strcpy( pm->presetURL, "/Users/descarte/tmp/projectM-1.00/presets_milkdrop" );
#else
pm->fontURL = (char *)malloc( sizeof( char ) * 512 );
strcpy( pm->fontURL, "c:\\tmp\\projectM-1.00\\fonts" );
pm->presetURL = (char *)malloc( sizeof( char ) * 512 );
strcpy( pm->presetURL, "c:\\tmp\\projectM-1.00\\presets_projectM" );
#endif /** MACOS */
pm->projectM_init();
}
/** Returns the number of depth bits */
int wxvisCanvas::getDepthBits() {
int rv[1];
SetCurrent();
glGetIntegerv( GL_DEPTH_BITS, (GLint *)rv );
return rv[0];
}
/** Returns the number of stencil bits */
int wxvisCanvas::getStencilBits() {
int rv[1];
SetCurrent();
glGetIntegerv( GL_STENCIL_BITS, (GLint *)rv );
return rv[0];
}
/** Handle keypresses */
void wxvisCanvas::OnKeyPress( wxKeyEvent &event ) {
int i;
switch ( event.GetKeyCode() ) {
case 'R': {
pm->switchPreset( RANDOM_NEXT, HARD_CUT );
break;
}
case 'N': {
pm->switchPreset( ALPHA_NEXT, HARD_CUT );
break;
}
case 'P': {
pm->switchPreset( ALPHA_PREVIOUS, HARD_CUT );
break;
}
case WXK_ESCAPE: {
_parent->app->shutdown();
break;
}
}
Refresh( FALSE );
}
/**
* projectM -- Milkdrop-esque visualisation SDK
* Copyright (C)2003-2004 projectM Team
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* See 'LICENSE.txt' included within this release
*
*/
/**
* $Id: wxvisCanvas.cpp,v 1.5 2004/11/12 15:47:27 cvs Exp $
*
* Handles all the OpenGL drawing in the main wxvis display
*/
#include <wx/wx.h>
#ifdef WIN32
#include <windows.h>
#endif /** WIN32 */
#include <math.h>
#include <projectM-engine/wipemalloc.h>
#include <projectM-engine/BeatDetect.hpp>
#include <projectM-engine/PCM.hpp>
#include <projectM-engine/Preset.h>
#include "wxvisApp.h"
#include "wxvisFrame.h"
#include "wxvisCanvas.h"
/** Event handler table */
BEGIN_EVENT_TABLE(wxvisCanvas,wxGLCanvas)
EVT_SIZE(wxvisCanvas::OnSize)
EVT_PAINT(wxvisCanvas::OnPaint)
EVT_ERASE_BACKGROUND(wxvisCanvas::OnEraseBackground)
EVT_KEY_DOWN(wxvisCanvas::OnKeyPress)
END_EVENT_TABLE()
/** Create the OpenGL canvas */
wxvisCanvas::wxvisCanvas( wxFrame *parent, const wxWindowID id,
const wxPoint &pos, const wxSize &dims,
long style, const wxString &name ) :
wxGLCanvas( parent, (wxGLCanvas *)NULL, id,
pos, dims, style, name ) {
_parent = (wxvisFrame *)parent;
_hasInitialised = 0;
pm = NULL;
/** Create a semaphore to regulate thread access to the refresh function */
#ifdef WIN32
refreshSemaphore =
CreateSemaphore( NULL, 1, 1, "Redraw Semaphore" );
InitializeCriticalSection( &refreshMutex );
#endif
}
/** Repaint the canvas */
void wxvisCanvas::OnPaint( wxPaintEvent &event ) {
/** Acquire the semaphore before running... */
#ifdef WIN32
#ifdef DEBUG2
fprintf( debugFile, "-> OnPaint(): Acquiring mutex\n" );
fflush( debugFile );
#endif
// WaitForSingleObject( refreshSemaphore, INFINITE );
EnterCriticalSection( &refreshMutex );
#ifdef DEBUG2
fprintf( debugFile, "-> OnPaint(): Semaphore acquired[]\n" );
fflush( debugFile );
#endif
#endif
wxSize dims = GetClientSize();
/** Get the paint device context */
wxPaintDC dc( this );
/** Swap in the OpenGL context */
#ifndef __WXMOTIF__
if ( !GetContext() ) {
return;
}
#endif
SetCurrent();
/** See if we've initialised */
if ( !_hasInitialised ) {
printf( "here\n" );
initialise();
printf( "here2: %X\n", pm );
if ( pm != NULL ) {
printf( "here3\n" );
pm->projectM_resetGL( dims.x, dims.y );
printf( "here4\n" );
_hasInitialised = 1;
} else {
goto unlockAndExit;
}
}
int i;
short pcm_data[2][512];
/** Produce some fake PCM data to stuff into projectM */
if ( pm->count % 5 == 0 ) {
for ( i = 0 ; i < 512 ; i++ ) {
pcm_data[0][i] = 0;
pcm_data[1][i] = 0;
}
} else {
for ( i = 0 ; i < 512 ; i++ ) {
if ( i % 2 == 0 ) {
pcm_data[0][i] = (short)( (float)( rand() / ( (float)RAND_MAX ) * (pow(2,i%14) ) ) );
pcm_data[1][i] = (short)( (float)( rand() / ( (float)RAND_MAX ) * (pow(2,i/2%14) ) ) );
} else {
pcm_data[0][i] = (short)( (float)( rand() / ( (float)RAND_MAX ) * (pow(2,i/2%14) ) ) );
pcm_data[1][i] = (short)( (float)( rand() / ( (float)RAND_MAX ) * (pow(2,i%14) ) ) );
}
if ( i % 2 == 1 ) {
pcm_data[0][i] = -pcm_data[0][i];
pcm_data[1][i] = -pcm_data[1][i];
}
}
}
/** Add the waveform data */
DWRITE( "pm: %X\tbeatDetect: %X\tpcm: %X\tpcm_data: %X\n",
pm, pm->beatDetect, pm->beatDetect->pcm, pcm_data );
pm->beatDetect->pcm->addPCM16( pcm_data );
/** Render the new frame */
pm->renderFrame();
#ifdef PANTS
if ( dumpFrame ) {
char fname[1024];
FILE *f = fopen( fname, "wb" );
sprintf( fname, "projectM_%08d.ppm", frameNumber++ );
fprintf( f, "P3\n#\n%d %d\n255\n", pm->wvw, pm->wvh );
glReadPixels( 0, 0, pm->wvw, pm->wvh, GL_RGB, GL_UNSIGNED_BYTE, fbuffer );
index = 0;
for ( y = 0 ; y < pm->wvh ; y++ ) {
for ( x = 0 ; x < pm->wvw ; x++ ) {
fprintf( f, "%d %d %d ", fbuffer[index++], fbuffer[index++], fbuffer[index++] );
}
fprintf( f, "\n" );
}
fclose( f );
}
#endif
/** Buffer swap in here */
SwapBuffers();
unlockAndExit:
#ifdef WIN32
/** Unlock the mutex */
LeaveCriticalSection( &refreshMutex );
// ReleaseSemaphore( refreshSemaphore, 1, NULL );
#ifdef DEBUG2
fprintf( debugFile, "<- OnPaint(): Released semaphore[]\n" );
fflush( debugFile );
#endif
// ExitThread( 0 );
#endif
return;
}
/** Handles resize events */
void wxvisCanvas::OnSize( wxSizeEvent &event ) {
wxGLCanvas::OnSize( event );
int w, h;
GetClientSize( &w, &h );
/** Reset the viewport size */
#ifndef __WXMOTIF__
if ( GetContext() ) {
#endif
SetCurrent();
glViewport( 0, 0, w, h );
#ifndef __WXMOTIF__
}
#endif
if ( pm != NULL && pm->hasInit ) {
pm->projectM_resetGL( w, h );
}
}
/** Enables double-buffering, or a reasonable approximation thereof! */
void wxvisCanvas::OnEraseBackground( wxEraseEvent &event ) {
// Do nothing, to avoid flashing.
}
/** Initialise the context -- this only happens once */
void wxvisCanvas::initialise() {
#ifdef WIN32
/** Initialise font bitmap lists */
SelectObject( (HDC)GetHDC(), GetStockObject( SYSTEM_FONT ) );
glColor3f( 1, 1, 1 );
wglUseFontBitmaps( (HDC)GetHDC(), 0, 255, 1000 );
#else
#ifdef __WXMAC__
/** Initialise font bitmap lists */
short familyId = 0;
GetFNum( (const unsigned char *)"systemFont", &familyId );
aglUseFont( aglGetCurrentContext(), familyId, normal, 12, 0, 255, 1000 );
#endif
#endif
/** Initialise projectM */
pm = (projectM *)wipemalloc( sizeof( projectM ) );
pm->projectM_reset();
pm->fullscreen = 0;
pm->renderTarget->texsize = 1024;
#ifndef WIN32
pm->fontURL = (char *)malloc( sizeof( char ) * 512 );
strcpy( pm->fontURL, "../../fonts" );
pm->presetURL = (char *)malloc( sizeof( char ) * 512 );
strcpy( pm->presetURL, "/Users/descarte/tmp/projectM-1.00/presets_milkdrop" );
#else
pm->fontURL = (char *)malloc( sizeof( char ) * 512 );
strcpy( pm->fontURL, "c:\\tmp\\projectM-1.00\\fonts" );
pm->presetURL = (char *)malloc( sizeof( char ) * 512 );
strcpy( pm->presetURL, "c:\\tmp\\projectM-1.00\\presets_projectM" );
#endif /** MACOS */
pm->projectM_init();
}
/** Returns the number of depth bits */
int wxvisCanvas::getDepthBits() {
int rv[1];
SetCurrent();
glGetIntegerv( GL_DEPTH_BITS, (GLint *)rv );
return rv[0];
}
/** Returns the number of stencil bits */
int wxvisCanvas::getStencilBits() {
int rv[1];
SetCurrent();
glGetIntegerv( GL_STENCIL_BITS, (GLint *)rv );
return rv[0];
}
/** Handle keypresses */
void wxvisCanvas::OnKeyPress( wxKeyEvent &event ) {
int i;
switch ( event.GetKeyCode() ) {
case 'R': {
pm->switchPreset( RANDOM_NEXT, HARD_CUT );
break;
}
case 'N': {
pm->switchPreset( ALPHA_NEXT, HARD_CUT );
break;
}
case 'P': {
pm->switchPreset( ALPHA_PREVIOUS, HARD_CUT );
break;
}
case WXK_ESCAPE: {
_parent->app->shutdown();
break;
}
}
Refresh( FALSE );
}