Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increased OpenGL ES compatibility #77

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions harfbuzz/demo-harfbuzz.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ int main( int argc, char **argv )
{x0,y1,0, s0,t1, r,g,b,a, shift, gamma},
{x1,y1,0, s1,t1, r,g,b,a, shift, gamma},
{x1,y0,0, s1,t0, r,g,b,a, shift, gamma} };
GLuint indices[6] = { 0,1,2, 0,2,3 };
GLushort indices[6] = { 0,1,2, 0,2,3 };
vertex_buffer_push_back( vbuffer, vertices, 4, indices, 6 );
x += x_advance;
y += y_advance;
Expand All @@ -244,7 +244,6 @@ int main( int argc, char **argv )
glClearColor(1,1,1,1);
glEnable( GL_BLEND );
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
glEnable( GL_TEXTURE_2D );
glBindTexture( GL_TEXTURE_2D, atlas->id );
texture_atlas_upload( atlas );
vertex_buffer_upload( vbuffer );
Expand Down
4 changes: 2 additions & 2 deletions texture-atlas.c
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,8 @@ texture_atlas_upload( texture_atlas_t * self )
}
else
{
glTexImage2D( GL_TEXTURE_2D, 0, GL_RED, self->width, self->height,
0, GL_RED, GL_UNSIGNED_BYTE, self->data );
glTexImage2D( GL_TEXTURE_2D, 0, GL_LUMINANCE, self->width, self->height,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might have a conflict here with OpenGL > 3

0, GL_LUMINANCE, GL_UNSIGNED_BYTE, self->data );
}
}

24 changes: 12 additions & 12 deletions vertex-buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ vertex_buffer_new( const char *format )
self->vertices_id = 0;
self->GPU_vsize = 0;

self->indices = vector_new( sizeof(GLuint) );
self->indices = vector_new( sizeof(GLushort) );
self->indices_id = 0;
self->GPU_isize = 0;

Expand Down Expand Up @@ -445,7 +445,7 @@ vertex_buffer_render_item ( vertex_buffer_t *self,
{
size_t start = item->istart;
size_t count = item->icount;
glDrawElements( self->mode, count, GL_UNSIGNED_INT, (void *)(start*sizeof(GLuint)) );
glDrawElements( self->mode, count, GL_UNSIGNED_SHORT, (void *)(start*sizeof(GLushort)) );
}
else if( self->vertices->size )
{
Expand All @@ -466,7 +466,7 @@ vertex_buffer_render ( vertex_buffer_t *self, GLenum mode )
vertex_buffer_render_setup( self, mode );
if( icount )
{
glDrawElements( mode, icount, GL_UNSIGNED_INT, 0 );
glDrawElements( mode, icount, GL_UNSIGNED_SHORT, 0 );
}
else
{
Expand All @@ -480,7 +480,7 @@ vertex_buffer_render ( vertex_buffer_t *self, GLenum mode )
// ----------------------------------------------------------------------------
void
vertex_buffer_push_back_indices ( vertex_buffer_t * self,
const GLuint * indices,
const GLushort * indices,
const size_t icount )
{
assert( self );
Expand Down Expand Up @@ -509,7 +509,7 @@ vertex_buffer_push_back_vertices ( vertex_buffer_t * self,
void
vertex_buffer_insert_indices ( vertex_buffer_t *self,
const size_t index,
const GLuint *indices,
const GLushort *indices,
const size_t count )
{
assert( self );
Expand Down Expand Up @@ -538,9 +538,9 @@ vertex_buffer_insert_vertices( vertex_buffer_t *self,

for( i=0; i<self->indices->size; ++i )
{
if( *(GLuint *)(vector_get( self->indices, i )) > index )
if( *(GLushort *)(vector_get( self->indices, i )) > index )
{
*(GLuint *)(vector_get( self->indices, i )) += index;
*(GLushort *)(vector_get( self->indices, i )) += index;
}
}

Expand Down Expand Up @@ -582,9 +582,9 @@ vertex_buffer_erase_vertices( vertex_buffer_t *self,
self->state |= DIRTY;
for( i=0; i<self->indices->size; ++i )
{
if( *(GLuint *)(vector_get( self->indices, i )) > first )
if( *(GLushort *)(vector_get( self->indices, i )) > first )
{
*(GLuint *)(vector_get( self->indices, i )) -= (last-first);
*(GLushort *)(vector_get( self->indices, i )) -= (last-first);
}
}
vector_erase_range( self->vertices, first, last );
Expand All @@ -596,7 +596,7 @@ vertex_buffer_erase_vertices( vertex_buffer_t *self,
size_t
vertex_buffer_push_back( vertex_buffer_t * self,
const void * vertices, const size_t vcount,
const GLuint * indices, const size_t icount )
const GLushort * indices, const size_t icount )
{
return vertex_buffer_insert( self, vector_size( self->items ),
vertices, vcount, indices, icount );
Expand All @@ -606,7 +606,7 @@ vertex_buffer_push_back( vertex_buffer_t * self,
size_t
vertex_buffer_insert( vertex_buffer_t * self, const size_t index,
const void * vertices, const size_t vcount,
const GLuint * indices, const size_t icount )
const GLushort * indices, const size_t icount )
{
size_t vstart, istart, i;
ivec4 item;
Expand All @@ -627,7 +627,7 @@ vertex_buffer_insert( vertex_buffer_t * self, const size_t index,
// Update indices within the vertex buffer
for( i=0; i<icount; ++i )
{
*(GLuint *)(vector_get( self->indices, istart+i )) += vstart;
*(GLushort *)(vector_get( self->indices, istart+i )) += vstart;
}

// Insert item
Expand Down
8 changes: 4 additions & 4 deletions vertex-buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ typedef struct vertex_buffer_t
*/
void
vertex_buffer_push_back_indices ( vertex_buffer_t *self,
const GLuint * indices,
const GLushort * indices,
const size_t icount );


Expand Down Expand Up @@ -255,7 +255,7 @@ typedef struct vertex_buffer_t
void
vertex_buffer_insert_indices ( vertex_buffer_t *self,
const size_t index,
const GLuint *indices,
const GLushort *indices,
const size_t icount );


Expand Down Expand Up @@ -316,7 +316,7 @@ typedef struct vertex_buffer_t
size_t
vertex_buffer_push_back( vertex_buffer_t * self,
const void * vertices, const size_t vcount,
const GLuint * indices, const size_t icount );
const GLushort * indices, const size_t icount );


/**
Expand All @@ -333,7 +333,7 @@ typedef struct vertex_buffer_t
vertex_buffer_insert( vertex_buffer_t * self,
const size_t index,
const void * vertices, const size_t vcount,
const GLuint * indices, const size_t icount );
const GLushort * indices, const size_t icount );

/**
* Erase an item from the vertex buffer.
Expand Down