Example #1
0
void
render_init(r_context_t *c)
{
    c->facelist.faces = (rendface_t*) rc_malloc(g->r_numfaces * sizeof(rendface_t));
    c->translist.faces = (rendface_t*) rc_malloc(MAX_TRANSPARENT *
					  sizeof(rendface_t));
    c->r_faceinc = (int*) rc_malloc(g->r_numfaces * sizeof(int));
    c->skylist = (int*) rc_malloc(100 * sizeof(int));
    render_backend_init(c);
}
Example #2
0
struct rcf_address_pool_item *
rc_addrpool_item_new(void)
{
	struct rcf_address_pool_item	*pool;

	pool = rc_malloc(sizeof(struct rcf_address_pool_item));
	LIST_INIT(&pool->lease_list);
	return pool;
}
Example #3
0
int
main(int argc, char **argv)
{
  Uint32 videoFlags = SDL_OPENGL | SDL_FULLSCREEN;
  SDL_Event event;

  /* setup global data structures. */
  g = (global_shared_t *) gc_malloc(sizeof(global_shared_t));
  init_global_shared(g);
  strcpy(g->r_help_fname, "paul/helpSDL.jpg");
  select_video();
  ui_read_args(argc, argv);

  /* load map */
  ui_init_bsp();
  printf("\n\n");

  /* Initialize SDL for video output */
  if ( SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) < 0 ) {
      fprintf(stderr, "Unable to initialize SDL: %s\n", SDL_GetError());
      exit(1);
  }

  /* Create an OpenGL screen */
  if ( SDL_SetVideoMode(g->r_viewport_w, g->r_viewport_h, bpp, videoFlags) == NULL ) {
      fprintf(stderr, "Unable to create OpenGL screen: %s\n", SDL_GetError());
      SDL_Quit();
      exit(2);
  }

  /* SDL_WM_GrabInput(SDL_GRAB_ON); */
  SDL_ShowCursor(0);

  /* setup rendering context. */
  r_context = (r_context_t *) rc_malloc(sizeof(r_context_t));
  ui_init_gl(r_context);

  starttime = (double) SDL_GetTicks() / 1000.0;

  /* center mouse */
  SDL_WarpMouse(g->r_viewport_w/2, g->r_viewport_h/2); /* center mouse */
  warp = 1;		

  while ( !done) {
    display();	
    while ( SDL_PollEvent(&event) )
      handle_event(event); 
  }
    
  SDL_Quit();
  return 0;
}
Example #4
0
File: tex.c Project: Borf/CaveQuake
static void
tex_loadtexture(byte_t *rgb, int w, int h, int format, uint_t flags)
{
    byte_t *tex = rgb;
    int width = w, height = h;
    int size = width*height* (format == GL_RGB ? 3 : 4);

    /* Scale image down for biased level of detail (lowered texture quality) */
    if (!(flags & TEXFILE_FULL_LOD) && g->r_lodbias > 0)
    {
	width /= 1 << g->r_lodbias;
	height /= 1 << g->r_lodbias;
        tex = (byte_t *) rc_malloc(size);

        gluScaleImage(format, w, h, GL_UNSIGNED_BYTE, rgb,
		      width, height, GL_UNSIGNED_BYTE, tex);
    }


    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
	    GL_LINEAR_MIPMAP_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

    if (flags & TEXFILE_CLAMP)
    {
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
    }
    else
    {
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
    }

    if (flags & TEXFILE_NOMIPMAPS)
    {
	glTexImage2D(GL_TEXTURE_2D, 0, format, width, height, 0, format,
		     GL_UNSIGNED_BYTE, tex);
    }
    else
    {
	gluBuild2DMipmaps(GL_TEXTURE_2D, format, width, height, format,
			  GL_UNSIGNED_BYTE, tex);
    }

    if (g->r_lodbias > 0)
      free(tex);
}
Example #5
0
File: tex.c Project: Borf/CaveQuake
void tex_bindobjs(r_context_t *c) {
  int i;
  tex_data_t tdata;

  c->r_textures = (uint_t*) rc_malloc(g->r_numtextures * sizeof(uint_t));
  glGenTextures(g->r_numtextures, c->r_textures);

  if (g->r_notextures)
    return;

  for (i=0; i < g->r_numtextures; i++) {
    tdata = g->r_texture_data[i];
    if (tdata.rgb != NULL) {
      glBindTexture(GL_TEXTURE_2D, c->r_textures[i]);
      tex_loadtexture(tdata.rgb, tdata.w, tdata.h, tdata.format, g->r_texfiles[i].flags);
    }
  }
}
Example #6
0
//---------------------------------------------------------------------------
//  initWindow
//---------------------------------------------------------------------------
void initWindow( MPKWindow *w )
{
    r_context_t *r_context;

    mpkWindowSetEventCB(w,MPK_WINDOW_EVENTCB_MOUSE,windowMouse);
    mpkWindowSetEventCB(w,MPK_WINDOW_EVENTCB_BUTTON,windowMouse);
    mpkWindowSetEventCB(w,MPK_WINDOW_EVENTCB_EXIT,windowExit);
    mpkWindowSetEventCB(w,MPK_WINDOW_EVENTCB_KEYBOARD,windowKeyboard);
    mpkWindowCreate( w );

    // GL initialization
    mpkWindowApplyViewport( w );

    /* setup rendering context. */
    r_context = (r_context_t *) rc_malloc(sizeof(r_context_t));
    ui_init_gl(r_context);
    mpkWindowSetUserData(w, (void *)r_context);
 
    mpkWindowSwapBuffers(w);
}