Merge pull request #861 from lakkatv/lakka

(Lakka) Remove libpng dependancy and use lowercase variables
This commit is contained in:
Twinaphex 2014-08-08 23:31:36 +02:00
commit d5d238c076
3 changed files with 171 additions and 302 deletions

View File

@ -43,7 +43,7 @@ static void lakka_switch_categories(void)
int i, j;
// translation
add_tween(DELAY, -menu_active_category * HSPACING, &all_categories_x, &inOutQuad, NULL);
add_tween(DELAY, -menu_active_category * hspacing, &all_categories_x, &inOutQuad, NULL);
// alpha tweening
for (i = 0; i < num_categories; i++)
@ -55,7 +55,7 @@ static void lakka_switch_categories(void)
continue;
ca = (i == menu_active_category) ? 1.0 : 0.5;
cz = (i == menu_active_category) ? C_ACTIVE_ZOOM : C_PASSIVE_ZOOM;
cz = (i == menu_active_category) ? c_active_zoom : c_passive_zoom;
add_tween(DELAY, ca, &category->alpha, &inOutQuad, NULL);
add_tween(DELAY, cz, &category->zoom, &inOutQuad, NULL);
@ -83,10 +83,10 @@ static void lakka_switch_items(void)
continue;
ia = (j == active_category->active_item) ? 1.0 : 0.5;
iz = (j == active_category->active_item) ? I_ACTIVE_ZOOM : I_PASSIVE_ZOOM;
iy = (j == active_category->active_item) ? VSPACING*ACTIVE_ITEM_FACTOR :
(j < active_category->active_item) ? VSPACING*(j - active_category->active_item + ABOVE_ITEM_OFFSET) :
VSPACING*(j - active_category->active_item + UNDER_ITEM_OFFSET);
iz = (j == active_category->active_item) ? i_active_zoom : i_passive_zoom;
iy = (j == active_category->active_item) ? vspacing*active_item_factor :
(j < active_category->active_item) ? vspacing*(j - active_category->active_item + above_item_offset) :
vspacing*(j - active_category->active_item + under_item_offset);
add_tween(DELAY, ia, &active_item->alpha, &inOutQuad, NULL);
add_tween(DELAY, iz, &active_item->zoom, &inOutQuad, NULL);
@ -111,22 +111,22 @@ static void lakka_switch_subitems(void)
{
// Above items
add_tween(DELAY, 0.5, &subitem->alpha, &inOutQuad, NULL);
add_tween(DELAY, VSPACING*(k - item->active_subitem + ABOVE_SUBITEM_OFFSET), &subitem->y, &inOutQuad, NULL);
add_tween(DELAY, I_PASSIVE_ZOOM, &subitem->zoom, &inOutQuad, NULL);
add_tween(DELAY, vspacing*(k - item->active_subitem + above_subitem_offset), &subitem->y, &inOutQuad, NULL);
add_tween(DELAY, i_passive_zoom, &subitem->zoom, &inOutQuad, NULL);
}
else if (k == item->active_subitem)
{
// Active item
add_tween(DELAY, 1.0, &subitem->alpha, &inOutQuad, NULL);
add_tween(DELAY, VSPACING*ACTIVE_ITEM_FACTOR, &subitem->y, &inOutQuad, NULL);
add_tween(DELAY, I_ACTIVE_ZOOM, &subitem->zoom, &inOutQuad, NULL);
add_tween(DELAY, vspacing*active_item_factor, &subitem->y, &inOutQuad, NULL);
add_tween(DELAY, i_active_zoom, &subitem->zoom, &inOutQuad, NULL);
}
else if (k > item->active_subitem)
{
// Under items
add_tween(DELAY, 0.5, &subitem->alpha, &inOutQuad, NULL);
add_tween(DELAY, VSPACING*(k - item->active_subitem + UNDER_ITEM_OFFSET), &subitem->y, &inOutQuad, NULL);
add_tween(DELAY, I_PASSIVE_ZOOM, &subitem->zoom, &inOutQuad, NULL);
add_tween(DELAY, vspacing*(k - item->active_subitem + under_item_offset), &subitem->y, &inOutQuad, NULL);
add_tween(DELAY, i_passive_zoom, &subitem->zoom, &inOutQuad, NULL);
}
}
}
@ -161,8 +161,8 @@ static void lakka_reset_submenu(void)
continue;
subitem->alpha = 0;
subitem->zoom = k == category->items[j].active_subitem ? I_ACTIVE_ZOOM : I_PASSIVE_ZOOM;
subitem->y = k == 0 ? VSPACING * ACTIVE_ITEM_FACTOR : VSPACING * (3+k);
subitem->zoom = k == category->items[j].active_subitem ? i_active_zoom : i_passive_zoom;
subitem->y = k == 0 ? vspacing * active_item_factor : vspacing * (3+k);
}
}
}
@ -172,7 +172,7 @@ static void lakka_reset_submenu(void)
static void lakka_open_submenu(void)
{
int i, j, k;
add_tween(DELAY, -HSPACING * (menu_active_category+1), &all_categories_x, &inOutQuad, NULL);
add_tween(DELAY, -hspacing * (menu_active_category+1), &all_categories_x, &inOutQuad, NULL);
add_tween(DELAY, 1.0, &arrow_alpha, &inOutQuad, NULL);
// Reset contextual menu style
@ -202,12 +202,12 @@ static void lakka_open_submenu(void)
if (k == category->items[j].active_subitem)
{
add_tween(DELAY, 1.0, &subitem->alpha, &inOutQuad, NULL);
add_tween(DELAY, I_ACTIVE_ZOOM, &subitem->zoom, &inOutQuad, NULL);
add_tween(DELAY, i_active_zoom, &subitem->zoom, &inOutQuad, NULL);
}
else
{
add_tween(DELAY, 0.5, &subitem->alpha, &inOutQuad, NULL);
add_tween(DELAY, I_PASSIVE_ZOOM, &subitem->zoom, &inOutQuad, NULL);
add_tween(DELAY, i_passive_zoom, &subitem->zoom, &inOutQuad, NULL);
}
}
}
@ -221,7 +221,7 @@ static void lakka_open_submenu(void)
static void lakka_close_submenu(void)
{
int i, j, k;
add_tween(DELAY, -HSPACING * menu_active_category, &all_categories_x, &inOutQuad, NULL);
add_tween(DELAY, -hspacing * menu_active_category, &all_categories_x, &inOutQuad, NULL);
add_tween(DELAY, 0.0, &arrow_alpha, &inOutQuad, NULL);
for (i = 0; i < num_categories; i++)
@ -234,7 +234,7 @@ static void lakka_close_submenu(void)
if (i == menu_active_category)
{
add_tween(DELAY, 1.0, &category->alpha, &inOutQuad, NULL);
add_tween(DELAY, C_ACTIVE_ZOOM, &category->zoom, &inOutQuad, NULL);
add_tween(DELAY, c_active_zoom, &category->zoom, &inOutQuad, NULL);
for (j = 0; j < category->num_items; j++)
{
@ -252,7 +252,7 @@ static void lakka_close_submenu(void)
else
{
add_tween(DELAY, 0.5, &category->alpha, &inOutQuad, NULL);
add_tween(DELAY, C_PASSIVE_ZOOM, &category->zoom, &inOutQuad, NULL);
add_tween(DELAY, c_passive_zoom, &category->zoom, &inOutQuad, NULL);
for (j = 0; j < category->num_items; j++)
add_tween(DELAY, 0, &category->items[j].alpha, &inOutQuad, NULL);

View File

@ -40,7 +40,6 @@
#include "../../../gfx/fonts/bitmap.h"
#include "lakka.h"
#include <png.h>
// Category variables
menu_category_t *categories;
@ -50,36 +49,43 @@ int menu_active_category = 0;
float all_categories_x = 0;
float global_alpha = 0;
float arrow_alpha = 0;
float HSPACING;
float VSPACING;
float C_ACTIVE_ZOOM;
float C_PASSIVE_ZOOM;
float I_ACTIVE_ZOOM;
float I_PASSIVE_ZOOM;
float FONT_SIZE;
float MARGIN_LEFT;
float MARGIN_TOP;
float TITLE_MARGIN_LEFT;
float TITLE_MARGIN_TOP;
float LABEL_MARGIN_LEFT;
float LABEL_MARGIN_TOP;
int ICON_SIZE;
char ICON_DIR[3];
float ABOVE_SUBITEM_OFFSET;
float ABOVE_ITEM_OFFSET;
float ACTIVE_ITEM_FACTOR;
float UNDER_ITEM_OFFSET;
float hspacing;
float vspacing;
float c_active_zoom;
float c_passive_zoom;
float i_active_zoom;
float i_passive_zoom;
float lakka_font_size;
float margin_left;
float margin_top;
float title_margin_left;
float title_margin_top;
float label_margin_left;
float label_margin_top;
int icon_size;
char icon_dir[3];
float above_subitem_offset;
float above_item_offset;
float active_item_factor;
float under_item_offset;
// Font variables
void *font;
const gl_font_renderer_t *font_driver;
char font_path[PATH_MAX];
static const GLfloat vtest[] = {
static const GLfloat vertex[] = {
0, 0,
1, 0,
0, 1,
1, 1
1, 1,
};
static const GLfloat tex_coord[] = {
0, 1,
1, 1,
0, 0,
1, 0,
};
enum
@ -117,76 +123,76 @@ static void lakka_responsive(void)
if (!gl)
return;
C_ACTIVE_ZOOM = 1.0;
C_PASSIVE_ZOOM = 0.5;
I_ACTIVE_ZOOM = 1.0;
I_PASSIVE_ZOOM = 0.5;
c_active_zoom = 1.0;
c_passive_zoom = 0.5;
i_active_zoom = 1.0;
i_passive_zoom = 0.5;
ABOVE_SUBITEM_OFFSET = 1.5;
ABOVE_ITEM_OFFSET = -1.0;
ACTIVE_ITEM_FACTOR = 2.25;
UNDER_ITEM_OFFSET = 3.0;
above_subitem_offset = 1.5;
above_item_offset = -1.0;
active_item_factor = 2.25;
under_item_offset = 3.0;
if (gl->win_width >= 2560)
{
ICON_SIZE = 256;
HSPACING = 400;
VSPACING = 128;
FONT_SIZE = 42.0;
MARGIN_LEFT = 200.0;
MARGIN_TOP = 384.0;
TITLE_MARGIN_LEFT = 20.0;
TITLE_MARGIN_TOP = 50.0;
LABEL_MARGIN_LEFT = 128 + 16.0;
LABEL_MARGIN_TOP = 15;
strcpy(ICON_DIR, "256");
icon_size = 256;
hspacing = 400;
vspacing = 128;
lakka_font_size = 42.0;
margin_left = 200.0;
margin_top = 384.0;
title_margin_left = 20.0;
title_margin_top = 50.0;
label_margin_left = 128 + 16.0;
label_margin_top = 15;
strcpy(icon_dir, "256");
return;
}
if (gl->win_width >= 1920)
if (1)//(gl->win_width >= 1920)
{
ICON_SIZE = 192;
HSPACING = 300;
VSPACING = 96;
FONT_SIZE = 32.0;
MARGIN_LEFT = 156.0;
MARGIN_TOP = 288.0;
TITLE_MARGIN_LEFT = 15.0;
TITLE_MARGIN_TOP = 40.0;
LABEL_MARGIN_LEFT = 96.0 + 12.0;
LABEL_MARGIN_TOP = 11.0;
strcpy(ICON_DIR, "192");
icon_size = 192;
hspacing = 300;
vspacing = 96;
lakka_font_size = 32.0;
margin_left = 156.0;
margin_top = 288.0;
title_margin_left = 15.0;
title_margin_top = 40.0;
label_margin_left = 96.0 + 12.0;
label_margin_top = 11.0;
strcpy(icon_dir, "192");
return;
}
if (gl->win_width <= 640)
{
ICON_SIZE = 64;
HSPACING = 100.0;
VSPACING = 32.0;
FONT_SIZE = 16;
MARGIN_LEFT = 60.0;
MARGIN_TOP = 96.0;
TITLE_MARGIN_LEFT = 10.0;
TITLE_MARGIN_TOP = 24.0;
LABEL_MARGIN_LEFT = 32.0 + 4.0;
LABEL_MARGIN_TOP = 6.0;
strcpy(ICON_DIR, "64");
icon_size = 64;
hspacing = 100.0;
vspacing = 32.0;
lakka_font_size = 16;
margin_left = 60.0;
margin_top = 96.0;
title_margin_left = 10.0;
title_margin_top = 24.0;
label_margin_left = 32.0 + 4.0;
label_margin_top = 6.0;
strcpy(icon_dir, "64");
return;
}
ICON_SIZE = 128;
HSPACING = 200.0;
VSPACING = 64.0;
FONT_SIZE = 24;
MARGIN_LEFT = 120.0;
MARGIN_TOP = 192.0;
TITLE_MARGIN_LEFT = 15.0;
TITLE_MARGIN_TOP = 35.0;
LABEL_MARGIN_LEFT = 64.0 + 8.0;
LABEL_MARGIN_TOP = 8.0;
strcpy(ICON_DIR, "128");
icon_size = 128;
hspacing = 200.0;
vspacing = 64.0;
lakka_font_size = 24;
margin_left = 120.0;
margin_top = 192.0;
title_margin_left = 15.0;
title_margin_top = 35.0;
label_margin_left = 64.0 + 8.0;
label_margin_top = 8.0;
strcpy(icon_dir, "128");
}
static char *str_replace (const char *string, const char *substr, const char *replacement)
@ -312,7 +318,7 @@ static void lakka_draw_text(const char *str, float x, float y, float scale, floa
if (!gl)
return;
if (x < -ICON_SIZE || x > gl->win_width + ICON_SIZE || y < -ICON_SIZE || y > gl->win_height + ICON_SIZE)
if (x < -icon_size || x > gl->win_width + icon_size || y < -icon_size || y > gl->win_height + icon_size)
return;
gl_set_viewport(gl, gl->win_width, gl->win_height, false, false);
@ -347,8 +353,8 @@ void lakka_draw_background(void)
glEnable(GL_BLEND);
gl->coords.vertex = vtest;
gl->coords.tex_coord = vtest;
gl->coords.vertex = vertex;
gl->coords.tex_coord = tex_coord;
gl->coords.color = color;
glBindTexture(GL_TEXTURE_2D, textures[TEXTURE_BG].id);
@ -376,7 +382,7 @@ void lakka_draw_icon(GLuint texture, float x, float y, float alpha, float rotati
if (!gl)
return;
if (x < -ICON_SIZE || x > gl->win_width + ICON_SIZE || y < -ICON_SIZE || y > gl->win_height + ICON_SIZE)
if (x < -icon_size || x > gl->win_width + icon_size || y < -icon_size || y > gl->win_height + icon_size)
return;
GLfloat color[] = {
@ -386,12 +392,12 @@ void lakka_draw_icon(GLuint texture, float x, float y, float alpha, float rotati
1.0f, 1.0f, 1.0f, alpha,
};
glViewport(x, gl->win_height - y, ICON_SIZE, ICON_SIZE);
glViewport(x, gl->win_height - y, icon_size, icon_size);
glEnable(GL_BLEND);
gl->coords.vertex = vtest;
gl->coords.tex_coord = vtest;
gl->coords.vertex = vertex;
gl->coords.tex_coord = tex_coord;
gl->coords.color = color;
glBindTexture(GL_TEXTURE_2D, texture);
@ -439,14 +445,14 @@ static void lakka_draw_subitems(int i, int j)
&& strcmp(g_extern.fullpath, &active_item->rom) == 0)
{
lakka_draw_icon(textures[TEXTURE_RESUME].id,
MARGIN_LEFT + HSPACING*(i+2.25) + all_categories_x - ICON_SIZE/2.0,
MARGIN_TOP + subitem->y + ICON_SIZE/2.0,
margin_left + hspacing*(i+2.25) + all_categories_x - icon_size/2.0,
margin_top + subitem->y + icon_size/2.0,
subitem->alpha,
0,
subitem->zoom);
lakka_draw_text("Resume",
MARGIN_LEFT + HSPACING*(i+2.25) + all_categories_x + LABEL_MARGIN_LEFT,
MARGIN_TOP + subitem->y + LABEL_MARGIN_TOP,
margin_left + hspacing*(i+2.25) + all_categories_x + label_margin_left,
margin_top + subitem->y + label_margin_top,
1,
subitem->alpha);
}
@ -457,14 +463,14 @@ static void lakka_draw_subitems(int i, int j)
strcmp(g_extern.fullpath, &active_item->rom) == 0))
{
lakka_draw_icon(subitem->icon,
MARGIN_LEFT + HSPACING*(i+2.25) + all_categories_x - ICON_SIZE/2.0,
MARGIN_TOP + subitem->y + ICON_SIZE/2.0,
margin_left + hspacing*(i+2.25) + all_categories_x - icon_size/2.0,
margin_top + subitem->y + icon_size/2.0,
subitem->alpha,
0,
subitem->zoom);
lakka_draw_text(subitem->name,
MARGIN_LEFT + HSPACING * (i+2.25) + all_categories_x + LABEL_MARGIN_LEFT,
MARGIN_TOP + subitem->y + LABEL_MARGIN_TOP,
margin_left + hspacing * (i+2.25) + all_categories_x + label_margin_left,
margin_top + subitem->y + label_margin_top,
1,
subitem->alpha);
}
@ -490,16 +496,16 @@ static void lakka_draw_items(int i)
i <= menu_active_category + 1) // performance improvement
{
lakka_draw_icon(category->item_icon,
MARGIN_LEFT + HSPACING*(i+1) + all_categories_x - ICON_SIZE/2.0,
MARGIN_TOP + item->y + ICON_SIZE/2.0,
margin_left + hspacing*(i+1) + all_categories_x - icon_size/2.0,
margin_top + item->y + icon_size/2.0,
item->alpha,
0,
item->zoom);
if (depth == 0)
lakka_draw_text(item->name,
MARGIN_LEFT + HSPACING * (i+1) + all_categories_x + LABEL_MARGIN_LEFT,
MARGIN_TOP + item->y + LABEL_MARGIN_TOP,
margin_left + hspacing * (i+1) + all_categories_x + label_margin_left,
margin_top + item->y + label_margin_top,
1,
item->alpha);
}
@ -525,8 +531,8 @@ static void lakka_draw_categories(void)
// draw category icon
lakka_draw_icon(category->icon,
MARGIN_LEFT + (HSPACING*(i+1)) + all_categories_x - ICON_SIZE/2.0,
MARGIN_TOP + ICON_SIZE/2.0,
margin_left + (hspacing*(i+1)) + all_categories_x - icon_size/2.0,
margin_top + icon_size/2.0,
category->alpha,
0,
category->zoom);
@ -554,170 +560,31 @@ static void lakka_frame(void)
lakka_draw_categories();
if (depth == 0 && active_category)
lakka_draw_text(active_category->name, TITLE_MARGIN_LEFT, TITLE_MARGIN_TOP, 1, 1.0);
lakka_draw_text(active_category->name, title_margin_left, title_margin_top, 1, 1.0);
else if (active_item)
lakka_draw_text(active_item->name, TITLE_MARGIN_LEFT, TITLE_MARGIN_TOP, 1, 1.0);
lakka_draw_text(active_item->name, title_margin_left, title_margin_top, 1, 1.0);
lakka_draw_icon(textures[TEXTURE_ARROW].id,
MARGIN_LEFT + HSPACING*(menu_active_category+1) + all_categories_x + ICON_SIZE/2.0,
MARGIN_TOP + VSPACING*ACTIVE_ITEM_FACTOR + ICON_SIZE/2.0, arrow_alpha, 0, I_ACTIVE_ZOOM);
margin_left + hspacing*(menu_active_category+1) + all_categories_x + icon_size/2.0,
margin_top + vspacing*active_item_factor + icon_size/2.0, arrow_alpha, 0, i_active_zoom);
gl_set_viewport(gl, gl->win_width, gl->win_height, false, false);
}
// thanks to https://github.com/DavidEGrayson/ahrs-visualizer/blob/master/png_texture.cpp
static GLuint png_texture_load(const char * file_name, int * width, int * height)
static GLuint png_texture_load(const char * file_name)
{
png_byte header[8];
struct texture_image ti;
texture_image_load(&ti, file_name);
FILE *fp = fopen(file_name, "rb");
if (fp == 0)
{
perror(file_name);
return 0;
}
// Generate the OpenGL texture object
GLuint texture;
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, ti.width, ti.height, 0, GL_RGBA, GL_UNSIGNED_BYTE, ti.pixels);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
// read the header
fread(header, 1, 8, fp);
if (png_sig_cmp(header, 0, 8))
{
fprintf(stderr, "error: %s is not a PNG.\n", file_name);
fclose(fp);
return 0;
}
png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if (!png_ptr)
{
fprintf(stderr, "error: png_create_read_struct returned 0.\n");
fclose(fp);
return 0;
}
// create png info struct
png_infop info_ptr = png_create_info_struct(png_ptr);
if (!info_ptr)
{
fprintf(stderr, "error: png_create_info_struct returned 0.\n");
png_destroy_read_struct(&png_ptr, (png_infopp)NULL, (png_infopp)NULL);
fclose(fp);
return 0;
}
// create png info struct
png_infop end_info = png_create_info_struct(png_ptr);
if (!end_info)
{
fprintf(stderr, "error: png_create_info_struct returned 0.\n");
png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp) NULL);
fclose(fp);
return 0;
}
// the code in this if statement gets called if libpng encounters an error
if (setjmp(png_jmpbuf(png_ptr))) {
fprintf(stderr, "error from libpng\n");
png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
fclose(fp);
return 0;
}
// init png reading
png_init_io(png_ptr, fp);
// let libpng know you already read the first 8 bytes
png_set_sig_bytes(png_ptr, 8);
// read all the info up to the image data
png_read_info(png_ptr, info_ptr);
// variables to pass to get info
int bit_depth, color_type;
png_uint_32 temp_width, temp_height;
// get info about png
png_get_IHDR(png_ptr, info_ptr, &temp_width, &temp_height, &bit_depth, &color_type,
NULL, NULL, NULL);
if (width){ *width = temp_width; }
if (height){ *height = temp_height; }
//printf("%s: %lux%lu %d\n", file_name, temp_width, temp_height, color_type);
if (bit_depth != 8)
{
fprintf(stderr, "%s: Unsupported bit depth %d. Must be 8.\n", file_name, bit_depth);
return 0;
}
GLint format;
switch(color_type)
{
case PNG_COLOR_TYPE_RGB:
format = GL_RGB;
break;
case PNG_COLOR_TYPE_RGB_ALPHA:
format = GL_RGBA;
break;
default:
fprintf(stderr, "%s: Unknown libpng color type %d.\n", file_name, color_type);
return 0;
}
// Update the png info struct.
png_read_update_info(png_ptr, info_ptr);
// Row size in bytes.
int rowbytes = png_get_rowbytes(png_ptr, info_ptr);
// glTexImage2d requires rows to be 4-byte aligned
rowbytes += 3 - ((rowbytes-1) % 4);
// Allocate the image_data as a big block, to be given to opengl
png_byte * image_data = (png_byte *)malloc(rowbytes * temp_height * sizeof(png_byte)+15);
if (image_data == NULL)
{
fprintf(stderr, "error: could not allocate memory for PNG image data\n");
png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
fclose(fp);
return 0;
}
// row_pointers is for pointing to image_data for reading the png with libpng
png_byte ** row_pointers = (png_byte **)malloc(temp_height * sizeof(png_byte *));
if (row_pointers == NULL)
{
fprintf(stderr, "error: could not allocate memory for PNG row pointers\n");
png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
free(image_data);
fclose(fp);
return 0;
}
// set the individual row_pointers to point at the correct offsets of image_data
for (unsigned int i = 0; i < temp_height; i++)
{
row_pointers[temp_height - 1 - i] = image_data + i * rowbytes;
}
// read the png into image_data through row_pointers
png_read_image(png_ptr, row_pointers);
// Generate the OpenGL texture object
GLuint texture;
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture);
glTexImage2D(GL_TEXTURE_2D, 0, format, temp_width, temp_height, 0, format, GL_UNSIGNED_BYTE, image_data);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
// clean up
png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
free(image_data);
free(row_pointers);
fclose(fp);
return texture;
return texture;
}
static void lakka_context_destroy(void *data)
@ -771,7 +638,7 @@ void lakka_init_settings(void)
strlcpy(category->name, "Settings", sizeof(category->name));
category->alpha = 1.0;
category->zoom = C_ACTIVE_ZOOM;
category->zoom = c_active_zoom;
category->active_item = 0;
category->num_items = 0;
category->items = (menu_item_t*)calloc(category->num_items, sizeof(menu_item_t));
@ -788,8 +655,8 @@ void lakka_init_settings(void)
strlcpy(item0->name, "General Options", sizeof(item0->name));
item0->alpha = j ? 0.5 : 1.0;
item0->zoom = j ? I_PASSIVE_ZOOM : I_ACTIVE_ZOOM;
item0->y = j ? VSPACING*(UNDER_ITEM_OFFSET+j) : VSPACING * ACTIVE_ITEM_FACTOR;
item0->zoom = j ? i_passive_zoom : i_active_zoom;
item0->y = j ? vspacing*(under_item_offset+j) : vspacing * active_item_factor;
item0->active_subitem = 0;
item0->num_subitems = 0;
@ -804,8 +671,8 @@ void lakka_init_settings(void)
strlcpy(subitem0->name, "Libretro Logging Level", sizeof(subitem0->name));
subitem0->alpha = k ? 1.0 : 0.5;
subitem0->zoom = k ? I_ACTIVE_ZOOM : I_PASSIVE_ZOOM;
subitem0->y = k ? VSPACING * (3+k) : VSPACING * ACTIVE_ITEM_FACTOR;
subitem0->zoom = k ? i_active_zoom : i_passive_zoom;
subitem0->y = k ? vspacing * (3+k) : vspacing * active_item_factor;
k = 1;
item0->num_subitems++;
@ -816,8 +683,8 @@ void lakka_init_settings(void)
strlcpy(subitem1->name, "Logging Verbosity", sizeof(subitem1->name));
subitem1->alpha = k ? 1.0 : 0.5;
subitem1->zoom = k ? I_ACTIVE_ZOOM : I_PASSIVE_ZOOM;
subitem1->y = k ? VSPACING * (3+k) : VSPACING * ACTIVE_ITEM_FACTOR;
subitem1->zoom = k ? i_active_zoom : i_passive_zoom;
subitem1->y = k ? vspacing * (3+k) : vspacing * active_item_factor;
k = 2;
item0->num_subitems++;
@ -828,8 +695,8 @@ void lakka_init_settings(void)
strlcpy(subitem2->name, "Configuration Save On Exit", sizeof(subitem2->name));
subitem2->alpha = k ? 1.0 : 0.5;
subitem2->zoom = k ? I_ACTIVE_ZOOM : I_PASSIVE_ZOOM;
subitem2->y = k ? VSPACING * (3+k) : VSPACING * ACTIVE_ITEM_FACTOR;
subitem2->zoom = k ? i_active_zoom : i_passive_zoom;
subitem2->y = k ? vspacing * (3+k) : vspacing * active_item_factor;
// Quit item
@ -841,8 +708,8 @@ void lakka_init_settings(void)
strlcpy(item1->name, "Quit RetroArch", sizeof(item1->name));
item1->alpha = j ? 0.5 : 1.0;
item1->zoom = j ? I_PASSIVE_ZOOM : I_ACTIVE_ZOOM;
item1->y = j ? VSPACING*(UNDER_ITEM_OFFSET+j) : VSPACING * ACTIVE_ITEM_FACTOR;
item1->zoom = j ? i_passive_zoom : i_active_zoom;
item1->y = j ? vspacing*(under_item_offset+j) : vspacing * active_item_factor;
item1->active_subitem = 0;
item1->num_subitems = 0;
}
@ -888,12 +755,12 @@ static void lakka_context_reset(void *data)
fill_pathname_join(mediapath, g_settings.assets_directory, "lakka", sizeof(mediapath));
fill_pathname_join(themepath, mediapath, THEME, sizeof(themepath));
fill_pathname_join(iconpath, themepath, ICON_DIR, sizeof(iconpath));
fill_pathname_join(iconpath, themepath, icon_dir, sizeof(iconpath));
fill_pathname_slash(iconpath, sizeof(iconpath));
fill_pathname_join(font_path, themepath, "font.ttf", sizeof(font_path));
gl_font_init_first(&font_driver, &font, gl, font_path, FONT_SIZE);
gl_font_init_first(&font_driver, &font, gl, font_path, lakka_font_size);
fill_pathname_join(textures[TEXTURE_BG].path, iconpath, "bg.png", sizeof(textures[TEXTURE_BG].path));
fill_pathname_join(textures[TEXTURE_SETTINGS].path, iconpath, "settings.png", sizeof(textures[TEXTURE_SETTINGS].path));
@ -908,7 +775,7 @@ static void lakka_context_reset(void *data)
fill_pathname_join(textures[TEXTURE_RELOAD].path, iconpath, "reload.png", sizeof(textures[TEXTURE_RELOAD].path));
for (k = 0; k < TEXTURE_LAST; k++)
textures[k].id = png_texture_load(textures[k].path, &ICON_SIZE, &ICON_SIZE);
textures[k].id = png_texture_load(textures[k].path);
lakka_settings_context_reset();
for (i = 1; i < num_categories; i++)
@ -921,7 +788,7 @@ static void lakka_context_reset(void *data)
fill_pathname_join(mediapath, g_settings.assets_directory, "lakka", sizeof(mediapath));
fill_pathname_join(themepath, mediapath, THEME, sizeof(themepath));
fill_pathname_join(iconpath, themepath, ICON_DIR, sizeof(iconpath));
fill_pathname_join(iconpath, themepath, icon_dir, sizeof(iconpath));
fill_pathname_slash(iconpath, sizeof(iconpath));
info_list = (core_info_list_t*)menu->core_info;
@ -945,8 +812,8 @@ static void lakka_context_reset(void *data)
strlcat(content_texturepath, core_id, sizeof(content_texturepath));
strlcat(content_texturepath, "-content.png", sizeof(content_texturepath));
category->icon = png_texture_load(texturepath, &ICON_SIZE, &ICON_SIZE);
category->item_icon = png_texture_load(content_texturepath, &ICON_SIZE, &ICON_SIZE);
category->icon = png_texture_load(texturepath);
category->item_icon = png_texture_load(content_texturepath);
for (j = 0; j < category->num_items; j++)
{
@ -1005,8 +872,8 @@ static void lakka_init_items(int i, menu_category_t *category, core_info_t *info
strlcpy(item->name, path_basename(list->elems[j].data), sizeof(item->name));
strlcpy(item->rom, list->elems[j].data, sizeof(item->rom));
item->alpha = i != menu_active_category ? 0 : n ? 0.5 : 1;
item->zoom = n ? I_PASSIVE_ZOOM : I_ACTIVE_ZOOM;
item->y = n ? VSPACING*(UNDER_ITEM_OFFSET+n) : VSPACING*ACTIVE_ITEM_FACTOR;
item->zoom = n ? i_passive_zoom : i_active_zoom;
item->y = n ? vspacing*(under_item_offset+n) : vspacing*active_item_factor;
item->active_subitem = 0;
item->num_subitems = 5;
item->subitems = (menu_subitem_t*)calloc(item->num_subitems, sizeof(menu_subitem_t));
@ -1037,8 +904,8 @@ static void lakka_init_items(int i, menu_category_t *category, core_info_t *info
break;
}
subitem->alpha = 0;
subitem->zoom = k ? I_PASSIVE_ZOOM : I_ACTIVE_ZOOM;
subitem->y = k ? VSPACING * (3+k) : VSPACING * ACTIVE_ITEM_FACTOR;
subitem->zoom = k ? i_passive_zoom : i_active_zoom;
subitem->y = k ? vspacing * (3+k) : vspacing * active_item_factor;
}
}
}
@ -1094,6 +961,8 @@ static void *lakka_init(void)
if (!menu || !gl)
return NULL;
driver.gfx_use_rgba = true;
lakka_responsive();
lakka_init_core_info(menu);
@ -1116,7 +985,7 @@ static void *lakka_init(void)
strlcpy(category->name, info->display_name, sizeof(category->name));
strlcpy(category->libretro, info->path, sizeof(category->libretro));
category->alpha = 0.5;
category->zoom = C_PASSIVE_ZOOM;
category->zoom = c_passive_zoom;
category->active_item = 0;
category->num_items = 0;
category->items = (menu_item_t*)calloc(category->num_items, sizeof(menu_item_t));

View File

@ -30,16 +30,16 @@ extern float all_categories_x;
extern int menu_active_category;
extern float global_alpha;
extern float arrow_alpha;
extern float HSPACING;
extern float VSPACING;
extern float C_ACTIVE_ZOOM;
extern float C_PASSIVE_ZOOM;
extern float I_ACTIVE_ZOOM;
extern float I_PASSIVE_ZOOM;
extern float ABOVE_SUBITEM_OFFSET;
extern float ABOVE_ITEM_OFFSET;
extern float ACTIVE_ITEM_FACTOR;
extern float UNDER_ITEM_OFFSET;
extern float hspacing;
extern float vspacing;
extern float c_active_zoom;
extern float c_passive_zoom;
extern float i_active_zoom;
extern float i_passive_zoom;
extern float above_subitem_offset;
extern float above_item_offset;
extern float active_item_factor;
extern float under_item_offset;
typedef struct
{