Esempio n. 1
0
void GLAPIENTRY
sav_Materiali (GLenum face, GLenum pname, GLint param)
{
    gl_assert(face == GL_FRONT || face == GL_BACK || face == GL_FRONT_AND_BACK);
    gl_assert(pname == GL_SHININESS);

    MAT_F(1, face, pname, (GLfloat)param, 0.0F, 0.0F, 0.0F);
}
Esempio n. 2
0
File: api.c Progetto: bhdminh/uGFX
void glPolygonMode(int face,int mode)
{
  GLParam p[3];

  gl_assert(face == GL_BACK ||
         face == GL_FRONT || 
         face == GL_FRONT_AND_BACK);
  gl_assert(mode == GL_POINT || mode == GL_LINE || mode==GL_FILL);

  p[0].op=OP_PolygonMode;
  p[1].i=face;
  p[2].i=mode;

  gl_add_op(p);
}
Esempio n. 3
0
File: light.c Progetto: dborca/sage
void GLAPIENTRY
imm_ColorMaterial (GLenum face, GLenum mode)
{
    gl_assert(face == GL_FRONT || face == GL_BACK || face == GL_FRONT_AND_BACK);
    gl_assert(mode == GL_EMISSION || mode == GL_AMBIENT || mode == GL_DIFFUSE ||
	      mode == GL_SPECULAR || mode == GL_AMBIENT_AND_DIFFUSE);
    /* XXX must be outside begin/end */

    FLUSH_VERTICES();

    ctx_colormat_face = face;
    ctx_colormat_mode = mode;

    ctx_gl_state |= NEW_LIGHT;
}
Esempio n. 4
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. 5
0
void
uniform_vec4ui::apply_value(const render_context& context, const program& p)
{
    const opengl::gl_core& glapi = context.opengl_api();
    glapi.glUniform4uiv(_location, _elements, (_value.front().data_array));//_value.data_array);
    gl_assert(glapi, leaving uniform_vec4ui::apply_value());
}
Esempio n. 6
0
void
uniform_image_sampler_base::apply_value(const render_context& context, const program& p)
{
    const opengl::gl_core& glapi = context.opengl_api();
#if SCM_GL_CORE_USE_EXT_DIRECT_STATE_ACCESS
    if (_bound_unit >= 0) {
        glapi.glProgramUniform1i(p.program_id(), _location, _bound_unit);
    }
    else if (   glapi.extension_ARB_bindless_texture
             && _resident_handle != 0ull)
    {
        glapi.glProgramUniformHandleui64ARB(p.program_id(), _location, _resident_handle);
    }
#else
    if (_bound_unit >= 0) {
        glapi.glUniform1i(_location, _bound_unit);
    }
    else if (   glapi.extension_ARB_bindless_texture
             && _resident_handle != 0ull)
    {
        glapi.glUniformHandleui64ARB(_location, _resident_handle);
    }
#endif
    gl_assert(glapi, leaving uniform_1f::apply_value());

}
Esempio n. 7
0
void GLAPIENTRY
sav_DrawElements (GLenum mode, GLsizei count,
                  GLenum type, const GLvoid *indices)
{
    GLsizei i;

    sav_Begin(mode);
    switch (type) {
	case GL_UNSIGNED_BYTE: {
	    GLubyte *ptr = (GLubyte *)indices;
	    for (i = 0; i < count; i++) {
		sav_ArrayElement(ptr[i]);
	    }
	    break;
	}
	case GL_UNSIGNED_SHORT: {
	    GLushort *ptr = (GLushort *)indices;
	    for (i = 0; i < count; i++) {
		sav_ArrayElement(ptr[i]);
	    }
	    break;
	}
	case GL_UNSIGNED_INT: {
	    GLuint *ptr = (GLuint *)indices;
	    for (i = 0; i < count; i++) {
		sav_ArrayElement(ptr[i]);
	    }
	    break;
	}
	default:
	    gl_assert(0);
	    break;
    }
    sav_End();
}
Esempio n. 8
0
transform_feedback::transform_feedback(      render_device&         in_device,
                                       const stream_output_setup&   in_setup)
  : render_device_child(in_device)
  , _stream_out_setup(in_setup)
  , _active(false)
  , _captured_topology(PRIMITIVE_POINTS)
{
    if (SCM_GL_CORE_OPENGL_TYPE >= SCM_GL_CORE_OPENGL_CORE_VERSION_400) {
        const opengl::gl_core& glapi = in_device.opengl_api();
        util::gl_error          glerror(glapi);

        glapi.glGenTransformFeedbacks(1, &(context_bindable_object::_gl_object_id));
        if (0 == object_id()) {
            state().set(object_state::OS_BAD);
        }
        else {
            context_bindable_object::_gl_object_target  = GL_TRANSFORM_FEEDBACK;
            context_bindable_object::_gl_object_binding = GL_TRANSFORM_FEEDBACK_BINDING;

            if (!initialize_transform_feedback_object(in_device)) {
                // the state is set in the functions to more detailed error states
            }
        }
        gl_assert(glapi, leaving transform_feedback::transform_feedback());
    }
}
Esempio n. 9
0
void 
glEnableClientState(GLenum array)
{
  GLParam p[2];
  p[0].op = OP_EnableClientState;
  
  switch(array) {
  case GL_VERTEX_ARRAY:
    p[1].i = VERTEX_ARRAY;
    break;  
  case GL_NORMAL_ARRAY:
    p[1].i = NORMAL_ARRAY;
    break;
  case GL_COLOR_ARRAY:
    p[1].i = COLOR_ARRAY;
    break;
  case GL_TEXTURE_COORD_ARRAY:
    p[1].i = TEXCOORD_ARRAY;
    break;
  default:
    gl_assert(0);
    break;
  }
  gl_add_op(p);
}
Esempio n. 10
0
void ZB_copyFrameBuffer(ZBuffer * zb, void *buf,
			int linesize)
{
    switch (zb->mode) {
#ifdef TGL_FEATURE_8_BITS
    case ZB_MODE_INDEX:
	ZB_ditherFrameBuffer(zb, buf, linesize >> 1);
	break;
#endif
#ifdef TGL_FEATURE_16_BITS
    case ZB_MODE_5R6G5B:
	ZB_copyBuffer(zb, buf, linesize);
	break;
#endif
#ifdef TGL_FEATURE_32_BITS
    case ZB_MODE_RGBA:
	ZB_copyFrameBufferRGB32(zb, buf, linesize >> 1);
	break;
#endif
#ifdef TGL_FEATURE_24_BITS
    case ZB_MODE_RGB24:
	ZB_copyFrameBufferRGB24(zb, buf, linesize >> 1);
	break;
#endif
    default:
	gl_assert(0);
    }
}
Esempio n. 11
0
void
uniform_1ui::apply_value(const render_context& context, const program& p)
{
    const opengl::gl_core& glapi = context.opengl_api();
    glapi.glUniform1uiv(_location, _elements, &(_value.front()));//&_value);
    gl_assert(glapi, leaving uniform_1ui::apply_value());
}
Esempio n. 12
0
void GLAPIENTRY
sav_Materialiv (GLenum face, GLenum pname, const GLint *params)
{
    gl_assert(face == GL_FRONT || face == GL_BACK || face == GL_FRONT_AND_BACK);

    gl_assert(pname == GL_AMBIENT ||
	      pname == GL_DIFFUSE ||
	      pname == GL_SPECULAR ||
	      pname == GL_EMISSION ||
	      pname == GL_SHININESS ||
	      pname == GL_AMBIENT_AND_DIFFUSE);

    if (pname != GL_SHININESS) {
	MAT_F(4, face, pname, I_TO_FLOAT(params[0]), I_TO_FLOAT(params[1]), I_TO_FLOAT(params[2]), I_TO_FLOAT(params[3]));
    } else {
	MAT_F(1, face, pname, (GLfloat)params[0], 0.0F, 0.0F, 0.0F);
    }
}
Esempio n. 13
0
void glopPopMatrix(GLContext *c,GLParam *p)
{
  int n=c->matrix_mode;
  (void)p;

  gl_assert( c->matrix_stack_ptr[n] > c->matrix_stack[n] );
  c->matrix_stack_ptr[n]--;
  gl_matrix_update(c);
}
Esempio n. 14
0
File: query.cpp Progetto: 4og/schism
query::~query()
{
    const opengl::gl_core& glapi = parent_device().opengl_api();

    assert(0 != _gl_query_id);
    glapi.glDeleteQueries(1, &_gl_query_id);
    
    gl_assert(glapi, leaving query::~query());
}
Esempio n. 15
0
transform_feedback::~transform_feedback()
{
    if (SCM_GL_CORE_OPENGL_TYPE >= SCM_GL_CORE_OPENGL_CORE_VERSION_400) {
        const opengl::gl_core& glapi = parent_device().opengl_api();

        assert(0 != object_id());
        glapi.glDeleteTransformFeedbacks(1, &(context_bindable_object::_gl_object_id));

        gl_assert(glapi, leaving transform_feedback::~transform_feedback());
    }
}
Esempio n. 16
0
File: sync.cpp Progetto: 4og/schism
void
sync::delete_sync()
{
    if (_gl_sync_object) {
        const opengl::gl_core& glapi = parent_device().opengl_api();
        glapi.glDeleteSync(_gl_sync_object);
        _gl_sync_object = 0;//nullptr;

        gl_assert(glapi, leaving sync::~delete_sync());
    }
}
Esempio n. 17
0
File: sync.cpp Progetto: 4og/schism
void
sync::server_wait(const render_context& in_context,
                        scm::uint64     in_timeout) const
{
    const opengl::gl_core& glapi = in_context.opengl_api();
    assert(0 != object());

    glapi.glWaitSync(object(), 0, sync_timeout_ignored);

    gl_assert(glapi, leaving sync::server_wait());
}
Esempio n. 18
0
File: query.cpp Progetto: 4og/schism
void
query::end(const render_context& in_context) const
{
    const opengl::gl_core& glapi = in_context.opengl_api();
    assert(0 != query_id());
    assert(0 != query_type());

    glapi.glEndQuery(query_type());

    gl_assert(glapi, leaving query::end());
}
Esempio n. 19
0
File: api.c Progetto: bhdminh/uGFX
void glShadeModel(int mode)
{
  GLParam p[2];

  gl_assert(mode == GL_FLAT || mode == GL_SMOOTH);

  p[0].op=OP_ShadeModel;
  p[1].i=mode;

  gl_add_op(p);
}
Esempio n. 20
0
void 
glNormalPointer(GLenum type, GLsizei stride, 
                const GLvoid *pointer)
{
  GLParam p[3];
  gl_assert(type == GL_FLOAT);
  p[0].op = OP_NormalPointer;
  p[1].i = stride;
  p[2].p = (void*)pointer;
  gl_add_op(p);
}
Esempio n. 21
0
File: light.c Progetto: dborca/sage
void GLAPIENTRY
imm_ShadeModel (GLenum mode)
{
    gl_assert(mode == GL_SMOOTH || mode == GL_FLAT);

    FLUSH_VERTICES();

    ctx_shade_model = mode;

    ctx_gl_state |= 0; /* XXX GULP!?! */
}
Esempio n. 22
0
void 
glTexCoordPointer(GLint size, GLenum type, GLsizei stride, 
                  const GLvoid *pointer)
{
  GLParam p[4];
  gl_assert(type == GL_FLOAT);
  p[0].op = OP_TexCoordPointer;
  p[1].i = size;
  p[2].i = stride;
  p[3].p = (void*)pointer;
  gl_add_op(p);
}
Esempio n. 23
0
ostgl_context *
ostgl_create_context(const int xsize,
                     const int ysize,
                     const int depth,
                     void **framebuffers,
                     const int numbuffers)
{
  ostgl_context *context;
  int i;
  ZBuffer *zb;
   
  gl_assert(depth == 16); /* support for other depths must include bpp
                          convertion */
  gl_assert(numbuffers >= 1);
  
  context = gl_malloc(sizeof(ostgl_context));
  gl_assert(context);
  context->zbs = gl_malloc(sizeof(void*)*numbuffers);
  context->framebuffers = gl_malloc(sizeof(void*)*numbuffers);
  
  gl_assert(context->zbs != NULL && context->framebuffers != NULL);
  
  for (i = 0; i < numbuffers; i++) {
    context->framebuffers[i] = framebuffers[i];
    zb = ZB_open(xsize, ysize, ZB_MODE_5R6G5B, 0, NULL, NULL, framebuffers[i]);
    if (zb == NULL) {
      fprintf(stderr, "Error while initializing Z buffer\n");
      exit(1);
    }
    context->zbs[i] = zb;
  }
  if (++buffercnt == 1) {
    glInit(context->zbs[0]);
  }
  context->xsize = xsize;
  context->ysize = ysize;
  context->numbuffers = numbuffers;
  return context;
}
Esempio n. 24
0
File: api.c Progetto: bhdminh/uGFX
void glCullFace(int mode)
{
  GLParam p[2];

  gl_assert(mode == GL_BACK ||
         mode == GL_FRONT || 
         mode == GL_FRONT_AND_BACK);

  p[0].op=OP_CullFace;
  p[1].i=mode;

  gl_add_op(p);
}
Esempio n. 25
0
File: api.c Progetto: bhdminh/uGFX
void glFrontFace(int mode)
{
  GLParam p[2];

  gl_assert(mode == GL_CCW || mode == GL_CW);

  mode = (mode != GL_CCW);

  p[0].op=OP_FrontFace;
  p[1].i=mode;

  gl_add_op(p);
}
Esempio n. 26
0
File: query.cpp Progetto: 4og/schism
query::query(render_device& in_device)
  : render_device_child(in_device)
  , _index(0)
  , _gl_query_id(0)
  , _gl_query_type(0)
{
    const opengl::gl_core& glapi = in_device.opengl_api();

    glapi.glGenQueries(1, &_gl_query_id);
    if (0 == _gl_query_id) {
        state().set(object_state::OS_BAD);
    }

    gl_assert(glapi, leaving query::query());
}
Esempio n. 27
0
File: query.cpp Progetto: 4og/schism
bool
query::available(const render_context& in_context) const
{
    const opengl::gl_core& glapi = in_context.opengl_api();
    assert(0 != query_id());
    assert(0 != query_type());

    int query_available = GL_FALSE;

    glapi.glGetQueryObjectiv(query_id(), GL_QUERY_RESULT_AVAILABLE, &query_available);
    
    gl_assert(glapi, leaving query::available());

    return query_available != GL_FALSE;
}
Esempio n. 28
0
void glopPushMatrix(GLContext *c,GLParam *p)
{
  int n=c->matrix_mode;
  M4 *m;
  (void)p;

  gl_assert( (c->matrix_stack_ptr[n] - c->matrix_stack[n] + 1 )
	   < c->matrix_stack_depth_max[n] );

  m=++c->matrix_stack_ptr[n];
  
  gl_M4_Move(&m[0],&m[-1]);

  gl_matrix_update(c);
}
Esempio n. 29
0
File: api.c Progetto: bhdminh/uGFX
void glMaterialfv(int mode,int type,float *v)
{
  GLParam p[7];
  int i,n;

  gl_assert(mode == GL_FRONT  || mode == GL_BACK || mode==GL_FRONT_AND_BACK);

  p[0].op=OP_Material;
  p[1].i=mode;
  p[2].i=type;
  n=4;
  if (type == GL_SHININESS) n=1;
  for(i=0;i<4;i++) p[3+i].f=v[i];
  for(i=n;i<4;i++) p[3+i].f=0;

  gl_add_op(p);
}
Esempio n. 30
0
void glopMatrixMode(GLContext *c,GLParam *p)
{
  int mode=p[1].i;
  switch(mode) {
  case GL_MODELVIEW:
    c->matrix_mode=0;
    break;
  case GL_PROJECTION:
    c->matrix_mode=1;
    break;
  case GL_TEXTURE:
    c->matrix_mode=2;
    break;
  default:
    gl_assert(0);
  }
}