Merge branch 'master' of gitlab.com:simulant/GLdc
This commit is contained in:
commit
07c8fadc23
10
.gitlab-ci.yml
Normal file
10
.gitlab-ci.yml
Normal file
|
@ -0,0 +1,10 @@
|
|||
stages:
|
||||
- build
|
||||
|
||||
build:sh4-gcc:
|
||||
stage: build
|
||||
image: kazade/dreamcast-sdk
|
||||
script:
|
||||
- source /etc/bash.bashrc
|
||||
- make clean
|
||||
- make samples
|
41
GL/texture.c
41
GL/texture.c
|
@ -171,24 +171,28 @@ GLboolean APIENTRY glIsTexture(GLuint texture) {
|
|||
return (named_array_used(&TEXTURE_OBJECTS, texture)) ? GL_TRUE : GL_FALSE;
|
||||
}
|
||||
|
||||
static void _glInitializeTextureObject(TextureObject* txr, unsigned int id) {
|
||||
txr->index = id;
|
||||
txr->width = txr->height = 0;
|
||||
txr->mipmap = 0;
|
||||
txr->uv_clamp = 0;
|
||||
txr->env = PVR_TXRENV_MODULATEALPHA;
|
||||
txr->data = NULL;
|
||||
txr->mipmapCount = 0;
|
||||
txr->minFilter = GL_NEAREST;
|
||||
txr->magFilter = GL_NEAREST;
|
||||
txr->palette = NULL;
|
||||
txr->isCompressed = GL_FALSE;
|
||||
txr->isPaletted = GL_FALSE;
|
||||
}
|
||||
|
||||
void APIENTRY glGenTextures(GLsizei n, GLuint *textures) {
|
||||
TRACE();
|
||||
|
||||
while(n--) {
|
||||
GLuint id = 0;
|
||||
TextureObject* txr = (TextureObject*) named_array_alloc(&TEXTURE_OBJECTS, &id);
|
||||
txr->index = id;
|
||||
txr->width = txr->height = 0;
|
||||
txr->mipmap = 0;
|
||||
txr->uv_clamp = 0;
|
||||
txr->env = PVR_TXRENV_MODULATEALPHA;
|
||||
txr->data = NULL;
|
||||
txr->mipmapCount = 0;
|
||||
txr->minFilter = GL_NEAREST;
|
||||
txr->magFilter = GL_NEAREST;
|
||||
txr->palette = NULL;
|
||||
txr->isCompressed = GL_FALSE;
|
||||
txr->isPaletted = GL_FALSE;
|
||||
_glInitializeTextureObject(txr, id);
|
||||
|
||||
*textures = id;
|
||||
|
||||
|
@ -237,6 +241,13 @@ void APIENTRY glBindTexture(GLenum target, GLuint texture) {
|
|||
return;
|
||||
}
|
||||
|
||||
/* If this didn't come from glGenTextures, then we should initialize the
|
||||
* texture the first time it's bound */
|
||||
if(!named_array_used(&TEXTURE_OBJECTS, texture)) {
|
||||
TextureObject* txr = named_array_reserve(&TEXTURE_OBJECTS, texture);
|
||||
_glInitializeTextureObject(txr, texture);
|
||||
}
|
||||
|
||||
if(texture) {
|
||||
TEXTURE_UNITS[ACTIVE_TEXTURE] = (TextureObject*) named_array_get(&TEXTURE_OBJECTS, texture);
|
||||
} else {
|
||||
|
@ -533,6 +544,10 @@ static inline void _rgba8888_to_rgba8888(const GLubyte* source, GLubyte* dest) {
|
|||
dst[3] = source[3];
|
||||
}
|
||||
|
||||
static inline void _rgba8888_to_rgb565(const GLubyte* source, GLubyte* dest) {
|
||||
*((GLushort*) dest) = ((source[0] & 0b11111000) << 8) | ((source[1] & 0b11111100) << 3) | (source[2] >> 3);
|
||||
}
|
||||
|
||||
static inline void _rgb888_to_rgba8888(const GLubyte* source, GLubyte* dest) {
|
||||
/* Noop */
|
||||
GLubyte* dst = (GLubyte*) dest;
|
||||
|
@ -594,6 +609,8 @@ static TextureConversionFunc _determineConversion(GLint internalFormat, GLenum f
|
|||
case GL_RGB: {
|
||||
if(type == GL_UNSIGNED_BYTE && format == GL_RGB) {
|
||||
return _rgb888_to_rgb565;
|
||||
} else if(type == GL_UNSIGNED_BYTE && format == GL_RGBA) {
|
||||
return _rgba8888_to_rgb565;
|
||||
} else if(type == GL_BYTE && format == GL_RGB) {
|
||||
return _rgb888_to_rgb565;
|
||||
} else if(type == GL_UNSIGNED_BYTE && format == GL_RED) {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#ifndef __APPLE__
|
||||
#include <malloc.h>
|
||||
|
@ -57,6 +58,23 @@ void* named_array_alloc(NamedArray* array, unsigned int* new_id) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void* named_array_reserve(NamedArray* array, unsigned int id) {
|
||||
if(!named_array_used(array, id)) {
|
||||
unsigned int j = id % 8;
|
||||
unsigned int i = (id - j) / 8;
|
||||
|
||||
assert(!named_array_used(array, id));
|
||||
array->used_markers[i] |= (unsigned char) 1 << j;
|
||||
assert(named_array_used(array, id));
|
||||
|
||||
unsigned char* ptr = &array->elements[(id - 1) * array->element_size];
|
||||
memset(ptr, 0, array->element_size);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
return named_array_get(array, id);
|
||||
}
|
||||
|
||||
void named_array_release(NamedArray* array, unsigned int new_id) {
|
||||
new_id--;
|
||||
|
||||
|
|
|
@ -15,7 +15,10 @@ typedef struct {
|
|||
|
||||
void named_array_init(NamedArray* array, unsigned int element_size, unsigned int max_elements);
|
||||
char named_array_used(NamedArray* array, unsigned int id);
|
||||
|
||||
void* named_array_alloc(NamedArray* array, unsigned int* new_id);
|
||||
void* named_array_reserve(NamedArray* array, unsigned int id);
|
||||
|
||||
void named_array_release(NamedArray* array, unsigned int new_id);
|
||||
void* named_array_get(NamedArray* array, unsigned int id);
|
||||
void named_array_cleanup(NamedArray* array);
|
||||
|
|
Loading…
Reference in New Issue
Block a user