GithubHelp home page GithubHelp logo

hrydgard / native Goto Github PK

View Code? Open in Web Editor NEW
74.0 18.0 81.0 9.54 MB

NOTE: DEPRECATED! No longer used in PPSSPP! Various C++ utility code: OpenGL ES, JSON, etc, portable to Android.

License: Other

Makefile 0.10% C++ 20.52% C 75.95% Java 1.00% CMake 0.08% Objective-C 0.14% Assembly 0.27% HTML 1.94%

native's Introduction

native

This is my library of stuff that I use when writing C++ programs, mostly for Android but it's all written to enable easy portability between Android, Linux, Windows and MacOSX. The code is part ugly, part inconsistent but quite useful.

Features

  • JSON read/write (two libraries that should be made more similar)
  • basic OpenGL utility code, like compressed texture loading
  • 2D texture atlases and drawing code
  • ETC1 texture save/load support
  • basic logging
  • Really simple audio mixer with OGG sample support
  • RIFF file read/write
  • MIDI Input (only on Windows)

Notes

  • The associated tools to create ZIM texture files and atlases do not yet live here but I might move them here eventually.
  • This library is not really meant to be a public library but I see no reason not to set it free.
  • Note that the included VS project is probably not very useful for you and you're likely better off making your own.
  • Don't complain about inconsistent naming etc - this consists of code that has been cobbled together from a variety of my projects through the years. Fashions come and go.

Licenses

This library, for my convenience, incorporates code from a variety of public domain or similarly-licensed code. This is the list:

  • glew (GL extension wrangler), MIT license. TODO: should just use a submodule.
  • rg_etc1. ZLIB license.
  • sha1, public domain implementation by Dominik Reichl
  • vjson in a heavily modified form, originally by Ivan Vashchaev (TODO: break out into its own repo?)
  • libzip with attribution "Copyright (C) 1999-2007 Dieter Baron and Thomas Klausner"
  • stb_vorbis, public domain by Sean Barrett of RAD Tools

If you're not okay with the licenses above, don't use this code.

I hereby release all code here not under the licenses above under the MIT license.

Contact

If you find this useful for your own projects, drop me a line at [email protected] .

Henrik Rydgård

native's People

Contributors

aapo avatar adrian17 avatar aquanull avatar beaumanvienna avatar bigpet avatar bollu avatar chinhodado avatar daniel-dressler avatar danyalzia avatar fireyfly avatar hrydgard avatar jbeich avatar kingcom avatar libcg avatar lioncash avatar mvdan avatar nachume avatar orphis avatar peterth avatar pggb avatar shenweip avatar sum2012 avatar thedax avatar tpunix avatar unknownbrackets avatar vnctdj avatar wuspring avatar xele02 avatar xsacha avatar zhykzhykzhyk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

native's Issues

Undefined references in zimtool build

Trying to build zimtool.

libimage.a has some undefined references (missing linking to libpng17 ?)

[ 76%] Building CXX object CMakeFiles/zimtool.dir/zimtool.cpp.o
/usr/bin/c++   -DSDL -std=c++11 -I/home/sergio/Projetos/ppsspp/ppsspp-git/native/tools/.. -I/home/sergio/Projetos/ppsspp/ppsspp-git/native/tools/../ext -I/home/sergio/Projetos/ppsspp/ppsspp-git/native/tools/../math/lin -I/home/sergio/Projetos/ppsspp/ppsspp-git/native/tools/../image -I/home/sergio/Projetos/ppsspp/ppsspp-git/native/tools/../ext/rg_etc1 -I/usr/include/GL -I/usr/local/include -I/usr/include/freetype2 -I/usr/local/include/freetype2 -I/opt/local/include/freetype2 -I/opt/local/include    -O2 -Wall -Wno-multichar -fno-strict-aliasing -o CMakeFiles/zimtool.dir/zimtool.cpp.o -c /home/sergio/Projetos/ppsspp/ppsspp-git/native/tools/zimtool.cpp
Linking CXX executable zimtool
/usr/bin/cmake -E cmake_link_script CMakeFiles/zimtool.dir/link.txt --verbose=1
/usr/bin/c++    -std=c++11    CMakeFiles/zimtool.dir/zimtool.cpp.o  -o zimtool  -L/usr/X11R6/lib  -L/opt/local/lib -rdynamic png17/libpng17.a -lfreetype image/libimage.a -lGLEW -lzip -lz stb_image/libstb_image.a rg_etc1/librg_etc1.a file/libfile.a -lzip base/libbase.a -Wl,-rpath,/usr/X11R6/lib:/opt/local/lib 
image/libimage.a(png_load.cpp.o): in function `pngLoad(char const*, int*, int*, unsigned char**, bool)':
png_load.cpp:(.text+0x4d): undefined reference to `png_image_begin_read_from_file'
png_load.cpp:(.text+0x10c): undefined reference to `png_image_finish_read'
image/libimage.a(png_load.cpp.o): in function `pngLoadPtr(unsigned char const*, unsigned long, int*, int*, unsigned char**, bool)':
png_load.cpp:(.text+0x1c5): undefined reference to `png_image_begin_read_from_memory'
png_load.cpp:(.text+0x284): undefined reference to `png_image_finish_read'
collect2: error: ld returned 1 exit status
make[2]: ** [zimtool] Erro 1

Some changes in the CMakeLists.txt:

Index: ppsspp-git/native/tools/atlastool.cpp
===================================================================
--- ppsspp-git.orig/native/tools/atlastool.cpp  2015-06-22 03:21:57.574484974 -0300
+++ ppsspp-git/native/tools/atlastool.cpp   2015-06-22 03:21:57.566484934 -0300
@@ -18,7 +18,7 @@
 // Hackery for our broken path structure
 #include <ftbitmap.h>
 #else
-#include <freetype/ftbitmap.h>
+#include <freetype2/ftbitmap.h>
 #endif
 #include <set>
 #include <map>
Index: ppsspp-git/native/tools/CMakeLists.txt
===================================================================
--- ppsspp-git.orig/native/tools/CMakeLists.txt 2015-06-22 03:21:43.118413290 -0300
+++ ppsspp-git/native/tools/CMakeLists.txt  2015-06-22 03:35:53.270628967 -0300
@@ -27,19 +27,13 @@
 include_directories(../ext)
 include_directories(../math/lin)
 include_directories(../image)
-include_directories(../ext/libzip)
 include_directories(../ext/rg_etc1)
-include_directories(../ext/glew)
-include_directories(/usr/local/include)
+include_directories(/usr/include/GL)

 link_directories(/usr/X11R6/lib)
-link_directories(/opt/local/lib)

 # Horrible horrible hack
 include_directories(/usr/include/freetype2)
-include_directories(/usr/local/include/freetype2)
-include_directories(/opt/local/include/freetype2)
-include_directories(/opt/local/include)

 add_subdirectory(../base base)
 add_subdirectory(../gfx gfx)
@@ -47,14 +41,13 @@
 add_subdirectory(../image image)
 add_subdirectory(../math math)
 add_subdirectory(../util util)
-add_subdirectory(../ext/libzip libzip)
 add_subdirectory(../ext/rg_etc1 rg_etc1)
 add_subdirectory(../ext/stb_image stb_image)
 add_subdirectory(../ext/libpng17 png17)


 add_executable(atlastool atlastool.cpp)
-target_link_libraries(atlastool png17 freetype util image z stb_image rg_etc1 file zip base)
+target_link_libraries(atlastool png17 freetype util image GLEW zip z stb_image rg_etc1 file base)

 add_executable(zimtool zimtool.cpp)
-target_link_libraries(zimtool png17 freetype image z stb_image rg_etc1 file zip base)
+target_link_libraries(zimtool png17 freetype image GLEW zip z stb_image rg_etc1 file base)

Maemo: Name 'Screen' on ui/screen.h:35 collapses with /usr/include/X11/Xlib.h:307

81da5fa

Happens on Maemo (gcc-4.7), doesn't happen on Ubuntu (gcc-4.6).

/home/rantalai/ppsspp/0.9/ppsspp/native/ui/screen.h:35:7: error: using typedef-name 'Screen' after 'class'
In file included from /usr/include/EGL/eglplatform.h:82:0,
             from /usr/include/EGL/egl.h:36,
             from /home/rantalai/ppsspp/0.9/ppsspp/native/gfx/gl_common.h:11,
             from /home/rantalai/ppsspp/0.9/ppsspp/native/gfx_es2/gl_state.h:6,
             from /home/rantalai/ppsspp/0.9/ppsspp/UI/NativeApp.cpp:39:
/usr/include/X11/Xlib.h:307:3: note: 'Screen' has a previous declaration here

malloc and free undefined on OS X

Discovered a missing include in ext/vjson/block_allocator.cpp (free and malloc were not found). I don't see any changes since june 6th to that file and it was working that time...
I simply added these, but the problem looks deeper. May break some other systems.

#ifdef __APPLE__
#include <stdlib.h>
#endif

I also wonder if anybody has the same problem.

stb_image fails to decode interlaced PNG images

Game icon used by Aero Racer:
http://forums.ppsspp.org/showthread.php?tid=3693

Fails at:

if (filter > 4) return e("invalid filter","Corrupt PNG");

But a couple PNG validators claim it's fine. As far as I can tell, if I resave it as an interlaced PNG, it fails, if I resave it as a non-interlaced PNG, it works.

Of course, this image is not properly optimized and even has an embedded ICC profile, alas...

(I know stb_image is some public domain thing, I can move this to ppsspp instead if it's more correct too...)

-[Unknown]

atlastool does not need Glew

Trying to compile atlastool on ARM, and it fails because native/base/timeutil.cpp includes glew header (by gl_state.h --> gfx/gl_common.h)

[  3%] Building CXX object base/CMakeFiles/base.dir/timeutil.cpp.o
In file included from /«BUILDDIR»/ppsspp-qt-1.0.1+r63.f46.n1198.l1596.a159.t83~21~ubuntu14.04.1/native/tools/../gfx_es2/gl_state.h:6:0,
                 from /«BUILDDIR»/ppsspp-qt-1.0.1+r63.f46.n1198.l1596.a159.t83~21~ubuntu14.04.1/native/base/timeutil.cpp:6:
/«BUILDDIR»/ppsspp-qt-1.0.1+r63.f46.n1198.l1596.a159.t83~21~ubuntu14.04.1/native/tools/../gfx/gl_common.h:14:21: fatal error: GL/glew.h: No such file or directory
 #include <GL/glew.h>
                     ^
compilation terminated.

https://launchpadlibrarian.net/209838887/buildlog_ubuntu-trusty-armhf.ppsspp-qt_1.0.1%2Br63.f46.n1198.l1596.a159.t83~21~ubuntu14.04.1_BUILDING.txt.gz

native/base/timeutil.cpp:

// For NV time functions. Ugly!
#include "gfx_es2/gl_state.h"

atlastool is not even linked to Glew.

Possible array overruns in zip_read?

At lines 166, 185 and 210, I think there's a potential for the array new_path to be overrun:

https://github.com/hrydgard/native/blob/master/file/zip_read.cpp#L166
https://github.com/hrydgard/native/blob/master/file/zip_read.cpp#L185
https://github.com/hrydgard/native/blob/master/file/zip_read.cpp#L210

While new_path has a length of 256, path has a length of 512.

Since new_path is the destination in those strcpy calls, I'm pretty sure it's a bug. (unless I missed something in the code).

build failure on archLinux 64 bit

I've been trying to build ppsspp for a solid week now, and I've run into tons of problems (mostly with poor 64 bit support and problems with Kepler and the android plugins).

However, now I've run into a brick wall for the past 3 days. I'm not able to compile ppsspp. I tried everything I could think of.

So, I ran ndk_build with the -k option (continue on errors) to see what would happen.

Here is a list of all the errors:

Most of them stem from the lack of an EGL folder (I don't know where the folder is supposed to be)

Some others are perplexing (the very first error for example. I don't know how to prevent it),

Here's a dump

set_xres and set_yres defined !USING_GLES2, but used unconditionally

Variables set_xres and set_yres are defined only if not USING_GLES2.

base/PCMain.cpp
369:

#ifdef USING_GLES2
    mode = SDL_SWSURFACE | SDL_FULLSCREEN;
#else
    mode = SDL_OPENGL;
    int set_xres = -1;
    int set_yres = -1;

But later they are used unconditionally, on 408:

    if (set_xres > 0) {
        pixel_xres = set_xres;
    }
    if (set_yres > 0) {
        pixel_yres = set_yres;
    }

Thin3D Clear() uses inconsistent color component order

OpenGL:
Uint32ToFloat4(colorval, col);
glClearColor(col[0], col[1], col[2], col[3]);

Direct3D 9:
(D3DCOLOR)colorval

As such, OpenGL uses 0xAABBGGRR and Direct3D 9 uses 0xAARRGGBB.

Incidentally, PPSSPP seems to assume 0xAARRGGBB (which is probably the clearer one to type.) This means that in OpenGL, if you do things like mashing F11 or etc., you'll see a brown background color.

dc.GetThin3DContext()->Clear(T3DClear::COLOR | T3DClear::DEPTH | T3DClear::STENCIL, 0xff224477, 0.0, 0);

It's clearly meant to be a bluish color, rather than a redish one, which implies that OpenGL should be color swapped. But, I'm not sure which color order is best.

-[Unknown]

base/PCmain.cpp: invalid conversion from 'EGLConfig {aka void*}' to 'void**

On base/PCmain.cpp
This

EGLConfig g_eglConfig[1] = {NULL};
EGLBoolean result = eglChooseConfig(g_eglDisplay, attrib_list, g_eglConfig[0], 1, &g_numConfigs);

gives compile time warning to me

warning: invalid conversion from 'EGLConfig {aka void*}' to 'void**' [-fpermissive]

And on Maemo/N900 it causes runtime error:

Unable to create EGL surface (eglError: 12293)

My pull request fixes this also.
#55

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.