Esempio n. 1
0
void glGetIntegerv(int pname,int *params)
{
  GLContext *c=gl_get_context();

  switch(pname) {
  case GL_VIEWPORT:
    params[0]=c->viewport.xmin;
    params[1]=c->viewport.ymin;
    params[2]=c->viewport.xsize;
    params[3]=c->viewport.ysize;
    break;
  case GL_MAX_MODELVIEW_STACK_DEPTH:
    *params = MAX_MODELVIEW_STACK_DEPTH;
    break;
  case GL_MAX_PROJECTION_STACK_DEPTH:
    *params = MAX_PROJECTION_STACK_DEPTH;
    break;
  case GL_MAX_LIGHTS:
    *params = MAX_LIGHTS;
    break;
  case GL_MAX_TEXTURE_SIZE:
    *params = 1024; /* not completely true, but... */
    break;
  case GL_MAX_TEXTURE_STACK_DEPTH:
    *params = MAX_TEXTURE_STACK_DEPTH;
    break;
  default:
    gl_fatal_error("glGet: option not implemented");
    break;
  }
}
Esempio n. 2
0
int pl110_MakeCurrent(pl110_Context *ctx ){
	int	mode;
	int	xsize;
	int	ysize;

	ZBuffer *zb;

	if( ctx->gl_context == NULL ){
		xsize = 640;
		ysize = 480;
		mode = ZB_MODE_5R6G5B;

		zb = ZB_open( xsize, ysize, mode, 0, NULL, NULL, NULL);
		
		if( zb == NULL ) {
			return 0;
		}

		/* initialisation of the TinyGL interpreter */
		glInit( zb );
		ctx->gl_context                     = gl_get_context();
		ctx->gl_context->opaque             = (void *) ctx;
		ctx->gl_context->gl_resize_viewport = pl110_resize_viewport;

		/* set the viewport */
		/*  TIS: !!! HERE SHOULD BE -1 on both to force reshape  */
		/*  which is needed to make sure initial reshape is  */
		/*  called, otherwise it is not called..  */
		ctx->gl_context->viewport.xsize = xsize;
		ctx->gl_context->viewport.ysize = ysize;
		glViewport( 0, 0, xsize, ysize );
	}
	return 1;
}
Esempio n. 3
0
void
ostgl_make_current(ostgl_context *oscontext, const int idx)
{
  GLContext *context = gl_get_context();
  gl_assert(idx < oscontext->numbuffers);
  context->zb = oscontext->zbs[idx];
}
Esempio n. 4
0
File: list.c Progetto: plzombie/ne
int glIsList(unsigned int list)
{
  GLContext *c=gl_get_context();
  GLList *l;
  l=find_list(c,list);
  return (l != NULL);
}
Esempio n. 5
0
/*!  Swap buffers  */
void pl110_SwapBuffers(){
	GLContext        *gl_context;
        pl110_Context *ctx;

    gl_context = gl_get_context();
    ctx = (pl110_Context *)gl_context->opaque;

    void *fb = (uint16*) 0x40000000;
    ZB_copyFrameBuffer(ctx->gl_context->zb, fb, 640 * 2);
}
Esempio n. 6
0
void nglXSwapBuffers(NGLXDrawable drawable) {
	GLContext *gl_context;
	TinyNGLXContext *ctx;

	/* retrieve the current NGLXContext */
	gl_context = gl_get_context();
	ctx = (TinyNGLXContext *)gl_context->opaque;

	GrArea(drawable, ctx->gc, 0, 0, ctx->xsize,
		   ctx->ysize, ctx->gl_context->zb->pbuf, ctx->pixtype);
}
Esempio n. 7
0
void glClose() {
	GLContext *c = gl_get_context();

	specbuf_cleanup(c);
	for (int i = 0; i < 3; i++)
		gl_free(c->matrix_stack[i]);
	endSharedState(c);
	gl_free(c->vertex);

	gl_free(c);
}
Esempio n. 8
0
void glEndList() {
	GLContext *c = gl_get_context();
	GLParam p[1];

	assert(c->compile_flag == 1);
  
	// end of list
	p[0].op = OP_EndList;
	gl_compile_op(c, p);
  
	c->compile_flag = 0;
	c->exec_flag = 1;
}
Esempio n. 9
0
void glClose() {
	GLContext *c = gl_get_context();

	tglDisposeDrawCallLists(c);
	tglDisposeResources(c);

	specbuf_cleanup(c);
	for (int i = 0; i < 3; i++)
		gl_free(c->matrix_stack[i]);
	endSharedState(c);
	gl_free(c->vertex);

	delete c;
}
Esempio n. 10
0
void gl_add_op(GLParam *p) {
	GLContext *c=gl_get_context();
	int op;

	op = p[0].op;
	if (c->exec_flag) {
		op_table_func[op](c, p);
	}
	if (c->compile_flag) {
		gl_compile_op(c, p);
	}
	if (c->print_flag) {
		gl_print_op(stderr, p);
	}
}
Esempio n. 11
0
void glDeleteTextures(int n, const unsigned int *textures)
{
    GLContext *c=gl_get_context();
    int i;
    GLTexture *t;

    for(i=0;i<n;i++) {
        t=find_texture(c,textures[i]);
        if (t!=NULL && t!=0) {
            if (t==c->current_texture) {
                glBindTexture(GL_TEXTURE_2D,0);
            }
            free_texture(c,textures[i]);
        }
    }
}
Esempio n. 12
0
File: list.c Progetto: plzombie/ne
void glNewList(unsigned int list,int mode)
{
  GLList *l;
  GLContext *c=gl_get_context();

  assert(mode == GL_COMPILE || mode == GL_COMPILE_AND_EXECUTE);
  assert(c->compile_flag == 0);

  l=find_list(c,list);
  if (l!=NULL) delete_list(c,list);
  l=alloc_list(c,list);

  c->current_op_buffer=l->first_op_buffer;
  c->current_op_buffer_index=0;
  
  c->compile_flag=1;
  c->exec_flag=(mode == GL_COMPILE_AND_EXECUTE);
}
Esempio n. 13
0
void glGenTextures(int n, unsigned int *textures)
{
    GLContext *c=gl_get_context();
    int max,i;
    GLTexture *t;

    max=0;
    for(i=0;i<TEXTURE_HASH_TABLE_SIZE;i++) {
        t=c->shared_state.texture_hash_table[i];
        while (t!=NULL) {
            if (t->handle>max) max=t->handle;
            t=t->next;
        }

    }
    for(i=0;i<n;i++) {
        textures[i]=max+i+1;
    }
}
Esempio n. 14
0
/* we assume here that drawable is a window */
int nglXMakeCurrent( NGLXDrawable drawable,
                     NGLXContext ctx1)
{
  TinyNGLXContext *ctx = (TinyNGLXContext *) ctx1;
  int mode, xsize, ysize;
  ZBuffer *zb;
  GR_WINDOW_INFO win_info;

  if (ctx->gl_context == NULL) {
      /* create the TinyGL context */
      GrGetWindowInfo(drawable, &win_info);

      xsize = win_info.width;
      ysize = win_info.height;

      /* currently, we only support 16 bit rendering */
      mode = ZB_MODE_5R6G5B;
      zb=ZB_open(xsize,ysize,mode,0,NULL,NULL,NULL);
      if (zb == NULL) {
          fprintf(stderr, "Error while initializing Z buffer\n");
          exit(1);
      }

      ctx->pixtype = MWPF_TRUECOLOR565;

      /* create a gc */
      ctx->gc = GrNewGC();
      
      /* initialisation of the TinyGL interpreter */
      glInit(zb);
      ctx->gl_context=gl_get_context();
      ctx->gl_context->opaque=(void *) ctx;
      ctx->gl_context->gl_resize_viewport=glX_resize_viewport;

      /* set the viewport : we force a call to glX_resize_viewport */
      ctx->gl_context->viewport.xsize=-1;
      ctx->gl_context->viewport.ysize=-1;
      
      glViewport(0, 0, xsize, ysize);
  }
  
  return 1;
}
Esempio n. 15
0
void glGetFloatv(int pname, float *v)
{
  int i;
  int mnr = 0; /* just a trick to return the correct matrix */
  GLContext *c = gl_get_context();
  switch (pname) {
  case GL_TEXTURE_MATRIX:
    mnr++; 
  case GL_PROJECTION_MATRIX:
    mnr++; 
  case GL_MODELVIEW_MATRIX:
    {
      float *p = &c->matrix_stack_ptr[mnr]->m[0][0];;
      for (i = 0; i < 4; i++) {
        *v++ = p[0];
        *v++ = p[4];
        *v++ = p[8];
        *v++ = p[12];
        p++;
      }
    } 
    break;
  case GL_LINE_WIDTH:
    *v = 1.0f;
    break;
  case GL_LINE_WIDTH_RANGE:
    v[0] = v[1] = 1.0f;
    break;
  case GL_POINT_SIZE:
    *v = 1.0f;
    break;
  case GL_POINT_SIZE_RANGE:
    v[0] = v[1] = 1.0f;
    break;
  default:
    tgl_warning("warning: unknown pname in glGetFloatv()\n");
    break;
  }
}
Esempio n. 16
0
unsigned int glGenLists(int range) {
	GLContext *c = gl_get_context();
	int count, i, list;
	GLList **lists;

	lists = c->shared_state.lists;
	count = 0;
	for (i = 0; i < MAX_DISPLAY_LISTS; i++) {
		if (!lists[i]) {
			count++;
			if (count == range) {
				list = i - range + 1;
				for (i = 0; i < range; i++) {
					alloc_list(c, list + i);
				}
				return list;
			}
		} else {
			count=0;
		}
	}
	return 0;
}
Esempio n. 17
0
			{
				for (mode=0; mode<ZB_NB_COLORS; mode++)
				{
					pal[mode].r = (ctx->palette[mode]>>16) & 0xFF;
					pal[mode].g = (ctx->palette[mode]>>8) & 0xFF;
					pal[mode].b = (ctx->palette[mode]) & 0xFF;
				}

				GAL_SetColors(surface, pal, 0, ZB_NB_COLORS);
				free(pal);
			}
		}

		// initialization of the TinyGL interpreter
		glInit( zb );
		ctx->gl_context                     = gl_get_context();
		ctx->gl_context->opaque             = (void *) ctx;
		ctx->gl_context->gl_resize_viewport = minigl_resize_viewport;

		// set original size
		ctx->gl_context->viewport.xsize = xsize;
		ctx->gl_context->viewport.ysize = ysize;
		glViewport( 0, 0, xsize, ysize );
	}

	ctx->surface = surface;

	return 1;
}

void minigl_SwapBuffers(const minigl_Context* gl_ctx, const Sint32 xOffset, const Sint32 yOffset)
Esempio n. 18
0
void glDebug(int mode)
{
  GLContext *c=gl_get_context();
  c->print_flag=mode;
}
Esempio n. 19
0
File: init.c Progetto: Masshat/almos
void glClose(void)
{
  GLContext *c=gl_get_context();
  endSharedState(c);
  gl_free(c);
}