コード例 #1
0
ファイル: gamma.c プロジェクト: Archer-sys/glfw
static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
{
    if (action != GLFW_PRESS)
        return;

    switch (key)
    {
        case GLFW_KEY_ESCAPE:
        {
            glfwSetWindowShouldClose(window, GLFW_TRUE);
            break;
        }

        case GLFW_KEY_KP_ADD:
        case GLFW_KEY_UP:
        case GLFW_KEY_Q:
        {
            set_gamma(window, gamma_value + STEP_SIZE);
            break;
        }

        case GLFW_KEY_KP_SUBTRACT:
        case GLFW_KEY_DOWN:
        case GLFW_KEY_W:
        {
            if (gamma_value - STEP_SIZE > 0.f)
                set_gamma(window, gamma_value - STEP_SIZE);

            break;
        }
    }
}
コード例 #2
0
ファイル: gamma.c プロジェクト: bioinfornatics/glfw
static void key_callback(GLFWwindow window, int key, int action)
{
    if (action != GLFW_PRESS)
        return;

    switch (key)
    {
        case GLFW_KEY_ESCAPE:
        {
            glfwDestroyWindow(window);
            break;
        }

        case GLFW_KEY_KP_ADD:
        case GLFW_KEY_Q:
        {
            set_gamma(gamma + STEP_SIZE);
            break;
        }

        case GLFW_KEY_KP_SUBTRACT:
        case GLFW_KEY_W:
        {
            if (gamma - STEP_SIZE > 0.f)
                set_gamma(gamma - STEP_SIZE);

            break;
        }
    }
}
コード例 #3
0
ファイル: gamma.c プロジェクト: csulmone/glfw
static void key_callback(GLFWwindow* window, int key, int action)
{
    if (action != GLFW_PRESS)
        return;

    switch (key)
    {
        case GLFW_KEY_ESCAPE:
        {
            closed = GL_TRUE;
            break;
        }

        case GLFW_KEY_KP_ADD:
        case GLFW_KEY_Q:
        {
            set_gamma(gamma_value + STEP_SIZE);
            break;
        }

        case GLFW_KEY_KP_SUBTRACT:
        case GLFW_KEY_W:
        {
            if (gamma_value - STEP_SIZE > 0.f)
                set_gamma(gamma_value - STEP_SIZE);

            break;
        }
    }
}
コード例 #4
0
ファイル: trans.c プロジェクト: chagge/nlp_rasp
void clear_trans_all(Trans *trans)
{
    int size = trans->size;
    set_trans(trans->trans, 0, size, FALSE);
    set_pi(trans->pi, 0, size, FALSE);
    set_gamma(trans->gamma, 0, size, FALSE);
}
コード例 #5
0
ファイル: FGAMMA.C プロジェクト: daemqn/Atari_ST_Sources
void OnInitDialogGamma(void *w)
{
  GEM_WINDOW       *wnd = (GEM_WINDOW *) w ;
  WEXTENSION_GAMMA *wext = wnd->DlgData->UserData ;
  OBJECT           *adr_gamma = wnd->DlgData->BaseObject ;
  char             buf[20] ;

  if ( nb_plane == 16 ) wext->nb_bits = 5 ;
  else                  wext->nb_bits = 8 ;
  wext->rgamma = wext->vgamma = wext->bgamma = 1.0 ;
  sprintf(buf, "%.2f", wext->rgamma) ;
  write_text(adr_gamma, GAMMA_RVAL, buf) ;
  write_text(adr_gamma, GAMMA_VVAL, buf) ;
  write_text(adr_gamma, GAMMA_BVAL, buf) ;
  wext->wbar = adr_gamma[GAMMA_RBAR].ob_width-adr_gamma[GAMMA_RSLIDER].ob_width ;
  if ( Truecolor )
  {
    set_tcgamma( wext->rgamma, wext->tcrgamma, wext->nb_bits ) ;
    memcpy( wext->tcvgamma, wext->tcrgamma, 256) ;
    memcpy( wext->tcbgamma, wext->tcrgamma, 256) ;
  }
  else
  {
    set_gamma( gamma, wext->trgamma) ;
    memcpy( wext->tvgamma, wext->trgamma, 1030*2) ;
    memcpy( wext->tbgamma, wext->trgamma, 1030*2) ;
  }
  wext->off_x = (int) ( wext->rgamma*(float)wext->wbar/2.0 ) ;
  adr_gamma[GAMMA_RSLIDER].ob_x = wext->off_x ;
  adr_gamma[GAMMA_VSLIDER].ob_x = wext->off_x ;
  adr_gamma[GAMMA_BSLIDER].ob_x = wext->off_x ;
}
コード例 #6
0
ファイル: NFCScanner.c プロジェクト: glnds/DevoxxNFCC
// helper to init all leds
void init_leds(){
  // init leds
  //int fd;              /* SPI device file descriptor */
  //const int leds = 12; /* 50 LEDs in the strand */
  //lpd8806_buffer buf;      /* Memory buffer for pixel values */
  //int count;           /* Count of iterations (up to 3) */
  //int i;               /* Counting Integer */
  set_gamma(2.5,2.5,2.5);
  /* Open SPI device */
  fd = open("/dev/spidev0.0",O_WRONLY);
  if(fd<0) {
      /* Open failed */
    fprintf(stderr, "Error: SPI device open failed.\n");
    exit(1);
  }

  /* Initialize SPI bus for lpd8806 pixels */
  if(spi_init(fd)<0) {
      /* Initialization failed */
    fprintf(stderr, "Unable to initialize SPI bus.\n");
    exit(1);
  }

  /* Allocate memory for the pixel buffer and initialize it */
  if(lpd8806_init(&buf,leds)<0) {
      /* Memory allocation failed */
    fprintf(stderr, "Insufficient memory for pixel buffer.\n");
    exit(1);
  }

  // SET LEDS HERE, update to do on interaction
  flash_leds(12);
}
コード例 #7
0
ViewPlane::ViewPlane() :
sampler_ptr(new MultiJittered(16))

{
   set_gamma(1.0);
   set_pixel_size(1.0);
}
コード例 #8
0
ファイル: trans.c プロジェクト: chagge/nlp_rasp
void init_good_turing_trans(Trans *trans)
{
    /* Set up transitions as if we had seen one of each transition already */
    int size = trans->size;
    set_trans(trans->trans, 1, size, FALSE);
    set_pi(trans->pi, 1, size, FALSE);
    set_gamma(trans->gamma, size, size, FALSE);
}
コード例 #9
0
 VngoSystem()
 {
     VgSystem = this;
     set_gamma(1.f);
     init_alpha();
     cur_vport = NULL;
     DIBTx = NULL;
     DDTx = NULL;
     D3DTx = NULL;
     OGLTx = NULL;
 }
コード例 #10
0
int mmpfb_ioctl(struct fb_info *info, unsigned int cmd, unsigned long arg)
{
	struct mmpfb_info *fbi = info->par;

	dev_dbg(info->dev, "cmd 0x%x, arg 0x%lx\n", cmd, arg);

	if (!mmp_path_ctrl_safe(fbi->path))
		return -EINVAL;

	switch (cmd) {
	case FB_IOCTL_QUERY_GLOBAL_INFO:
		get_global_info(info, arg);
		break;
	case FB_IOCTL_FLIP_COMMIT:
		enable_commit(info, arg);
		break;
	case FB_IOCTL_WAIT_VSYNC:
		mmp_wait_vsync(&fbi->path->vsync);
		break;
	case FB_IOCTL_FLIP_USR_BUF:
#ifdef CONFIG_MMP_FENCE
		return flip_buffer(info, arg);
#else
		return flip_buffer_vsync(info, arg);
#endif
	case FB_IOCTL_FLIP_VSYNC:
		return flip_buffer_vsync(info, arg);
	case FB_IOCTL_GAMMA_SET:
		return set_gamma(info, arg);
	case FB_IOCTL_SET_COLORKEYnALPHA:
		return set_colorkey_alpha(info, arg);
	case FB_IOCTL_GET_COLORKEYnALPHA:
		return get_colorkey_alpha(info, arg);
	case FB_IOCTL_ENABLE_DMA:
		return enable_dma(info, arg);
	case FB_IOCTL_VSMOOTH_EN:
		return vsmooth_en(info, arg);
	/* FB_IOCTL_ENABLE_COMMIT_DMA is only for overlay commit temporarily */
	case FB_IOCTL_ENABLE_COMMIT_DMA:
		return enable_commit_dma(info, arg);
	case FB_IOCTL_SET_PATHALPHA:
		return set_path_alpha(info, arg);
	case FB_IOCTL_SET_DFC_RATE:
		return set_dfc_rate(info, arg);
	case FB_IOCTL_GET_DFC_RATE:
		return get_dfc_rate(info, arg);
	default:
		dev_info(info->dev, "unknown ioctl 0x%x\n", cmd);
		return -EINVAL;
	}
	return 0;
}
コード例 #11
0
ファイル: flea_py.c プロジェクト: jaxiano/cuav
static PyObject *
flea_set_gamma(PyObject *self, PyObject *args)
{
	int handle = -1;
	float gamma=0;
	fleaCamera* cam = NULL;

	if (!PyArg_ParseTuple(args, "if", &handle, &gamma))
		return NULL;

	if (handle >= 0 && handle < NUM_CAMERA_HANDLES && cameras[handle]) {
		cam = cameras[handle];
		set_gamma(cam, gamma);
	} else {
		PyErr_SetString(FleaError, "Invalid handle");
		return NULL;
	}


	Py_RETURN_NONE;
}
コード例 #12
0
ファイル: Driver.cpp プロジェクト: almeagher/CheckersForOne
 Driver::Driver()
{
	
	setup_pcf();
	set_gamma(2.5,2.5,2.5);
	leds= 64;
		
	fd = open("/dev/spidev0.0",O_WRONLY);
	if(fd<0) {
		/* Open failed */
		fprintf(stderr, "Error: SPI device open failed.\n");
		exit(1);
	}

	/* Initialize SPI bus for lpd8806 pixels */
	if(spi_init(fd)<0) {
		/* Initialization failed */
		fprintf(stderr, "Unable to initialize SPI bus.\n");
		exit(1);
	}

	/* Allocate memory for the pixel buffer and initialize it */
	if(lpd8806_init(&buf,leds)<0) {
		/* Memory allocation failed */
		fprintf(stderr, "Insufficient memory for pixel buffer.\n");
		exit(1);
	}

	/* Loop Forever */
	
	for(int i=0;i<leds;i++) {
		
		write_gamma_color(&buf.pixels[i],0x00,0x00,0x00);
			
	}
	
	
		send_buffer(fd,&buf);

}
コード例 #13
0
ファイル: gamma.c プロジェクト: csulmone/glfw
int main(int argc, char** argv)
{
    int width, height, ch;
    GLFWmonitor* monitor = NULL;
    GLFWwindow* window;

    while ((ch = getopt(argc, argv, "fh")) != -1)
    {
        switch (ch)
        {
            case 'h':
                usage();
                exit(EXIT_SUCCESS);

            case 'f':
                monitor = glfwGetPrimaryMonitor();
                break;

            default:
                usage();
                exit(EXIT_FAILURE);
        }
    }

    glfwSetErrorCallback(error_callback);

    if (!glfwInit())
        exit(EXIT_FAILURE);

    if (monitor)
    {
        GLFWvidmode mode = glfwGetVideoMode(monitor);
        width = mode.width;
        height = mode.height;
    }
    else
    {
        width = 200;
        height = 200;
    }

    window = glfwCreateWindow(width, height, "Gamma Test", monitor, NULL);
    if (!window)
    {
        glfwTerminate();
        exit(EXIT_FAILURE);
    }

    set_gamma(1.f);

    glfwMakeContextCurrent(window);
    glfwSwapInterval(1);

    glfwSetKeyCallback(window, key_callback);
    glfwSetWindowCloseCallback(window, window_close_callback);
    glfwSetWindowSizeCallback(window, size_callback);

    glMatrixMode(GL_PROJECTION);
    glOrtho(-1.f, 1.f, -1.f, 1.f, -1.f, 1.f);
    glMatrixMode(GL_MODELVIEW);

    glClearColor(0.5f, 0.5f, 0.5f, 0);

    while (!closed)
    {
        glClear(GL_COLOR_BUFFER_BIT);

        glColor3f(0.8f, 0.2f, 0.4f);
        glRectf(-0.5f, -0.5f, 0.5f, 0.5f);

        glfwSwapBuffers(window);
        glfwPollEvents();
    }

    glfwTerminate();
    exit(EXIT_SUCCESS);
}
コード例 #14
0
ファイル: moptions.cpp プロジェクト: argarak/tw-light
int handleGammaSliderChange(void *dp3, int d2)
{
	STACKTRACE;
	set_gamma(d2);
	return d2;
}
コード例 #15
0
ファイル: blink_test.c プロジェクト: CoolNeon/elinux-tcl
int main(int argc, char *argv[]) {
  tcl_buffer buf;
  int fd;
  int return_value;
  tcl_color *p;
  int i;
  struct timeval start_time;
  unsigned long *change_times;
  unsigned long current_time;

  /* Open the device file using Low-Level IO */
  fd = open(device,O_WRONLY);
  if(fd<0) {
    fprintf(stderr,"Error %d: %s\n",errno,strerror(errno));
    exit(1);
  }

  /* Initialize the SPI bus for Total Control Lighting */
  return_value = spi_init(fd);
  if(return_value==-1) {
    fprintf(stderr,"SPI initialization error %d: %s\n",errno, strerror(errno));
    exit(1);
  }

  /* Initialize pixel buffer */
  if(tcl_init(&buf,leds)<0) {
    fprintf(stderr,"Pixel buffer initialization error: Not enough memory.\n");
    exit(1);
  }

  /* Set the gamma correction factors for each color */
  set_gamma(2.2,2.2,2.2);

  /* Get the current time */
  return_value = gettimeofday(&start_time,NULL);
  if(return_value==-1) {
    fprintf(stderr, "Error reading the current time: %s\n", strerror(errno));
    exit(1);
  }

  /* Set scattered intervals for the lights to change */
  /* Set all pixels to black */
  change_times = (unsigned long *)malloc(leds*sizeof(unsigned long));
  if(change_times==NULL) {
    fprintf(stderr, "Error allocating array of change times.\n");
    exit(1);
  }
  for(i=0;i<leds;i++) {
    change_times[i] = min_interval+random()%(max_interval-min_interval);
    write_gamma_color(&buf.pixels[i],0x00,0x00,0x00);
  }

  send_buffer(fd,&buf);

  /* Prepare to receive ctrl-c to stop looping */
  continue_looping = 1;
  signal(SIGINT,stop_program);

  /* Loop while continue_looping is true */
  while(continue_looping) {
    current_time = microseconds_since(&start_time);
    for(i=0;i<leds;i++) {
      if(current_time>change_times[i]) {
        p = &buf.pixels[i];
        if(p->red==0x00 && p->blue==0x00 && p->green==0x00) {
          write_gamma_color(p,(int)random()%256,(int)random()%256,(int)random%256);
        }
        else {
          write_gamma_color(p,0x00,0x00,0x00);
        }
        change_times[i]=current_time+min_interval+random()%(max_interval-min_interval);
      }
    }
    send_buffer(fd,&buf);
  }

  tcl_free(&buf);
  free(change_times);
  close(fd);
  printf("Program Terminated.\n");

  return 0;
}
コード例 #16
0
ファイル: main.c プロジェクト: imclab/Open-World-Domination
int main(){
	BOOL done = FALSE;
	MSG msg;
	IDirect3DDevice9 *device = NULL;
	IDirect3DSurface9 *main_rendertarget = NULL;
	D3DFORMAT format;
	
	float old_time = 0;

	/* render-to-texture-stuff */
	IDirect3DTexture9 *rtt_texture;
	IDirect3DSurface9 *rtt_surface;
	IDirect3DTexture9 *rtt_32_texture;
	IDirect3DSurface9 *rtt_32_surface;

	/* textures used from mainloop */
	int white, black;
	int odd_is_back_again[4];
	int at_the_gathering_2003[4];
	int o_d_d_in_your_face[4];
	int world_domination[4];
	int back_once_again[3];
	int were_back;
	int cred[4];
	int mad_props[4];
	int not_eph[4];
	int piss_the_fuck_off[11];
	int hardcore;

	int refmap, refmap2;
	int eatyrcode;
	int code_0, code_1;
	int overlaytest;
	int circle_particle;

	/* special-textures */
	int rtt_texture_id;
	int rtt_32_texture_id;
	int video_texture_id;
	int dilldall,dilldall2;
	int metaball_text;

	/* videos */
	video *vid;

	/* 3d-scenes */
	scene *fysikkfjall;
	scene *startblob;
	scene *inni_abstrakt;
	scene *korridor;
	scene *skjerm_rom;
	scene *bare_paa_lissom;

	format = D3DFMT_X8R8G8B8;
	device = d3dwin_open(TITLE, WIDTH, HEIGHT, format, FULLSCREEN);
	if(!device){
		format = D3DFMT_A8R8G8B8;
		device = d3dwin_open(TITLE, WIDTH, HEIGHT, format, FULLSCREEN);
		if(!device){
			format = D3DFMT_X1R5G5B5;
			device = d3dwin_open(TITLE, WIDTH, HEIGHT, format, FULLSCREEN);
			if(!device){
				format = D3DFMT_R5G6B5;
				device = d3dwin_open(TITLE, WIDTH, HEIGHT, format, FULLSCREEN);
				if(!device) error("failed to initialize Direct3D9");
			}
		}
	}

#ifdef BIGSCREEN
	set_gamma(device,1.05f);
#endif

	if (!BASS_Init(1, 44100, BASS_DEVICE_LATENCY, win, NULL)) error("failed to initialize BASS");
	fp = file_open("worlddomination.ogg");
	if (!fp) error("music-file not found");
	music_file = BASS_StreamCreateFile(1, fp->data, 0, fp->size, 0);

	/*** music ***/
//	if(!pest_open(win)) error("failed to initialize DirectSond");
//	if(!pest_load("worlddomination.ogg",0)) error("failed to load music-file");


	/*** subsystems ***/
	init_tunnel();
	video_init();
	if(!init_particles(device)) error("failed to initialize");
	if(!init_overlays(device)) error("f**k a duck");
	if(!init_marching_cubes(device)) error("screw a kangaroo");

	make_random_particles(particles, PARTICLES, vector_make(0,-180,0), 500);
	make_random_particles(particles2, PARTICLES2, vector_make(0,-180,0), 500);
	make_random_particles(particles3, PARTICLES3, vector_make(0,0,0), 800);

	/*** rendertextures ***/
	if (IDirect3DDevice9_CreateTexture(device, 512, 256, 0,D3DUSAGE_RENDERTARGET, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &rtt_texture, NULL)!=D3D_OK) error("failed to create rendertarget-texture");
	if (IDirect3DTexture9_GetSurfaceLevel(rtt_texture,0,&rtt_surface)!=D3D_OK) error("could not get kvasi-backbuffer-surface");
	if ((rtt_texture_id=texture_insert(device, "rendertexture.jpg", rtt_texture))==-1) error("fakk off!");

	if(IDirect3DDevice9_CreateTexture(device,16,16,0,D3DUSAGE_RENDERTARGET|D3DUSAGE_AUTOGENMIPMAP,D3DFMT_X8R8G8B8,D3DPOOL_DEFAULT, &rtt_32_texture, NULL)!=D3D_OK) error("failed to create rendertarget-texture");
	if(IDirect3DTexture9_GetSurfaceLevel(rtt_32_texture,0,&rtt_32_surface)!=D3D_OK) error("could not get kvasi-backbuffer-surface");
	if((rtt_32_texture_id=texture_insert(device, "rendertexture2.jpg", rtt_32_texture))==-1) error("fakk off!");


	/*** textures ***/
	/* solid colors for fades etc */
	if((white=texture_load(device,"white.png",FALSE))==-1) error("shjit!");
	if((black=texture_load(device,"black.png",FALSE))==-1) error("shjit!");

	/* textoverlays */
	if((odd_is_back_again[0]=texture_load(device,"odd_is_back_again_0.png",FALSE))==-1) error("failed to load image");
	if((odd_is_back_again[1]=texture_load(device,"odd_is_back_again_1.png",FALSE))==-1) error("failed to load image");
	if((odd_is_back_again[2]=texture_load(device,"odd_is_back_again_2.png",FALSE))==-1) error("failed to load image");
	if((odd_is_back_again[3]=texture_load(device,"odd_is_back_again_3.png",FALSE))==-1) error("failed to load image");
	if((at_the_gathering_2003[0]=texture_load(device,"at_the_gathering_2003_0.png",FALSE))==-1) error("failed to load image");
	if((at_the_gathering_2003[1]=texture_load(device,"at_the_gathering_2003_1.png",FALSE))==-1) error("failed to load image");
	if((at_the_gathering_2003[2]=texture_load(device,"at_the_gathering_2003_2.png",FALSE))==-1) error("failed to load image");
	if((at_the_gathering_2003[3]=texture_load(device,"at_the_gathering_2003_3.png",FALSE))==-1) error("failed to load image");
	if((back_once_again[0]=texture_load(device,"back_once_again_0.png",TRUE))==-1) error("failed to load image");
	if((back_once_again[1]=texture_load(device,"back_once_again_1.png",TRUE))==-1) error("failed to load image");
	if((back_once_again[2]=texture_load(device,"back_once_again_2.png",TRUE))==-1) error("failed to load image");
	if((o_d_d_in_your_face[0]=texture_load(device,"o_d_d_in_your_face_0.png",TRUE))==-1) error("failed to load image");
	if((o_d_d_in_your_face[1]=texture_load(device,"o_d_d_in_your_face_1.png",TRUE))==-1) error("failed to load image");
	if((o_d_d_in_your_face[2]=texture_load(device,"o_d_d_in_your_face_2.png",TRUE))==-1) error("failed to load image");
	if((o_d_d_in_your_face[3]=texture_load(device,"o_d_d_in_your_face_3.png",TRUE))==-1) error("failed to load image");
	if((world_domination[0]=texture_load(device,"world_domination_0.png",TRUE))==-1) error("failed to load image");
	if((world_domination[1]=texture_load(device,"world_domination_1.png",TRUE))==-1) error("failed to load image");
	if((world_domination[2]=texture_load(device,"world_domination_2.png",TRUE))==-1) error("failed to load image");
	if((world_domination[3]=texture_load(device,"world_domination_3.png",TRUE))==-1) error("failed to load image");
	if((were_back=texture_load(device,"were_back.png",TRUE))==-1) error("failed to load image");

	if((cred[0]=texture_load(device,"cred_0.png",TRUE))==-1) error("failed to load image");
	if((cred[1]=texture_load(device,"cred_1.png",TRUE))==-1) error("failed to load image");
	if((cred[2]=texture_load(device,"cred_2.png",TRUE))==-1) error("failed to load image");
	if((cred[3]=texture_load(device,"cred_3.png",TRUE))==-1) error("failed to load image");
	if((mad_props[0]=texture_load(device,"mad_props_0.png",TRUE))==-1) error("failed to load image");
	if((mad_props[1]=texture_load(device,"mad_props_1.png",TRUE))==-1) error("failed to load image");
	if((mad_props[2]=texture_load(device,"mad_props_2.png",TRUE))==-1) error("failed to load image");
	if((mad_props[3]=texture_load(device,"mad_props_3.png",TRUE))==-1) error("failed to load image");
	if((not_eph[0]=texture_load(device,"not_eph_0.png",TRUE))==-1) error("failed to load image");
	if((not_eph[1]=texture_load(device,"not_eph_1.png",TRUE))==-1) error("failed to load image");
	if((not_eph[2]=texture_load(device,"not_eph_2.png",TRUE))==-1) error("failed to load image");
	if((not_eph[3]=texture_load(device,"not_eph_3.png",TRUE))==-1) error("failed to load image");

	if((piss_the_fuck_off[0]=texture_load(device,"piss_the_fuck_off_0.png",TRUE))==-1) error("failed to load image");
	if((piss_the_fuck_off[1]=texture_load(device,"piss_the_fuck_off_1.png",TRUE))==-1) error("failed to load image");
	if((piss_the_fuck_off[2]=texture_load(device,"piss_the_fuck_off_2.png",TRUE))==-1) error("failed to load image");
	if((piss_the_fuck_off[3]=texture_load(device,"piss_the_fuck_off_3.png",TRUE))==-1) error("failed to load image");
	if((piss_the_fuck_off[4]=texture_load(device,"piss_the_fuck_off_4.png",TRUE))==-1) error("failed to load image");
	if((piss_the_fuck_off[5]=texture_load(device,"piss_the_fuck_off_5.png",TRUE))==-1) error("failed to load image");
	if((piss_the_fuck_off[6]=texture_load(device,"piss_the_fuck_off_6.png",TRUE))==-1) error("failed to load image");
	if((piss_the_fuck_off[7]=texture_load(device,"piss_the_fuck_off_7.png",TRUE))==-1) error("failed to load image");
	if((piss_the_fuck_off[8]=texture_load(device,"piss_the_fuck_off_8.png",TRUE))==-1) error("failed to load image");
	if((piss_the_fuck_off[9]=texture_load(device,"piss_the_fuck_off_9.png",TRUE))==-1) error("failed to load image");
	if((piss_the_fuck_off[10]=texture_load(device,"piss_the_fuck_off_10.png",TRUE))==-1) error("failed to load image");
	if((hardcore=texture_load(device,"hardcore.png",TRUE))==-1) error("failed to load image");

	/* other textures */
	if((circle_particle=texture_load(device,"circle_particle.jpg",FALSE))==-1) error("shjit!");
	if((refmap=texture_load(device,"fysikkfjall/refmap.jpg",FALSE))==-1) error("shjit!");
	if((refmap2=texture_load(device,"refmap2.jpg",FALSE))==-1) error("shjit!");
	if((eatyrcode=texture_load(device,"eatyrcode.jpg",FULLSCREEN_HACK))==-1) error("shjit!");
	if((code_0=texture_load(device,"code-0.jpg",FALSE))==-1) error("shjit!");
	if((code_1=texture_load(device,"code-1.jpg",FALSE))==-1) error("shjit!");
	if((overlaytest=texture_load(device,"overlaytest.jpg",FALSE))==-1) error("shjit!");

	if((dilldall=texture_load(device,"dilldall.png",FALSE))==-1) error("shjit!");
	if((dilldall2=texture_load(device,"dilldall2.png",FALSE))==-1) error("shjit!");

	if((metaball_text=texture_load(device,"metaballs.png",TRUE))==-1) error("shjit!");

	/*** video ***/
	if(!(vid=video_load(device,"test.kpg"))) error("fæck!");
	video_texture_id = texture_insert(device, "skjerm_rom/skjerm_tom.tga", vid->texture);


	/*** misc stuff ***/
	/* main rendertarget */
	IDirect3DDevice9_GetRenderTarget(device,0,&main_rendertarget);

	/* default state */
	IDirect3DDevice9_CreateStateBlock(device, D3DSBT_ALL, &default_state);
	init_defaultstate(device);
	IDirect3DStateBlock9_Capture(default_state);


	/*** 3d scenes ***/
	if(!(fysikkfjall=load_scene(device,"fysikkfjall/fysikkfjall.krs"))) error("failed to load 3d scene");
	if(!(startblob=load_scene(device,"startblob/startblob.krs"))) error("failed to load 3d scene");
	if(!(inni_abstrakt=load_scene(device,"inni_abstrakt/inni_abstrakt.krs"))) error("failed to load 3d scene");
	if(!(korridor=load_scene(device,"korridor/korridor.krs"))) error("failed to load 3d scene");
	if(!(skjerm_rom=load_scene(device,"skjerm_rom/skjerm_rom.krs"))) error("failed to load 3d scene");
	if(!(bare_paa_lissom=load_scene(device,"bare_paa_lissom/bare_paa_lissom.krs"))) error("failed to load 3d scene");

//	pest_play();
	BASS_Start();
	BASS_StreamPlay(music_file, 1, 0);
	do{
		grid g;
		int i;
		matrix m, temp, temp_matrix;
		matrix marching_cubes_matrix;

		long long bytes_played = BASS_ChannelGetPosition(music_file);
		float time =  bytes_played * (1.0 / (44100 * 2 * 2));
//		float time = pest_get_pos()+0.05f;
		float delta_time = time-old_time;

		int beat = (int)(time*((float)BPM/60.f));

		if(time_index<(sizeof(timetable)/4)){
			while(timetable[time_index]<time) time_index++;
		}

#ifdef _DEBUG
		printf("time: %2.2f, delta_time: %2.2f, time_index: %i, beat: %i                    \r",time,delta_time,time_index,beat);
#endif

		IDirect3DDevice9_SetRenderTarget(device,0,main_rendertarget);
		IDirect3DStateBlock9_Apply(default_state);
		IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER|D3DCLEAR_STENCIL, 0, 1.0f, 0);
//		IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_ZBUFFER, 0, 1.0f, 0);
		IDirect3DDevice9_BeginScene(device);
#if 1
		if(time_index<40){
			if(time_index>0&&time_index<5){
				draw_overlay(device,odd_is_back_again[time_index-1],0,0,1,FALSE);
			}else if(time_index>4&&time_index<19){
				float itime = time*10;
				grid_flat(g,0,0);
				for(i=0;i<7;i++){
					int scale = (time_index&1);
					grid_wave(g,(float)sin(itime-i+sin(i-itime))*0.3f*scale,(float)cos(itime*0.69f+i*0.733f)*0.3f*scale,7,(float)sin(itime+i*0.1f)*0.5f*scale);
				}
				draw_grid(device, g, odd_is_back_again[3], FALSE);
			}else if(time_index>=19){
				float itime = (time-timetable[18])*0.5f;
				grid_flat(g,0,0);
				for(i=0;i<7;i++){
					grid_wave(g,(float)sin(time-i+sin(i-time))*0.3f,(float)cos(time*0.69f+i*0.733f)*0.3f,7, itime*itime);
				}
				draw_grid(device, g, odd_is_back_again[3], FALSE);
			}
			if(time_index>20&&time_index<25){
				draw_overlay(device,at_the_gathering_2003[(time_index-21)%4],0,0,1,TRUE);
			}else if(time_index>=25&&time_index<38){
				float itime = time*10;
				grid_flat(g,0,0);
				for(i=0;i<10;i++){
					int scale = (time_index&1);
					grid_wave(g,(float)sin(itime-i+sin(i-itime))*0.3f*scale,(float)cos(itime*0.69f+i*0.733f)*0.3f*scale,7,(float)sin(itime+i*0.1f)*0.5f*scale);
				}
				draw_grid(device,g,at_the_gathering_2003[3],TRUE);
			}else if(time_index>=38){
				float itime = (time-timetable[37])*0.5f;
				grid_flat(g,0,0);
				for(i=0;i<10;i++){
					grid_wave(g,(float)sin(time-i+sin(i-time))*0.3f,(float)cos(time*0.69f+i*0.733f)*0.3f,7, itime*itime);
				}
				draw_grid(device,g,at_the_gathering_2003[3],TRUE);
			}
		}else if(time_index<52){
			animate_scene(inni_abstrakt,(time-timetable[39]));
			draw_scene(device,inni_abstrakt,0,TRUE);

			flash(device,white,time,timetable[39],1);

			if(time_index<43){
				draw_overlay(device, back_once_again[(time_index-40)%3],0,0,1,FALSE);
			}else if(time_index<47){
				draw_overlay(device, o_d_d_in_your_face[(time_index-43)%4],0,0,1,FALSE);
			}else if(time_index<51){
				draw_overlay(device, world_domination[(time_index-47)%4],0,0,1,FALSE);
			}else{
				draw_overlay(device, were_back,0,0,(time-timetable[51]),FALSE);
			}

			draw_overlay(device,dilldall,sin(sin(time)*0.07f+(((beat+1)/2)*0.8f)),sin(time*0.03337f+(((beat+1)/2)*0.14f)),0.5f,TRUE);
			draw_overlay(device,dilldall2,sin(sin(time*0.1f)*0.07f+time*0.1f+(((beat+1)/2)*0.8f)),sin(time*0.01337f+(((beat+1)/2)*0.14f)),0.5f,TRUE);

		}else if(time_index<69){

			animate_scene(startblob,(time-timetable[39]-0.27f+((beat+1)&2))*0.74948f);

			startblob->cameras[0].fog = TRUE;
			startblob->cameras[0].fog_start = 100.f;
			startblob->cameras[0].fog_end = 700.f;

			if(time_index>=53 && time_index<66 && time_index&1 ){
				float f = fade(timetable[time_index-1],1.7f,time,0.5f,0);
				f *= f;
				f *= 2;

				if(f>0.f)
				IDirect3DDevice9_SetRenderTarget(device,0,rtt_surface);

				draw_scene(device,startblob,0,TRUE);
				draw_particles(device, particles3, PARTICLES3, code_0);

				if(f>0.f){
					IDirect3DDevice9_SetRenderTarget(device,0,main_rendertarget);
					draw_radialblur(device,0,0,f,0,rtt_texture_id, FALSE);
				}
				if(time_index<61) draw_overlay(device,cred[((time_index/2)-2)%4],0,0,f*3,FALSE);
			}else{
				draw_scene(device,startblob,0,TRUE);
				draw_particles(device, particles3, PARTICLES3, circle_particle);			
			}
			if(time_index>=54&& !(time_index&1)){

				float f = fade(timetable[time_index-1],1.8f,time,1.f,0)*0.8f;
				IDirect3DDevice9_SetRenderTarget(device,0,rtt_32_surface);
				draw_scene(device,startblob,0,TRUE);
				draw_particles(device, particles3, PARTICLES3, code_0);

				IDirect3DDevice9_SetRenderTarget(device,0,main_rendertarget);
				IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
				draw_overlay(device,rtt_32_texture_id,0,0,f,TRUE);
				draw_overlay(device,rtt_32_texture_id,0,0,f,TRUE);
				IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
			}

			flash(device,were_back,time,timetable[51],2);
			flash(device,white,time,timetable[51],1);
		}else if(time_index<79){

			for(i=0;i<BALLS;i++){
				balls[i].pos.x = (float)sin(time+i-sin((float)i*0.1212111f))*0.35f;
				balls[i].pos.y = (float)cos(time-(float)i*0.29342111f)*0.35f;
				balls[i].pos.z = (float)sin(time*0.31121f+sin(i-time))*0.35f;
				balls[i].r = 0.15f + (float)sin(time+i)*0.01f;
				balls[i].pos = vector_normalize(balls[i].pos);
				balls[i].pos = vector_scale(balls[i].pos, (float)(cos(i*0.11131f-time*0.55311f)+sin(time+(float)sin(time-i+time*0.3f)))*0.2f );
			}

			animate_scene(korridor,(time-timetable[68])*0.65f );
			draw_scene(device,korridor,(beat/4)&1,TRUE);

			memcpy(temp,korridor->objects[korridor->object_count-1]->mat,sizeof(matrix));
			matrix_scale(marching_cubes_matrix,vector_make(120,120,120));
			matrix_multiply(marching_cubes_matrix,temp,marching_cubes_matrix);
	
			matrix_rotate(temp,vector_make(time,-time,time*0.5f+sin(time)));
			matrix_multiply(marching_cubes_matrix,marching_cubes_matrix,temp);

			IDirect3DDevice9_SetTransform( device, D3DTS_WORLD, (D3DMATRIX*)&marching_cubes_matrix );

			fill_metafield_blur(balls, BALLS,0.98f);
			march_my_cubes_opt(balls, BALLS, 0.9f);

			IDirect3DDevice9_SetRenderState(device, D3DRS_CULLMODE, D3DCULL_NONE);

			set_texture(device,0,refmap2);
			IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR );
			IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_ADD);
			IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
			IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG2, D3DTA_CURRENT);

			draw_marched_cubes(device);

			flash(device,white,time,timetable[68],1);

			if(time_index>69&&time_index<74){
				draw_overlay(device,mad_props[(time_index+2)%4],0,0,1,FALSE);
			}else if(time_index>73&&time_index<77){
				draw_overlay(device,not_eph[(time_index+2)%4],0,0,1,FALSE);
			}else if(time_index==77){
				float f = fade(timetable[76],2.5f,time,1,0);
				draw_overlay(device,not_eph[3],0,0,f,FALSE);
			}
		}
		if(time_index>77&&time_index<92){
			float f = fade(timetable[77],timetable[78]-timetable[77],time,0,1);
			draw_overlay(device,eatyrcode,0,0,f,FALSE);

			if(time>109.5f){
				IDirect3DStateBlock9_Apply(default_state);
				animate_particles(particles, PARTICLES, delta_time*30);
				animate_particles(particles2, PARTICLES2, delta_time*28);

				draw_particles(device, particles, PARTICLES, code_0);
				draw_particles(device, particles2, PARTICLES2, code_1);
			}
			if(time_index>79&&time_index<90){
				draw_overlay(device,piss_the_fuck_off[(time_index-80)%11],0,0,1,FALSE);
			}else if(time_index==90){
				float f = fade(timetable[89],2,time,1,0);
				draw_overlay(device,piss_the_fuck_off[10],0,0,f,FALSE);
			}
			if(time_index==91){
				float f = fade(timetable[90],2,time,1,0);
				draw_overlay(device,hardcore,0,0,f,FALSE);
			}
		}else if(time_index>91 && time_index<97){
			animate_scene(skjerm_rom,time);
			video_update(vid, time);
			draw_scene(device,skjerm_rom,((beat/4)&1),TRUE);

			draw_overlay(device,dilldall,sin(sin(time)*0.07f+(((beat+1)/2)*0.8f)),sin(time*0.03337f+(((beat+1)/2)*0.14f)),0.5f,TRUE);
			draw_overlay(device,dilldall2,sin(sin(time*0.1f)*0.07f+time*0.1f+(((beat+1)/2)*0.8f)),sin(time*0.01337f+(((beat+1)/2)*0.14f)),0.5f,TRUE);
			if(time_index>92)
				draw_overlay(device, world_domination[(time_index-93)%4],0,0,1,FALSE);

		}else if(time_index>96&&time_index<104){
			grid_zero(g);

			matrix_translate(m, vector_make(cos(time)*1.5f, sin(time)*1.5f,time*10));
			matrix_rotate(temp_matrix, vector_make(sin(time*0.8111f)*0.2f,sin(time*1.2f)*0.2f,time));
			matrix_multiply(m,m,temp_matrix);

			render_tunnel(g,m);

			matrix_rotate(temp_matrix, vector_make(0,M_PI,0));
			matrix_multiply(m,m,temp_matrix);
			render_tunnel(g,m);
			matrix_rotate(temp_matrix, vector_make(M_PI,0,0));
			matrix_multiply(m,m,temp_matrix);
			render_tunnel(g,m);

			grid_add_noice(g,sin(time)*0.1f);

			draw_grid(device, g, circle_particle, FALSE);

			if(time_index>97&&time_index<102){
				float f = 1;
				if(time_index==101) f = fade(timetable[100],3,time,1,0);
				draw_overlay(device, o_d_d_in_your_face[(time_index-42)%4],0,0,f,FALSE);
			}
		}
		if(time_index>101 && time_index<104){
			float f = fade(timetable[101],8,time,0,1);
			float f2 = fade(timetable[101],4,time,0,1);

			draw_overlay(device,black,0,0,f2,FALSE);

			IDirect3DDevice9_SetRenderTarget(device,0,rtt_surface);
			IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, 0, 1.0f, 0);

			IDirect3DStateBlock9_Apply(default_state);

			animate_scene(bare_paa_lissom,time-timetable[101]);
			draw_scene(device,bare_paa_lissom,0,TRUE);

			time *=0.5f;

			for(i=0;i<BALLS2;i++){
				balls2[i].pos.x = (float)sin(time+i-sin((float)i*0.1212111f))*0.35f;
				balls2[i].pos.y = (float)cos(time-(float)i*0.29342111f)*0.35f;
				balls2[i].pos.z = (float)sin(time*0.31121f+sin(i-time))*0.35f;
				balls2[i].r = 0.15f + (float)sin(time+i)*0.01f;
				balls2[i].pos = vector_normalize(balls2[i].pos);
				balls2[i].pos = vector_scale(balls2[i].pos, (float)(cos(i*0.11131f-time*0.55311f)+sin(time+(float)sin(time-i+time*0.3f)))*0.2f );
			}

			memcpy(temp,bare_paa_lissom->objects[bare_paa_lissom->object_count-1]->mat,sizeof(matrix));
			matrix_scale(marching_cubes_matrix,vector_make(120,120,120));
			matrix_multiply(marching_cubes_matrix,temp,marching_cubes_matrix);

			IDirect3DDevice9_SetTransform( device, D3DTS_WORLD, (D3DMATRIX*)&marching_cubes_matrix );
			fill_metafield(balls2, BALLS2);
			march_my_cubes_opt(balls2, BALLS2, 0.9f);

			IDirect3DDevice9_SetRenderState(device, D3DRS_CULLMODE, D3DCULL_NONE);

			set_texture(device,0,refmap);
			IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR );
			IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_ADD);
			IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
			IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG2, D3DTA_CURRENT);

			draw_marched_cubes(device);

			IDirect3DDevice9_SetRenderTarget(device,0,main_rendertarget);
			draw_overlay(device,rtt_texture_id,0,0,f,TRUE);

			if(time_index==103){
				float f;
				time *= 2;
				f = fade(timetable[time_index-1],3,time,1,0);
				draw_overlay(device,metaball_text,0,0,f,FALSE);

				flash(device,white,time,timetable[time_index-1],1);
			}
		}
		if(time_index==104){
			float f = fade(timetable[103],timetable[104]-timetable[103],time,0,1);

			animate_scene(korridor,180-(time-timetable[time_index-1])*0.8f );
			draw_scene(device,korridor,(beat/4)&1,TRUE);
			draw_overlay(device,black,0,0,f,FALSE);
		}
		if(time_index==105){
			float f = fade(timetable[104],timetable[105]-timetable[104],time,0,1);
			float t = (time-timetable[time_index-1])*0.6f+2.2f;
			animate_scene(fysikkfjall,t);
			draw_scene(device,fysikkfjall,0,TRUE);
			draw_overlay(device,black,0,0,f,FALSE);
		}
#endif
/*
*/
/*
		draw_overlay(device, were_back, (1+sin(time))*0.5f, TRUE);
*/
//		animate_scene(risterom,time);
//		draw_scene(device,risterom,0,TRUE);

#if 0 //helvete_har_frosset
		draw_overlay(device, eatyrcode, 1,FALSE);

		IDirect3DStateBlock9_Apply(default_state);

		animate_particles(particles, PARTICLES, delta_time*30);
		animate_particles(particles2, PARTICLES2, delta_time*28);

		draw_particles(device, particles, PARTICLES, code_0);
		draw_particles(device, particles2, PARTICLES2, code_1);
#endif

#ifdef pikk

//				IDirect3DDevice9_SetRenderTarget(device,0,rtt_surface);
				IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, 0, 1.0f, 0);

				draw_overlay(device, eatyrcode, TRUE);

				animate_scene(startblob,(time-timetable[39]-0.27f)*0.7453f);
				draw_scene(device,startblob,0,FALSE);
				draw_particles(device, particles, PARTICLES, code_0);
				draw_particles(device, particles2, PARTICLES2, code_1);
//				IDirect3DDevice9_SetRenderTarget(device,0,main_rendertarget);
/*
				draw_radialblur(device,
					(float)sin(time)*0.2f,
					(float)sin(-time*0.331f)*0.13f,
					(float)(2+(float)sin(time*0.5f))*0.2f,
					0,//sin(time)*0.25f,
					rtt_texture_id, TRUE);

				animate_scene(fysikkfjall,time);
				draw_scene(device,fysikkfjall,0,FALSE);
*/
//				draw_overlay(device, rtt_texture_id, TRUE);
#endif

//		draw_overlay(device, eatyrcode, FALSE);

//		video_update(vid, time);
#if 0
//		IDirect3DDevice9_SetRenderTarget(device,0,rtt_surface);

		animate_scene(testscene,time);

//		morph_object(testscene->objects[0], time );
		draw_scene(device,testscene,0,TRUE);
//		draw_particles(device, particles, PARTICLES, particle);

//		IDirect3DDevice9_SetRenderTarget(device,0,main_rendertarget);
#endif
#if 0
		time *=0.5f;

		for(i=0;i<BALLS2;i++){
			balls2[i].pos.x = (float)sin(time+i-sin((float)i*0.1212111f))*0.35f;
			balls2[i].pos.y = (float)cos(time-(float)i*0.29342111f)*0.35f;
			balls2[i].pos.z = (float)sin(time*0.31121f+sin(i-time))*0.35f;
			balls2[i].r = 0.15f + (float)sin(time+i)*0.01f;
			balls2[i].pos = vector_normalize(balls2[i].pos);
			balls2[i].pos = vector_scale(balls2[i].pos, (float)(cos(i*0.11131f-time*0.55311f)+sin(time+(float)sin(time-i+time*0.3f)))*0.2f );
//			balls2[i].pos.x *= 2.8f;
		}

		matrix_translate(temp,vector_make(0,0,87));
		matrix_scale(marching_cubes_matrix,vector_make(50,50,50));
		matrix_multiply(marching_cubes_matrix,temp,marching_cubes_matrix);

		IDirect3DDevice9_SetTransform( device, D3DTS_WORLD, (D3DMATRIX*)&marching_cubes_matrix );
		fill_metafield(balls2, BALLS2);
//		fill_metafield_blur(balls, BALLS,0.98f);
		march_my_cubes_opt(balls2, BALLS2, 0.9f);
//		march_my_cubes(0.9f);

		IDirect3DDevice9_SetRenderState(device, D3DRS_CULLMODE, D3DCULL_CW);

		set_texture(device,0,refmap);
		IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR );
		IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_ADD);
		IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
		IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG2, D3DTA_CURRENT);

		draw_marched_cubes(device);
#endif

#if 0
//		time *= 0.5f;
		grid_zero(g);
//		for(i=0;i<10;i++)
//			grid_wave(g,sin(time-i+sin(i-time))*0.3f,cos(time*0.69f+i*0.733f)*0.3f,7,sin(time+i*0.1f)*0.5f);

		matrix_translate(m, vector_make(cos(time)*1.5f, sin(time)*1.5f,time*10));
		matrix_rotate(temp_matrix, vector_make(sin(time*0.8111f)*0.2f,sin(time*1.2f)*0.2f,time));
		matrix_multiply(m,m,temp_matrix);

//		empty_grid( grid );
		render_tunnel(g,m);

		matrix_rotate(temp_matrix, vector_make(0,M_PI,0));
		matrix_multiply(m,m,temp_matrix);
		render_tunnel(g,m);
		matrix_rotate(temp_matrix, vector_make(M_PI,0,0));
		matrix_multiply(m,m,temp_matrix);
		render_tunnel(g,m);
//		tyfuus_expand_grid( screen, grid, texture );

		grid_add_noice(g,sin(time)*0.1f);

		draw_grid(device, g, circle_particle, FALSE);
#endif
//		IDirect3DDevice9_SetRenderTarget(device,0,main_rendertarget);

//		video_update(vid,time);
/*
		draw_radialblur(device,
			(float)sin(time)*0.2f,
			(float)sin(-time*0.331f)*0.13f,
			(float)(1+(float)sin(time*0.5f))*0.2f,
			0,//sin(time)*0.25f,
			rtt_texture_id, FALSE);
*/
//		IDirect3DStateBlock9_Apply(default_state);

//		draw_overlay(device,rtt_texture_id,FALSE);
//		draw_overlay(device,fullscreen,FALSE);

//		draw_radialblur(device,0,sin(time*0.2f)*2.f, rtt_texture_id);

//		IDirect3DDevice9_StretchRect(device,main_rendertarget,NULL,rtt_surface,NULL,D3DTEXF_NONE);
//		IDirect3DBaseTexture9_GenerateMipSubLevels(rtt_texture);

		IDirect3DDevice9_EndScene(device);
		if(IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL)==D3DERR_DEVICELOST)
			error("fakkin lost device. keep your hands off alt-tab, looser.");

		old_time = time;

		while (PeekMessage(&msg,NULL,0,0,PM_REMOVE)){ 
			TranslateMessage(&msg);
			DispatchMessage(&msg);
			if (msg.message == WM_QUIT ||
			    msg.message == WM_KEYDOWN && LOWORD(msg.wParam) == VK_ESCAPE)
				done = TRUE;
		}
	}while(!done);

	deinit_marching_cubes();
	deinit_overlays();
	deinit_particles();

	free_scene(fysikkfjall);
	free_scene(startblob);
	free_scene(inni_abstrakt);
	free_scene(korridor);
	free_scene(skjerm_rom);
	free_scene(bare_paa_lissom);

	free_materials();
	free_textures();
	free_video(vid);

	rtt_surface->lpVtbl->Release(rtt_surface);
	rtt_32_surface->lpVtbl->Release(rtt_32_surface);

	main_rendertarget->lpVtbl->Release(main_rendertarget);
	IDirect3DStateBlock9_Release(default_state);


	d3dwin_close();

	if (music_file) BASS_StreamFree( music_file );
	if (fp) file_close( fp );
	BASS_Free();

//	pest_close();

	return 0;
}
コード例 #17
0
ファイル: moptions.cpp プロジェクト: argarak/tw-light
void video_menu (Game *game)
{
	int choice = -1;
	bool done = false;
	int i, width, height, bpp, fs, native_res, native_bpp;

	DIALOG old_settings[sizeof(video_dialog)/sizeof(video_dialog[0])];

	tw_set_config_file(home_ini_full_path("client.ini"));
	if (get_config_int("Video", "NativeResolution", 1)) {
		i = static_get_native_resolution_index();
	} else {
		sprintf(dialog_string[3], "%dx%d", videosystem.width, videosystem.height);
		for (i = 0; i< sizeof(resolution)/sizeof(resolution[0]); i++) {
			if (strcmp(resolution[i], dialog_string[3]) == 0) {
				break;
			}
		}
		if (i == sizeof(resolution)/sizeof(resolution[0])) {
			i = static_get_native_resolution_index();
		}
	}
	video_dialog[DIALOG_VIDEO_RESLIST].d1 = i;

	if (get_config_int("Video", "NativeBpp", 1)) {
		i = static_get_native_bpp_index();
	} else {
		for (i = 0; i< sizeof(color_depth)/sizeof(color_depth[0]); i++) {
			if (atoi(color_depth[i]) == videosystem.bpp) {
				break;
			}
			if (i == sizeof(color_depth)/sizeof(color_depth[0])) {
				i = static_get_native_bpp_index();
			}
		}
	}

	video_dialog[DIALOG_VIDEO_BPPLIST].d1 = i;

	//set button for fullscreen
	video_dialog[DIALOG_VIDEO_FULLSCREEN].flags = videosystem.fullscreen ? D_SELECTED : 0;

	int startfs = video_dialog[DIALOG_VIDEO_FULLSCREEN].flags;

	//set gamma correction
	video_dialog[DIALOG_VIDEO_GAMMA_SLIDER].d2 = get_gamma();
	memcpy(old_settings, video_dialog, sizeof(video_dialog));

	while ( (choice != DIALOG_VIDEO_EXIT) && (!done) ) {
		//do the dialog
		choice = tw_popup_dialog(NULL, video_dialog, 0);
		if (choice == -1)
			choice = DIALOG_VIDEO_EXIT;

		static_video_dialog_to_params(video_dialog, &width, &height, &bpp, &fs, &native_res, &native_bpp);

		switch (choice) {
			case DIALOG_VIDEO_GET_DEFAULT:
				set_config_int("Video", "BitsPerPixel", 16);
				set_config_int("Video", "ScreenWidth", 640);
				set_config_int("Video", "ScreenHeight", 480);
				set_config_int("Video", "FullScreen", 1);
				set_config_int("Video", "Gamma", 128);
				set_config_int("Video", "NativeResolution", 1);
				set_config_int("Video", "NativeBpp", 1);

				if (tw_get_desktop_resolution(&width, &height)) {
					tw_error("Unable to get desktop resolution!!!");
				}
				videosystem.set_resolution(width, height, tw_desktop_color_depth(), 1);
				return;
				break;
			case DIALOG_VIDEO_OK:
				set_gamma(video_dialog[DIALOG_VIDEO_GAMMA_SLIDER].d2);
				if (videosystem.set_resolution(width, height, bpp, fs)) {
					if (confirmVideoChanges()) {
						set_config_int("Video", "BitsPerPixel", bpp);
						set_config_int("Video", "ScreenWidth", width);
						set_config_int("Video", "ScreenHeight", height);
						set_config_int("Video", "FullScreen", fs);
						set_config_int("Video", "Gamma", get_gamma());

						if (video_dialog[DIALOG_VIDEO_RESLIST].d1 == static_get_native_resolution_index()) {
							set_config_int("Video", "NativeResolution", 1);
						} else {
							set_config_int("Video", "NativeResolution", 0);
						}
						if (video_dialog[DIALOG_VIDEO_BPPLIST].d1 == static_get_native_bpp_index()) {
							set_config_int("Video", "NativeBpp", 1);
						} else {
							set_config_int("Video", "NativeBpp", 0);
						}
						return;
					} else {
						static_video_dialog_to_params(old_settings, &width, &height, &bpp, &fs, &native_res, &native_bpp);
						videosystem.set_resolution(width, height, bpp, fs);
						memcpy(video_dialog, old_settings, sizeof(video_dialog));
					}
				}
				break;

			case DIALOG_VIDEO_GAMMA_SLIDER:
				set_gamma(video_dialog[DIALOG_VIDEO_GAMMA_SLIDER].d2);
				break;

			case DIALOG_VIDEO_EXIT:
			case -1:
				return;
				break;
		}
	}
	return;
}
コード例 #18
0
ファイル: FGAMMA.C プロジェクト: daemqn/Atari_ST_Sources
void update_gammabox(GEM_WINDOW *wnd, int reference)
{
  WEXTENSION_GAMMA *wext = wnd->DlgData->UserData ;
  OBJECT           *adr_gamma = wnd->DlgData->BaseObject ;
  INFO_IMAGE       *inf_img = wext->inf_img ;
  char             buf[20] ;

  switch( reference )
  {
    case GAMMA_RVAL : xobjc_draw( wnd->window_handle,adr_gamma, GAMMA_RBAR ) ; 
                      sprintf(buf, "%.2f", wext->rgamma) ;
                      if (!Truecolor) set_gamma(wext->rgamma, wext->trgamma) ;
                      else            set_tcgamma(wext->rgamma, wext->tcrgamma, wext->nb_bits) ;
                      break ;
    case GAMMA_VVAL : xobjc_draw( wnd->window_handle,adr_gamma, GAMMA_VBAR ) ; 
                      sprintf(buf, "%.2f", wext->vgamma) ;
                      if (!Truecolor) set_gamma(wext->vgamma, wext->tvgamma) ;
                      else            set_tcgamma(wext->vgamma, wext->tcvgamma, wext->nb_bits) ;
                      break ;
    case GAMMA_BVAL : xobjc_draw( wnd->window_handle,adr_gamma, GAMMA_BBAR ) ; 
                      sprintf(buf, "%.2f", wext->bgamma) ;
                      if (!Truecolor) set_gamma(wext->bgamma, wext->tbgamma) ;
                      else            set_tcgamma(wext->bgamma, wext->tcbgamma, wext->nb_bits) ;
                      break ;
  }

  if (selected(adr_gamma, GAMMA_GROUP))
  {
    switch(reference)
    {
      case GAMMA_RVAL : wext->vgamma = wext->bgamma = wext->rgamma ;
                        if (Truecolor)
                        {
                          memcpy(wext->tcvgamma, wext->tcrgamma, 256) ;
                          memcpy(wext->tcbgamma, wext->tcrgamma, 256) ;
                        }
                        else
                        {
                          memcpy(wext->tvgamma, wext->trgamma, 1030*2) ;
                          memcpy(wext->tbgamma, wext->trgamma, 1030*2) ;
                        }
                        break ;
      case GAMMA_VVAL : wext->rgamma = wext->bgamma = wext->vgamma ;
                        if (Truecolor)
                        {
                          memcpy(wext->tcrgamma, wext->tcvgamma, 256) ;
                          memcpy(wext->tcbgamma, wext->tcvgamma, 256) ;
                        }
                        else
                        {
                          memcpy(wext->trgamma, wext->tvgamma, 1030*2) ;
                          memcpy(wext->tbgamma, wext->tvgamma, 1030*2) ;
                        }
                        break ;
      case GAMMA_BVAL : wext->vgamma = wext->rgamma = wext->bgamma ;
                        if (Truecolor)
                        {
                          memcpy(wext->tcvgamma, wext->tcbgamma, 256) ;
                          memcpy(wext->tcrgamma, wext->tcbgamma, 256) ;
                        }
                        else
                        {
                          memcpy(wext->tvgamma, wext->tbgamma, 1030*2) ;
                          memcpy(wext->trgamma, wext->tbgamma, 1030*2) ;
                        }
                        break ;
    }

    adr_gamma[GAMMA_RSLIDER].ob_x = wext->off_x ;
    xobjc_draw( wnd->window_handle,adr_gamma, GAMMA_RBAR ) ;
    adr_gamma[GAMMA_VSLIDER].ob_x = wext->off_x ;
    xobjc_draw( wnd->window_handle,adr_gamma, GAMMA_VBAR ) ;
    adr_gamma[GAMMA_BSLIDER].ob_x = wext->off_x ;
    xobjc_draw( wnd->window_handle,adr_gamma, GAMMA_BBAR ) ;
    write_text(adr_gamma, GAMMA_RVAL, buf) ;
    xobjc_draw( wnd->window_handle,adr_gamma, GAMMA_RVAL ) ;
    write_text(adr_gamma, GAMMA_VVAL, buf) ;
    xobjc_draw( wnd->window_handle,adr_gamma, GAMMA_VVAL ) ;
    write_text(adr_gamma, GAMMA_BVAL, buf) ;
    xobjc_draw( wnd->window_handle,adr_gamma, GAMMA_BVAL ) ;
  }
  else
  {
    write_text(adr_gamma, reference, buf) ;
    xobjc_draw( wnd->window_handle,adr_gamma, reference ) ;
  }
  if (Truecolor)
  {
    if ( !UseStdVDI )
      screen_tcpal( wext->tcrgamma, wext->tcvgamma, wext->tcbgamma, wext->wnd ) ;
  } 
  else
    if (inf_img->palette != NULL)
    {
      int pal[6*256] ;

      memcpy(pal, inf_img->palette, 6*inf_img->nb_cpal) ;
      make_vdigamma(wext->trgamma, wext->tvgamma, wext->tbgamma, inf_img->palette, (int) inf_img->nb_cpal) ;
      set_imgpalette( wext->vimage ) ;
      memcpy(inf_img->palette, pal, 6*inf_img->nb_cpal) ;
    }
}
コード例 #19
0
ファイル: gamma.c プロジェクト: bioinfornatics/glfw
int main(int argc, char** argv)
{
    int width, height, ch;
    int mode = GLFW_WINDOWED;
    GLFWwindow window;

    while ((ch = getopt(argc, argv, "fh")) != -1)
    {
        switch (ch)
        {
            case 'h':
                usage();
                exit(EXIT_SUCCESS);

            case 'f':
                mode = GLFW_FULLSCREEN;
                break;

            default:
                usage();
                exit(EXIT_FAILURE);
        }
    }

    if (!glfwInit())
    {
        fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError()));
        exit(EXIT_FAILURE);
    }

    if (mode == GLFW_FULLSCREEN)
    {
        GLFWvidmode mode;
        glfwGetDesktopMode(&mode);
        width = mode.width;
        height = mode.height;
    }
    else
    {
        width = 0;
        height = 0;
    }

    window = glfwCreateWindow(width, height, mode, "Gamma Test", NULL);
    if (!window)
    {
        glfwTerminate();

        fprintf(stderr, "Failed to open GLFW window: %s\n", glfwErrorString(glfwGetError()));
        exit(EXIT_FAILURE);
    }

    set_gamma(1.f);

    glfwMakeContextCurrent(window);
    glfwSwapInterval(1);

    glfwSetKeyCallback(key_callback);
    glfwSetWindowSizeCallback(size_callback);

    glMatrixMode(GL_PROJECTION);
    glOrtho(-1.f, 1.f, -1.f, 1.f, -1.f, 1.f);
    glMatrixMode(GL_MODELVIEW);

    glClearColor(0.5f, 0.5f, 0.5f, 0);

    while (!glfwGetWindowParam(window, GLFW_CLOSE_REQUESTED))
    {
        glClear(GL_COLOR_BUFFER_BIT);

        glColor3f(0.8f, 0.2f, 0.4f);
        glRectf(-0.5f, -0.5f, 0.5f, 0.5f);

        glfwSwapBuffers(window);
        glfwPollEvents();
    }

    glfwTerminate();
    exit(EXIT_SUCCESS);
}
コード例 #20
0
ファイル: lpd8806.c プロジェクト: pgrandin/evdev-jukebox
void * spi_handler(void)
{
  lpd8806_buffer buf;
  int fd;
  int return_value;
  lpd8806_color *p;
  int i;
  double h, r, g, b;

  /* Open the device file using Low-Level IO */
  fd = open(device,O_WRONLY);
  if(fd<0) {
    fprintf(stderr,"Error %d: %s\n",errno,strerror(errno));
    pthread_exit(NULL);
  }

  /* Initialize the SPI bus for Total Control Lighting */
  return_value = spi_init(fd);
  if(return_value==-1) {
    fprintf(stderr,"SPI initialization error %d: %s\n",errno, strerror(errno));
    pthread_exit(NULL);
  }

  /* Initialize pixel buffer */
  if(lpd8806_init(&buf,leds)<0) {
    fprintf(stderr,"Pixel buffer initialization error: Not enough memory.\n");
    pthread_exit(NULL);
  }

  /* Set the gamma correction factors for each color */
  set_gamma(2.2,2.2,2.2);

  /* Blank the pixels */

  for(i=0;i<leds;i++) {
    write_gamma_color(&buf.pixels[i],0x00,0x00,0x00);
  }

  send_buffer(fd,&buf);

  h = 0.0;
  printf("Entering spi loop\n");
  /* Loop while continue_looping is true */
  for(;;){
    pthread_mutex_lock(&playback_status_lock);
    if(is_playing){
      h+=2.0;
      if(h>=360.0) h=0.0;
      memmove(buf.pixels+1,buf.pixels,sizeof(lpd8806_color)*(leds-2));
      HSVtoRGB(h,1.0,1.0,&r,&g,&b);
      p = &buf.pixels[0];
      write_gamma_color(p,(int)(r*255.0),(int)(g*255.0),(int)floor(b*255.0));
      send_buffer(fd,&buf);
    } else {
      for(i=0;i<leds;i++) {
         p = &buf.pixels[i];
         write_gamma_color(p,0x00,0x00,0x00);
      }
    send_buffer(fd,&buf);
   }
   pthread_mutex_unlock(&playback_status_lock);
   usleep(10000);
  }
for(i=0;i<leds;i++) {
    p = &buf.pixels[i];
      write_gamma_color(p,0x00,0x00,0x00);
      
  }
    send_buffer(fd,&buf);
  lpd8806_free(&buf);
  close(fd);
  printf("lpd thread terminated.\n");

  pthread_exit(NULL);
}
コード例 #21
0
int main(int argc, char *argv[]) {
  int fd;              /* SPI device file descriptor */
  const int leds = 500; /* 50 LEDs in the strand */
  lpd8806_buffer buf;      /* Memory buffer for pixel values */
  int count;           /* Count of iterations (up to 3) */
  int i;               /* Counting Integer */
  set_gamma(2.5,2.5,2.5);
  /* Open SPI device */
  fd = open("/dev/spidev0.0",O_WRONLY);
  if(fd<0) {
      /* Open failed */
      fprintf(stderr, "Error: SPI device open failed.\n");
      exit(1);
  }

  /* Initialize SPI bus for lpd8806 pixels */
  if(spi_init(fd)<0) {
      /* Initialization failed */
      fprintf(stderr, "Unable to initialize SPI bus.\n");
      exit(1);
  }

  /* Allocate memory for the pixel buffer and initialize it */
  if(lpd8806_init(&buf,leds)<0) {
      /* Memory allocation failed */
      fprintf(stderr, "Insufficient memory for pixel buffer.\n");
      exit(1);
  }

  /* Loop Forever */
  while(1) {
    /* Do three iterations */
    for(count=0;count<3;count++) {
      /* Write color for every pixel */
      for(i=0;i<leds;i++) {
        if((i+count)%3==0) {
          /* Red pixel */
          write_gamma_color(&buf.pixels[i],255,0,0);
        }
        else if((i+count)%3==1) {
          /* Green pixel */
          write_gamma_color(&buf.pixels[i],0,255,0);
        }
        else {
          /* Blue pixel */
          write_gamma_color(&buf.pixels[i],0,0,255);
        }
      }

      /* Send the data to the lpd8806 lighting strand */
      if(send_buffer(fd,&buf)<0) {
        fprintf(stderr, "Error sending data.\n");
        exit(1);
      }

      /* Sleep for 1 second */
      usleep(1000000/60.0f);
    }
  }
for(i=0;i<leds;i++) {
    
      write_gamma_color(&buf.pixels[i],0x00,0x00,0x00);
      
  }
    send_buffer(fd,&buf);
  /* Although the program never gets to this point, below is how to clean up */

  /* Free the pixel buffer */
  lpd8806_free(&buf);

  /* Close the SPI device */
  close(fd);

  return 0;
}
コード例 #22
0
ファイル: cl_gamma_handler.cpp プロジェクト: weiafu/libxcam
CLGammaImageKernel::CLGammaImageKernel (SmartPtr<CLContext> &context)
    : CLImageKernel (context, "kernel_gamma", false)
{
    set_gamma(default_gamma_table);
}
コード例 #23
0
ファイル: gamma.c プロジェクト: Archer-sys/glfw
int main(int argc, char** argv)
{
    int width, height, ch;
    GLFWmonitor* monitor = NULL;
    GLFWwindow* window;

    glfwSetErrorCallback(error_callback);

    if (!glfwInit())
        exit(EXIT_FAILURE);

    while ((ch = getopt(argc, argv, "fh")) != -1)
    {
        switch (ch)
        {
            case 'h':
                usage();
                exit(EXIT_SUCCESS);

            case 'f':
                monitor = glfwGetPrimaryMonitor();
                break;

            default:
                usage();
                exit(EXIT_FAILURE);
        }
    }

    if (monitor)
    {
        const GLFWvidmode* mode = glfwGetVideoMode(monitor);

        glfwWindowHint(GLFW_REFRESH_RATE, mode->refreshRate);
        glfwWindowHint(GLFW_RED_BITS, mode->redBits);
        glfwWindowHint(GLFW_GREEN_BITS, mode->greenBits);
        glfwWindowHint(GLFW_BLUE_BITS, mode->blueBits);

        width = mode->width;
        height = mode->height;
    }
    else
    {
        width = 200;
        height = 200;
    }

    window = glfwCreateWindow(width, height, "Gamma Test", monitor, NULL);
    if (!window)
    {
        glfwTerminate();
        exit(EXIT_FAILURE);
    }

    set_gamma(window, 1.f);

    glfwMakeContextCurrent(window);
    gladLoadGLLoader((GLADloadproc) glfwGetProcAddress);
    glfwSwapInterval(1);

    glfwSetKeyCallback(window, key_callback);
    glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);

    glMatrixMode(GL_PROJECTION);
    glOrtho(-1.f, 1.f, -1.f, 1.f, -1.f, 1.f);
    glMatrixMode(GL_MODELVIEW);

    glClearColor(0.5f, 0.5f, 0.5f, 0);

    while (!glfwWindowShouldClose(window))
    {
        glClear(GL_COLOR_BUFFER_BIT);

        glColor3f(0.8f, 0.2f, 0.4f);
        glRectf(-0.5f, -0.5f, 0.5f, 0.5f);

        glfwSwapBuffers(window);
        glfwWaitEvents();
    }

    glfwTerminate();
    exit(EXIT_SUCCESS);
}