GLuint CreateSimpleTexture2D( )
{
   // Texture object handle
   GLuint textureId;
   
   // 2x2 Image, 3 bytes per pixel (R, G, B)
   int width, height;
   TextureReturn thing = png_texture_load("Kakka_Carrot_Veggie.png", &width, &height);//esLoadTGA("flag_b24.tga", &width, &height);
   /*{  
      255,   0,   0, // Red
        0, 255,   0, // Green
        0,   0, 255, // Blue
      255, 255,   0  // Yellow
   };*/

   // Generate a texture object
   glGenTextures ( 1, &textureId );

   // Bind the texture object
   glBindTexture ( GL_TEXTURE_2D, textureId );

   // Load the texture
   glTexImage2D(GL_TEXTURE_2D, 0, thing.format, width, height, 0, thing.format, GL_UNSIGNED_BYTE, thing.pixels);

   // Set the filtering mode
   glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
   glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );

   return textureId;

}
Beispiel #2
0
void initGL(Mesh* m)
{
    vertexVBOID = 0;
    if(m != NULL)
    {
        m->getVertices(vertices, v_size);
        m->getIndexes(indexes, i_size);
    }
    else
        std::cout << "Mesh is null and shoucldn't" << std::endl;

    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
   // glEnable(GL_TEXTURE_2D);

    // Decommenter ces deux lignes pour activer les textures.
    windows1 = png_texture_load("atlas.png", NULL, NULL);
    glBindTexture(GL_TEXTURE_2D, windows1);

    //Bind and fill the buffer with the content of our mesh.
    //GL_STATIC_DRAW is here because we don't modify our model
    glGenBuffers(1, &vertexVBOID);
    glBindBuffer(GL_ARRAY_BUFFER, vertexVBOID);
    glBufferData(GL_ARRAY_BUFFER, v_size * sizeof(Vert), NULL, GL_STATIC_DRAW);
    glBufferSubData(GL_ARRAY_BUFFER, 0, v_size * sizeof(Vert), vertices);

    //Bind and fill the index array
    glGenBuffers(1, &indexVBOID);
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexVBOID);
    glBufferData(GL_ELEMENT_ARRAY_BUFFER, i_size * sizeof(int), indexes, GL_STATIC_DRAW);

    glClearColor (0.0, 0.0, 0.0, 0.0);
    glShadeModel (GL_SMOOTH);
    glEnable(GL_COLOR_MATERIAL);
    glEnable(GL_LIGHTING);
    glEnable(GL_LIGHT0);
    glEnable(GL_DEPTH_TEST);
	glDepthMask(GL_TRUE);
	glEnable(GL_CULL_FACE);
}
Beispiel #3
0
static void lakka_context_reset(void *data)
{
   int i, j, k;
   char path[256], dirpath[256];;
   rgui_handle_t *rgui = (rgui_handle_t*)data;
   gl_t *gl = (gl_t*)driver.video_data;

   if (!rgui)
      return;

   fill_pathname_join(dirpath, g_settings.assets_directory, "lakka", sizeof(dirpath));
   fill_pathname_slash(dirpath, sizeof(dirpath));

   fill_pathname_join(textures[TEXTURE_SETTINGS].path, dirpath, "settings.png", sizeof(textures[TEXTURE_SETTINGS].path));
   fill_pathname_join(textures[TEXTURE_SETTING].path, dirpath, "setting.png", sizeof(textures[TEXTURE_SETTING].path));
   fill_pathname_join(textures[TEXTURE_SUBSETTING].path, dirpath, "subsetting.png", sizeof(textures[TEXTURE_SUBSETTING].path));
   fill_pathname_join(textures[TEXTURE_ARROW].path, dirpath, "arrow.png", sizeof(textures[TEXTURE_ARROW].path));
   fill_pathname_join(textures[TEXTURE_RUN].path, dirpath, "run.png", sizeof(textures[TEXTURE_RUN].path));
   fill_pathname_join(textures[TEXTURE_RESUME].path, dirpath, "resume.png", sizeof(textures[TEXTURE_RESUME].path));
   fill_pathname_join(textures[TEXTURE_SAVESTATE].path, dirpath, "savestate.png", sizeof(textures[TEXTURE_SAVESTATE].path));
   fill_pathname_join(textures[TEXTURE_LOADSTATE].path, dirpath, "loadstate.png", sizeof(textures[TEXTURE_LOADSTATE].path));
   fill_pathname_join(textures[TEXTURE_SCREENSHOT].path, dirpath, "screenshot.png", sizeof(textures[TEXTURE_SCREENSHOT].path));
   fill_pathname_join(textures[TEXTURE_RELOAD].path, dirpath, "reload.png", sizeof(textures[TEXTURE_RELOAD].path));

   for (k = 0; k < TEXTURE_LAST; k++)
      textures[k].id = png_texture_load(textures[k].path, &dim, &dim);

   if (font_driver)
   {
      font_driver->render_msg(font, "Run", &run_label);
      font_driver->render_msg(font, "Resume", &resume_label);
   }

   lakka_settings_context_reset();
   for (i = 1; i < num_categories; i++)
   {
      menu_category_t *category = (menu_category_t*)&categories[i];

      char core_id[256], texturepath[256], content_texturepath[256], dirpath[256];
      core_info_t *info;
      core_info_list_t *info_list;

      fill_pathname_join(dirpath, g_settings.assets_directory, "lakka", sizeof(dirpath));
      fill_pathname_slash(dirpath, sizeof(dirpath));

      info_list = (core_info_list_t*)rgui->core_info;
      info = NULL;

      if (info_list)
         info = (core_info_t*)&info_list->list[i-1];

      strlcpy(core_id, basename(info->path), sizeof(core_id));
      strlcpy(core_id, str_replace(core_id, ".so", ""), sizeof(core_id));
      strlcpy(core_id, str_replace(core_id, ".dll", ""), sizeof(core_id));
      strlcpy(core_id, str_replace(core_id, ".dylib", ""), sizeof(core_id));
      strlcpy(core_id, str_replace(core_id, "-libretro", ""), sizeof(core_id));
      strlcpy(core_id, str_replace(core_id, "_libretro", ""), sizeof(core_id));
      strlcpy(core_id, str_replace(core_id, "libretro-", ""), sizeof(core_id));
      strlcpy(core_id, str_replace(core_id, "libretro_", ""), sizeof(core_id));

      strlcpy(texturepath, dirpath, sizeof(texturepath));
      strlcat(texturepath, core_id, sizeof(texturepath));
      strlcat(texturepath, ".png", sizeof(texturepath));

      strlcpy(content_texturepath, dirpath, sizeof(content_texturepath));
      strlcat(content_texturepath, core_id, sizeof(content_texturepath));
      strlcat(content_texturepath, "-content.png", sizeof(content_texturepath));

      category->icon = png_texture_load(texturepath, &dim, &dim);
      category->item_icon = png_texture_load(content_texturepath, &dim, &dim);
      
      if (font_driver)
         font_driver->render_msg(font, category->name, &category->out);

      for (j = 0; j < category->num_items; j++)
      {
         menu_item_t *item = (menu_item_t*)&category->items[j];

         if (font_driver)
            font_driver->render_msg(font, item->name, &item->out);

         for (k = 0; k < item->num_subitems; k++)
         {
            menu_subitem_t *subitem = (menu_subitem_t*)&item->subitems[k];

            switch (k)
            {
               case 0:
                  subitem->icon = textures[TEXTURE_RUN].id;
                  break;
               case 1:
                  subitem->icon = textures[TEXTURE_SAVESTATE].id;
                  break;
               case 2:
                  subitem->icon = textures[TEXTURE_LOADSTATE].id;
                  break;
               case 3:
                  subitem->icon = textures[TEXTURE_SCREENSHOT].id;
                  break;
               case 4:
                  subitem->icon = textures[TEXTURE_RELOAD].id;
                  break;
            }

            if (font_driver)
               font_driver->render_msg(font, subitem->name, &subitem->out);
         }
      }
   }
}
void carregar_texturas(void){
	textura_plano = png_texture_load(TEXTURA_DO_PLANO, NULL, NULL);
	textura_aviao = png_texture_load(TEXTURA_DO_AVIAO, NULL, NULL);
	textura_logo = png_texture_load(TEXTURA_DO_LOGO, NULL, NULL);
}
Beispiel #5
0
static void lakka_context_reset(void *data)
{
   int i, j, k;
   char path[256], mediapath[256], themepath[256], iconpath[256];
   menu_handle_t *menu = (menu_handle_t*)data;
   gl_t *gl = (gl_t*)driver.video_data;

   driver.gfx_use_rgba = true;

   if (!menu)
      return;

   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_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, 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));
   fill_pathname_join(textures[TEXTURE_SETTING].path, iconpath, "setting.png", sizeof(textures[TEXTURE_SETTING].path));
   fill_pathname_join(textures[TEXTURE_SUBSETTING].path, iconpath, "subsetting.png", sizeof(textures[TEXTURE_SUBSETTING].path));
   fill_pathname_join(textures[TEXTURE_ARROW].path, iconpath, "arrow.png", sizeof(textures[TEXTURE_ARROW].path));
   fill_pathname_join(textures[TEXTURE_RUN].path, iconpath, "run.png", sizeof(textures[TEXTURE_RUN].path));
   fill_pathname_join(textures[TEXTURE_RESUME].path, iconpath, "resume.png", sizeof(textures[TEXTURE_RESUME].path));
   fill_pathname_join(textures[TEXTURE_SAVESTATE].path, iconpath, "savestate.png", sizeof(textures[TEXTURE_SAVESTATE].path));
   fill_pathname_join(textures[TEXTURE_LOADSTATE].path, iconpath, "loadstate.png", sizeof(textures[TEXTURE_LOADSTATE].path));
   fill_pathname_join(textures[TEXTURE_SCREENSHOT].path, iconpath, "screenshot.png", sizeof(textures[TEXTURE_SCREENSHOT].path));
   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);

   lakka_settings_context_reset();
   for (i = 1; i < num_categories; i++)
   {
      menu_category_t *category = (menu_category_t*)&categories[i];

      char core_id[256], texturepath[256], content_texturepath[256], mediapath[256], themepath[256];
      core_info_t *info;
      core_info_list_t *info_list;

      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_slash(iconpath, sizeof(iconpath));

      info_list = (core_info_list_t*)menu->core_info;
      info = NULL;

      if (info_list)
         info = (core_info_t*)&info_list->list[i-1];

      if (info->systemname) {
         strlcpy(core_id, info->systemname, sizeof(core_id));
         strlcpy(core_id, str_replace(core_id, "/", " "), sizeof(core_id));
      } else {
         strlcpy(core_id, "default", sizeof(core_id));
      }

      strlcpy(texturepath, iconpath, sizeof(texturepath));
      strlcat(texturepath, core_id, sizeof(texturepath));
      strlcat(texturepath, ".png", sizeof(texturepath));

      strlcpy(content_texturepath, iconpath, sizeof(content_texturepath));
      strlcat(content_texturepath, core_id, sizeof(content_texturepath));
      strlcat(content_texturepath, "-content.png", sizeof(content_texturepath));

      category->icon = png_texture_load(texturepath);
      category->item_icon = png_texture_load(content_texturepath);
      
      for (j = 0; j < category->num_items; j++)
      {
         menu_item_t *item = (menu_item_t*)&category->items[j];

         for (k = 0; k < item->num_subitems; k++)
         {
            menu_subitem_t *subitem = (menu_subitem_t*)&item->subitems[k];

            switch (k)
            {
               case 0:
                  subitem->icon = textures[TEXTURE_RUN].id;
                  break;
               case 1:
                  subitem->icon = textures[TEXTURE_SAVESTATE].id;
                  break;
               case 2:
                  subitem->icon = textures[TEXTURE_LOADSTATE].id;
                  break;
               case 3:
                  subitem->icon = textures[TEXTURE_SCREENSHOT].id;
                  break;
               case 4:
                  subitem->icon = textures[TEXTURE_RELOAD].id;
                  break;
            }
         }
      }
   }
}