merge webgl
authorunc0rr
Wed, 19 Jun 2013 00:52:39 +0400
branchwebgl
changeset 9267 dbd18257be8f
parent 9264 21df1a0ec9ed (diff)
parent 9259 872dd30deb7b (current diff)
child 9270 a9b9ebd3d3be
merge
project_files/hwc/CMakeLists.txt
--- a/hedgewars/pas2cSystem.pas	Tue Jun 18 22:39:57 2013 +0200
+++ b/hedgewars/pas2cSystem.pas	Wed Jun 19 00:52:39 2013 +0400
@@ -126,4 +126,9 @@
     clear_filelist_hook, add_file_hook, idb_loader_hook, mainloop_hook, drawworld_hook : procedure;
     SDL_InitPatch : procedure;
 
-  
+    PHYSFS_init, PHYSFS_deinit, PHYSFS_mount, PHYSFS_readBytes : function : LongInt;
+    PHYSFSRWOPS_openRead, PHYSFSRWOPS_openWrite, PHYSFS_openRead : function : pointer;
+    PHYSFS_eof, PHYSFS_close, PHYSFS_exists : function : boolean;
+
+    hedgewarsMountPackages, physfsReaderSetBuffer, hedgewarsMountPackage : procedure;
+    physfsReader : function : pointer;
--- a/hedgewars/uPhysFSLayer.pas	Tue Jun 18 22:39:57 2013 +0200
+++ b/hedgewars/uPhysFSLayer.pas	Wed Jun 19 00:52:39 2013 +0400
@@ -29,16 +29,16 @@
 
 function pfsExists(fname: shortstring): boolean;
 
+{$IFNDEF PAS2C}
 function  physfsReader(L: Plua_State; f: PFSFile; sz: Psize_t) : PChar; cdecl; external PhyslayerLibName;
 procedure physfsReaderSetBuffer(buf: pointer); cdecl; external PhyslayerLibName;
 procedure hedgewarsMountPackage(filename: PChar); cdecl; external PhyslayerLibName;
+{$ENDIF}
+
+implementation
+uses uUtils, uVariables;
 
 {$IFNDEF PAS2C}
-//apparently pas2c doesn't render the functions below if it finds 'implementation' first
-implementation
-uses uUtils, uVariables, sysutils;
-{$ENDIF}
-
 function PHYSFS_init(argv0: PChar) : LongInt; cdecl; external PhysfsLibName;
 function PHYSFS_deinit() : LongInt; cdecl; external PhysfsLibName;
 function PHYSFSRWOPS_openRead(fname: PChar): PSDL_RWops; cdecl; external PhyslayerLibName;
@@ -52,10 +52,6 @@
 function PHYSFS_exists(fname: PChar): LongBool; cdecl; external PhysfsLibName;
 
 procedure hedgewarsMountPackages(); cdecl; external PhyslayerLibName;
-
-{$IFDEF PAS2C}
-implementation
-uses uUtils, uVariables;
 {$ENDIF}
 
 (*****************************************************************)
--- a/hedgewars/uRender.pas	Tue Jun 18 22:39:57 2013 +0200
+++ b/hedgewars/uRender.pas	Wed Jun 19 00:52:39 2013 +0400
@@ -144,63 +144,6 @@
 glDrawArrays(GL_TRIANGLE_FAN, 0, High(VertexBuffer) - Low(VertexBuffer) + 1);
 end;
 
-
-procedure DrawTextureFromRectDir(X, Y, W, H: LongInt; r: PSDL_Rect; SourceTexture: PTexture);
-var
-    rr: TSDL_Rect;
-    VertexBuffer, TextureBuffer: array [0..3] of TVertex2f;
-    //VertexBuffer, TextureBuffer: TVertexRect;
-    _l, _r, _t, _b: GLfloat;
-begin
-if (SourceTexture^.h = 0) or (SourceTexture^.w = 0) then
-    exit;
-
-// do not draw anything outside the visible screen space (first check fixes some sprite drawing, e.g. hedgehogs)
-if (abs(X) > W) and ((abs(X + W / 2) - W / 2) > cScreenWidth / cScaleFactor) then
-    exit;
-if (abs(Y) > H) and ((abs(Y + H / 2 - (0.5 * cScreenHeight)) - H / 2) > cScreenHeight / cScaleFactor) then
-    exit;
-
-rr.x:= X;
-rr.y:= Y;
-rr.w:= W;
-rr.h:= H;
-
-_l:= r^.x / SourceTexture^.w * SourceTexture^.rx;
-_r:= (r^.x + r^.w) / SourceTexture^.w * SourceTexture^.rx;
-_t:= r^.y / SourceTexture^.h * SourceTexture^.ry;
-_b:= (r^.y + r^.h) / SourceTexture^.h * SourceTexture^.ry;
-
-glBindTexture(GL_TEXTURE_2D, SourceTexture^.id);
-
-VertexBuffer[0].X:= X;
-VertexBuffer[0].Y:= Y;
-VertexBuffer[1].X:= rr.w + X;
-VertexBuffer[1].Y:= Y;
-VertexBuffer[2].X:= rr.w + X;
-VertexBuffer[2].Y:= rr.h + Y;
-VertexBuffer[3].X:= X;
-VertexBuffer[3].Y:= rr.h + Y;
-
-TextureBuffer[0].X:= _l;
-TextureBuffer[0].Y:= _t;
-TextureBuffer[1].X:= _r;
-TextureBuffer[1].Y:= _t;
-TextureBuffer[2].X:= _r;
-TextureBuffer[2].Y:= _b;
-TextureBuffer[3].X:= _l;
-TextureBuffer[3].Y:= _b;
-
-SetVertexPointer(@VertexBuffer[0], Length(VertexBuffer));
-SetTexCoordPointer(@TextureBuffer[0], Length(VertexBuffer));
-
-{$IFDEF GL2}
-UpdateModelviewProjection;
-{$ENDIF}
-
-glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer));
-end;
-
 procedure DrawTexture(X, Y: LongInt; Texture: PTexture); inline;
 begin
     DrawTexture(X, Y, Texture, 1.0);
--- a/hedgewars/uScript.pas	Tue Jun 18 22:39:57 2013 +0200
+++ b/hedgewars/uScript.pas	Wed Jun 19 00:52:39 2013 +0400
@@ -85,6 +85,7 @@
     SysUtils,
     uIO,
     uPhysFSLayer
+{$IFDEF PAS2C}, hwpacksmounter{$ENDIF}
     ;
 
 var luaState : Plua_State;
--- a/misc/libphyslayer/hwpacksmounter.h	Tue Jun 18 22:39:57 2013 +0200
+++ b/misc/libphyslayer/hwpacksmounter.h	Wed Jun 19 00:52:39 2013 +0400
@@ -3,6 +3,10 @@
 
 #include "physfs.h"
 
+#ifndef STRINIT
+#include "lua.h"
+#endif
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -10,6 +14,9 @@
 PHYSFS_DECL void hedgewarsMountPackages();
 PHYSFS_DECL void hedgewarsMountPackage(char * fileName);
 
+PHYSFS_DECL const char * physfsReader(lua_State *L, PHYSFS_File *f, size_t *size);
+PHYSFS_DECL void physfsReaderSetBuffer(void *buffer);
+
 #ifdef __cplusplus
 }
 #endif
--- a/project_files/hwc/CMakeLists.txt	Tue Jun 18 22:39:57 2013 +0200
+++ b/project_files/hwc/CMakeLists.txt	Wed Jun 19 00:52:39 2013 +0400
@@ -10,6 +10,8 @@
 #compile our rtl implementation
 include_directories(${GLEW_INCLUDE_DIR})
 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/rtl)
+include_directories(${PHYSFS_INCLUDE_DIR})
+include_directories(${PHYSLAYER_INCLUDE_DIR})
 add_subdirectory(rtl)
 
 configure_file(${CMAKE_SOURCE_DIR}/hedgewars/config.inc.in ${CMAKE_CURRENT_BINARY_DIR}/config.inc)
--- a/project_files/hwc/rtl/fpcrtl.h	Tue Jun 18 22:39:57 2013 +0200
+++ b/project_files/hwc/rtl/fpcrtl.h	Wed Jun 19 00:52:39 2013 +0400
@@ -63,8 +63,10 @@
 #define luapas_luaopen_math                 luaopen_math
 #define luapas_luaopen_string               luaopen_string
 #define luapas_luaopen_table                luaopen_table
+#define luapas_lua_load                     lua_load
 
 #define sdlh_IMG_Load                       IMG_Load
+#define sdlh_IMG_Load_RW                    IMG_Load_RW
 
 #ifndef EMSCRIPTEN
 #define sdlh_Mix_AllocateChannels           Mix_AllocateChannels
@@ -77,6 +79,7 @@
 #define sdlh_Mix_HaltChannel                Mix_HaltChannel
 #define sdlh_Mix_HaltMusic                  Mix_HaltMusic
 #define sdlh_Mix_LoadMUS                    Mix_LoadMUS
+#define sdlh_Mix_LoadMUS_RW                 Mix_LoadMUS_RW
 #define sdlh_Mix_LoadWAV_RW                 Mix_LoadWAV_RW
 #define sdlh_Mix_OpenAudio                  Mix_OpenAudio
 #define sdlh_Mix_PauseMusic                 Mix_PauseMusic
@@ -96,6 +99,7 @@
 #define sdlh_Mix_HaltChannel                stub_Mix_HaltChannel
 #define sdlh_Mix_HaltMusic                  stub_Mix_HaltMusic
 #define sdlh_Mix_LoadMUS                    stub_Mix_LoadMUS
+#define sdlh_Mix_LoadMUS_RW                 stub_Mix_LoadMUS_RW
 #define sdlh_Mix_LoadWAV_RW                 stub_Mix_LoadWAV_RW
 #define sdlh_Mix_OpenAudio                  stub_Mix_OpenAudio
 #define sdlh_Mix_PauseMusic                 stub_Mix_PauseMusic
@@ -141,6 +145,11 @@
 #define sdlh_SDL_RWFromFile                 SDL_RWFromFile
 #define sdlh_SDL_SetColorKey                SDL_SetColorKey
 #define sdlh_SDL_SetVideoMode               SDL_SetVideoMode
+#define sdlh_SDL_WaitThread                 SDL_WaitThread
+#define sdlh_SDL_CreateMutex                SDL_CreateMutex
+#define sdlh_SDL_DestroyMutex               SDL_DestroyMutex
+#define sdlh_SDL_LockMutex                  SDL_mutexP
+#define sdlh_SDL_UnlockMutex                SDL_mutexV
 #ifndef EMSCRIPTEN
 #define sdlh_SDL_ShowCursor                 SDL_ShowCursor
 #else
@@ -165,6 +174,7 @@
 #define sdlh_SDLNet_TCP_Send                SDLNet_TCP_Send
 #define sdlh_TTF_Init                       TTF_Init
 #define sdlh_TTF_OpenFont                   TTF_OpenFont
+#define sdlh_TTF_OpenFontRW                 TTF_OpenFontRW
 #define sdlh_TTF_Quit                       TTF_Quit
 #define sdlh_TTF_RenderUTF8_Blended         TTF_RenderUTF8_Blended
 #define sdlh_TTF_RenderUTF8_Solid           TTF_RenderUTF8_Solid