dmuratshin 9 years ago
parent
commit
a576ebc838

+ 1 - 0
oxygine/src/STDRenderer.h

@@ -40,6 +40,7 @@ namespace oxygine
 
 
         const Matrix&   getViewProjection() const { return _vp; }
         const Matrix&   getViewProjection() const { return _vp; }
         IVideoDriver*   getDriver();
         IVideoDriver*   getDriver();
+        unsigned int    getShaderFlags() const { return _shaderFlags; }
 
 
 
 
         void setDriver(IVideoDriver*);
         void setDriver(IVideoDriver*);

+ 2 - 0
oxygine/src/core/VideoDriver.h

@@ -75,6 +75,7 @@ namespace oxygine
         virtual void            getViewport(Rect& r) const = 0;
         virtual void            getViewport(Rect& r) const = 0;
         virtual bool            getScissorRect(Rect&) const = 0;
         virtual bool            getScissorRect(Rect&) const = 0;
         virtual spNativeTexture getRenderTarget() const = 0;
         virtual spNativeTexture getRenderTarget() const = 0;
+        virtual ShaderProgram*  getShaderProgram() const = 0;
         virtual const VertexDeclaration* getVertexDeclaration(bvertex_format) const = 0;
         virtual const VertexDeclaration* getVertexDeclaration(bvertex_format) const = 0;
 
 
         virtual void setScissorRect(const Rect*) = 0;
         virtual void setScissorRect(const Rect*) = 0;
@@ -110,6 +111,7 @@ namespace oxygine
         void getStats(Stats& s) const;
         void getStats(Stats& s) const;
         void getViewport(Rect& r) const;
         void getViewport(Rect& r) const;
         bool getScissorRect(Rect&) const;
         bool getScissorRect(Rect&) const;
+        ShaderProgram*  getShaderProgram() const { return 0; }
         spNativeTexture getRenderTarget() const;
         spNativeTexture getRenderTarget() const;
 
 
         const VertexDeclaration*    getVertexDeclaration(bvertex_format) const;
         const VertexDeclaration*    getVertexDeclaration(bvertex_format) const;

+ 9 - 8
oxygine/src/core/gl/VideoDriverGLES20.cpp

@@ -21,7 +21,7 @@
 
 
 namespace oxygine
 namespace oxygine
 {
 {
-    VideoDriverGLES20::VideoDriverGLES20(): _program(0)
+    VideoDriverGLES20::VideoDriverGLES20(): _programID(0), _p(0)
     {
     {
     }
     }
 
 
@@ -84,7 +84,8 @@ namespace oxygine
         ShaderProgramGL* prog = safeCast<ShaderProgramGL*>(prog_);
         ShaderProgramGL* prog = safeCast<ShaderProgramGL*>(prog_);
         unsigned int id = prog->getID();
         unsigned int id = prog->getID();
         oxglUseProgram(id);
         oxglUseProgram(id);
-        _program = id;
+        _programID = id;
+        _p = prog_;
         CHECKGL();
         CHECKGL();
     }
     }
 
 
@@ -178,7 +179,7 @@ namespace oxygine
 
 
     void VideoDriverGLES20::setUniformInt(const char* id, int v)
     void VideoDriverGLES20::setUniformInt(const char* id, int v)
     {
     {
-        int location = oxglGetUniformLocation(_program, id);
+        int location = oxglGetUniformLocation(_programID, id);
         if (location == -1)
         if (location == -1)
             return;
             return;
         oxglUniform1i(location, v);
         oxglUniform1i(location, v);
@@ -187,7 +188,7 @@ namespace oxygine
 
 
     void VideoDriverGLES20::setUniform(const char* id, const Vector4* v, int num)
     void VideoDriverGLES20::setUniform(const char* id, const Vector4* v, int num)
     {
     {
-        int p = oxglGetUniformLocation(_program, id);
+        int p = oxglGetUniformLocation(_programID, id);
         if (p == -1)
         if (p == -1)
             return;
             return;
         oxglUniform4fv(p, num, v->m);
         oxglUniform4fv(p, num, v->m);
@@ -196,7 +197,7 @@ namespace oxygine
 
 
     void VideoDriverGLES20::setUniform(const char* id, const Vector2* v, int num)
     void VideoDriverGLES20::setUniform(const char* id, const Vector2* v, int num)
     {
     {
-        int p = oxglGetUniformLocation(_program, id);
+        int p = oxglGetUniformLocation(_programID, id);
         if (p == -1)
         if (p == -1)
             return;
             return;
         oxglUniform2fv(p, num, &v->x);
         oxglUniform2fv(p, num, &v->x);
@@ -205,7 +206,7 @@ namespace oxygine
 
 
     void VideoDriverGLES20::setUniform(const char* id, const Vector3* v, int num)
     void VideoDriverGLES20::setUniform(const char* id, const Vector3* v, int num)
     {
     {
-        int p = oxglGetUniformLocation(_program, id);
+        int p = oxglGetUniformLocation(_programID, id);
         if (p == -1)
         if (p == -1)
             return;
             return;
         oxglUniform3fv(p, num, &v->x);
         oxglUniform3fv(p, num, &v->x);
@@ -214,7 +215,7 @@ namespace oxygine
 
 
     void VideoDriverGLES20::setUniform(const char* id, const Matrix* mat)
     void VideoDriverGLES20::setUniform(const char* id, const Matrix* mat)
     {
     {
-        int p = oxglGetUniformLocation(_program, id);
+        int p = oxglGetUniformLocation(_programID, id);
         if (p == -1)
         if (p == -1)
             return;
             return;
         oxglUniformMatrix4fv(p, 1, GL_FALSE, mat->ml);
         oxglUniformMatrix4fv(p, 1, GL_FALSE, mat->ml);
@@ -223,7 +224,7 @@ namespace oxygine
 
 
     void VideoDriverGLES20::setUniform(const char* id, float val)
     void VideoDriverGLES20::setUniform(const char* id, float val)
     {
     {
-        int p = oxglGetUniformLocation(_program, id);
+        int p = oxglGetUniformLocation(_programID, id);
         if (p == -1)
         if (p == -1)
             return;
             return;
         oxglUniform1f(p, val);
         oxglUniform1f(p, val);

+ 4 - 1
oxygine/src/core/gl/VideoDriverGLES20.h

@@ -23,6 +23,8 @@ namespace oxygine
         void begin(const Rect& viewport, const Color* clearColor);
         void begin(const Rect& viewport, const Color* clearColor);
         void clear(const Color& color);
         void clear(const Color& color);
 
 
+        ShaderProgram*  getShaderProgram() const OVERRIDE { return _p; }
+
         void draw(PRIMITIVE_TYPE pt, const VertexDeclaration* decl, const void* verticesData, unsigned int verticesDataSize);
         void draw(PRIMITIVE_TYPE pt, const VertexDeclaration* decl, const void* verticesData, unsigned int verticesDataSize);
         void draw(PRIMITIVE_TYPE pt, const VertexDeclaration* decl, const void* verticesData, unsigned int verticesDataSize, const void* indicesData, unsigned int indicesDataSize, bool indicesShortType);
         void draw(PRIMITIVE_TYPE pt, const VertexDeclaration* decl, const void* verticesData, unsigned int verticesDataSize, const void* indicesData, unsigned int indicesDataSize, bool indicesShortType);
         void setDefaultSettings();
         void setDefaultSettings();
@@ -41,7 +43,8 @@ namespace oxygine
         GLuint _vbo;
         GLuint _vbo;
         GLuint _ibo;
         GLuint _ibo;
 
 
-        int _program;
+        int _programID;
+        ShaderProgram* _p;
         void updateConstants();
         void updateConstants();
     };
     };
 }
 }

+ 8 - 0
oxygine/src/utils/stringUtils.cpp

@@ -222,8 +222,16 @@ namespace oxygine
             std::string name = filename.substr(pos, filename.size() - pos);
             std::string name = filename.substr(pos, filename.size() - pos);
             return name;
             return name;
         }
         }
+
+        std::string extractFolder(const std::string& path)
+        {
+            size_t pos = path.find_last_of("\\/") + 1;
+            std::string name = path.substr(0, pos);
+            return name;
+        }
     }
     }
 
 
+
     const char* getNextCode(int& code, const char* utf8str)
     const char* getNextCode(int& code, const char* utf8str)
     {
     {
         const char* utfstr = utf8str;
         const char* utfstr = utf8str;

+ 3 - 0
oxygine/src/utils/stringUtils.h

@@ -32,6 +32,9 @@ namespace oxygine
 
 
         /**some/file/path.png   ->  png*/
         /**some/file/path.png   ->  png*/
         std::string extractFileExt(const std::string& filename);
         std::string extractFileExt(const std::string& filename);
+
+        /**some/file/path.png   ->  some/file/*/
+        std::string extractFolder(const std::string& filename);
     }
     }
 
 
     std::string lower(const std::string& str);
     std::string lower(const std::string& str);

+ 3 - 2
tools/others/build_oxygine_with_sdl.py

@@ -72,8 +72,9 @@ export("oxygine-framework", "oxygine-framework")
 buildzip("oxygine-framework.zip")
 buildzip("oxygine-framework.zip")
 
 
 # ALL IN ONE
 # ALL IN ONE
-cmd = "hg archive -R ../../../SDL %s" % (SDL_dest, )
-os.system(cmd)
+#cmd = "hg archive -R ../../../SDL %s" % (SDL_dest, )
+#os.system(cmd)
+export("SDL", "SDL")
 export("oxygine-sound", "oxygine-sound")
 export("oxygine-sound", "oxygine-sound")
 export("oxygine-flow", "oxygine-flow")
 export("oxygine-flow", "oxygine-flow")
 
 

+ 6 - 2
tools/others/gen_xml_resources.py

@@ -26,6 +26,10 @@ def gen_xml(args):
     wildcard = "*.*"
     wildcard = "*.*"
     path = args.data + "/" + args.images
     path = args.data + "/" + args.images
     filelist = glob.glob(path + "/" + args.wildcard)
     filelist = glob.glob(path + "/" + args.wildcard)
+    filelist = glob.glob(path + "/*.jpeg")
+    filelist.extend(glob.glob(path + "/*.jpg"))
+    filelist.extend(glob.glob(path + "/*.tga"))
+    filelist.extend(glob.glob(path + "/*.png"))
     print(filelist)
     print(filelist)
     print(path)
     print(path)
 
 
@@ -64,14 +68,14 @@ if __name__ == "__main__":
     parser = argparse.ArgumentParser(
     parser = argparse.ArgumentParser(
         description="generates xml file with image resources")
         description="generates xml file with image resources")
     parser.add_argument(
     parser.add_argument(
-        "-d", "--data", help="root data folder", default=".", required=True)
+        "-d", "--data", help="root data folder", default=".")
     parser.add_argument("-s", "--sfactor", help="scale factor", default=1)
     parser.add_argument("-s", "--sfactor", help="scale factor", default=1)
     parser.add_argument(
     parser.add_argument(
         "-i", "--images", help="folder with images. path relative to --data", default=".")
         "-i", "--images", help="folder with images. path relative to --data", default=".")
     parser.add_argument(
     parser.add_argument(
         "-o", "--out", help="output xml file name", default="out.xml")
         "-o", "--out", help="output xml file name", default="out.xml")
     parser.add_argument("-w", "--wildcard",
     parser.add_argument("-w", "--wildcard",
-                        help="default is '*.png'", default="*.png")
+                        help="default is '*.png'", default="(*.png,*.jpg)")
     parser.add_argument("-l", "--load", help="preload files?",
     parser.add_argument("-l", "--load", help="preload files?",
                         action="store_true", default=True)
                         action="store_true", default=True)
     parser.add_argument("-a", "--atlasses", help="separate atlasses for each file?",
     parser.add_argument("-a", "--atlasses", help="separate atlasses for each file?",