Merge branch 'master' of github.com:hrydgard/native

This commit is contained in:
Henrik Rydgard 2012-08-13 20:12:56 +02:00
commit 754dadfd05
7 changed files with 33 additions and 62 deletions

View File

@ -6,7 +6,6 @@ include $(CLEAR_VARS)
LOCAL_MODULE := libnative
LOCAL_SRC_FILES :=\
android/app-android.cpp \
android/native_audio.cpp \
audio/wav_read.cpp \
audio/mixer.cpp.arm \
@ -51,7 +50,7 @@ LOCAL_SRC_FILES :=\
util/random/perlin.cpp
LOCAL_CFLAGS := -O2 -DANDROID_NDK -DUSE_GLES2
LOCAL_CFLAGS := -O2
LOCAL_CPPFLAGS := -fno-exceptions -fno-rtti -std=gnu++0x
LOCAL_LDLIBS := -lz
LOCAL_C_INCLUDES := $(LOCAL_PATH)/ext/libzip

View File

@ -90,8 +90,6 @@ public class NativeActivity extends Activity {
public static String installID;
private EditText editText;
String getApplicationLibraryDir(ApplicationInfo application) {
String libdir = null;
try {

View File

@ -11,31 +11,13 @@
#pragma once
/* For ANSI-challenged compilers, you may want to #define
* NO_MEMBER_TEMPLATES, explicit or mutable */
#define NO_MEMBER_TEMPLATES
template <class X> class linked_ptr
{
public:
explicit linked_ptr(X* p = 0) throw() : itsPtr(p) {itsPrev = itsNext = this;}
~linked_ptr() {release();}
linked_ptr(const linked_ptr& r) throw() {acquire(r);}
#ifndef NO_MEMBER_TEMPLATES
# define TEMPLATE_FUNCTION template <class Y>
TEMPLATE_FUNCTION friend class linked_ptr<Y>;
#else
# define TEMPLATE_FUNCTION
typedef X Y;
#endif
typedef X element_type;
explicit linked_ptr(X* p = 0) throw()
: itsPtr(p) {itsPrev = itsNext = this;}
~linked_ptr()
{release();}
linked_ptr(const linked_ptr& r) throw()
{acquire(r);}
linked_ptr& operator=(const linked_ptr& r)
{
if (this != &r) {
@ -45,24 +27,10 @@ public:
return *this;
}
#ifndef NO_MEMBER_TEMPLATES
template <class Y> friend class linked_ptr<Y>;
template <class Y> linked_ptr(const linked_ptr<Y>& r) throw()
{acquire(r);}
template <class Y> linked_ptr& operator=(const linked_ptr<Y>& r)
{
if (this != &r) {
release();
acquire(r);
}
return *this;
}
#endif // NO_MEMBER_TEMPLATES
X& operator*() const throw() {return *itsPtr;}
X* operator->() const throw() {return itsPtr;}
X* get() const throw() {return itsPtr;}
bool unique() const throw() {return itsPrev ? itsPrev==this : true;}
X& operator*() const throw() {return *itsPtr;}
X* operator->() const throw() {return itsPtr;}
X* get() const throw() {return itsPtr;}
bool unique() const throw() {return itsPrev ? itsPrev==this : true;}
private:
X* itsPtr;
@ -75,28 +43,9 @@ private:
itsNext = r.itsNext;
itsNext->itsPrev = this;
itsPrev = &r;
#ifndef mutable
r.itsNext = this;
#else // for ANSI-challenged compilers
(const_cast<linked_ptr<X>*>(&r))->itsNext = this;
#endif
}
#ifndef NO_MEMBER_TEMPLATES
template <class Y> void acquire(const linked_ptr<Y>& r) throw()
{ // insert this to the list
itsPtr = r.itsPtr;
itsNext = r.itsNext;
itsNext->itsPrev = this;
itsPrev = &r;
#ifndef mutable
r.itsNext = this;
#else // for ANSI-challenged compilers
(const_cast<linked_ptr<X>*>(&r))->itsNext = this;
#endif
}
#endif // NO_MEMBER_TEMPLATES
void release()
{ // erase this from the list, delete if unique
if (unique()) delete itsPtr;

View File

@ -34,3 +34,22 @@ inline void StringToHexString(const std::string &data, std::string *output) {
// highly unsafe and not recommended.
unsigned int parseHex(const char* _szValue);
// Suitable for inserting into maps, unlike char*, and cheaper than std::string.
// Strings must be constant and preferably be stored in the read-only part
// of the binary.
class ConstString {
public:
ConstString(const char *ptr) {
ptr_ = ptr;
}
bool operator <(const ConstString &other) const {
return strcmp(ptr_, other.ptr_) < 0;
}
bool operator ==(const ConstString &other) const {
return ptr_ == other.ptr_ || !strcmp(ptr_, other.ptr_);
}
private:
const char *ptr_;
};

View File

@ -16,6 +16,7 @@
#endif
#endif
#include <map>
#include <time.h>
#include "gfx/gl_lost_manager.h"
@ -54,6 +55,9 @@ struct GLSLProgram : public GfxResourceHolder {
void GLLost();
};
// C API, old skool
GLSLProgram *glsl_create(const char *vshader_file, const char *fshader_file);
void glsl_destroy(GLSLProgram *program);

View File

@ -90,6 +90,7 @@
</Lib>
</ItemDefinitionGroup>
<ItemGroup>
<None Include="Android.mk" />
<None Include="base\CMakeLists.txt" />
<None Include="file\CMakeLists.txt" />
<None Include="README.md" />

View File

@ -8,6 +8,7 @@
<None Include="base\CMakeLists.txt">
<Filter>base</Filter>
</None>
<None Include="Android.mk" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="gfx\gl_debug_log.h">