Commit bb5b4401412846ad829b8380bed0419264fa653b

Authored by dg
1 parent 56753989

Fixed drawQuad (it would randomly start using a texture when when told not to)


git-svn-id: http://svn.net-core.org/repos/t-engine4@3371 51575b47-30f0-44d4-a5cc-537603b46e54
@@ -832,6 +832,38 @@ static int gl_texture_to_sdl(lua_State *L) @@ -832,6 +832,38 @@ static int gl_texture_to_sdl(lua_State *L)
832 return 1; 832 return 1;
833 } 833 }
834 834
  835 +static int gl_tex_white = 0;
  836 +int init_blank_surface()
  837 +{
  838 + Uint32 rmask, gmask, bmask, amask;
  839 +#if SDL_BYTEORDER == SDL_BIG_ENDIAN
  840 + rmask = 0xff000000;
  841 + gmask = 0x00ff0000;
  842 + bmask = 0x0000ff00;
  843 + amask = 0x000000ff;
  844 +#else
  845 + rmask = 0x000000ff;
  846 + gmask = 0x0000ff00;
  847 + bmask = 0x00ff0000;
  848 + amask = 0xff000000;
  849 +#endif
  850 + SDL_Surface *s = SDL_CreateRGBSurface(
  851 + SDL_SWSURFACE | SDL_SRCALPHA,
  852 + 4,
  853 + 4,
  854 + 32,
  855 + rmask, gmask, bmask, amask
  856 + );
  857 + SDL_FillRect(s, NULL, SDL_MapRGBA(s->format, 255, 255, 255, 255));
  858 +
  859 + glGenTextures(1, &gl_tex_white);
  860 + tglBindTexture(GL_TEXTURE_2D, gl_tex_white);
  861 + int fw, fh;
  862 + make_texture_for_surface(s, &fw, &fh);
  863 + copy_surface_to_texture(s);
  864 + return gl_tex_white;
  865 +}
  866 +
835 static int gl_draw_quad(lua_State *L) 867 static int gl_draw_quad(lua_State *L)
836 { 868 {
837 int x = luaL_checknumber(L, 1); 869 int x = luaL_checknumber(L, 1);
@@ -854,7 +886,7 @@ static int gl_draw_quad(lua_State *L) @@ -854,7 +886,7 @@ static int gl_draw_quad(lua_State *L)
854 } 886 }
855 else 887 else
856 { 888 {
857 - tglBindTexture(GL_TEXTURE_2D, 0); 889 + tglBindTexture(GL_TEXTURE_2D, gl_tex_white);
858 } 890 }
859 891
860 GLfloat texcoords[2*4] = { 892 GLfloat texcoords[2*4] = {
@@ -22,5 +22,6 @@ @@ -22,5 +22,6 @@
22 #define _CORELUA_H_ 22 #define _CORELUA_H_
23 23
24 extern int luaopen_core(lua_State *L); 24 extern int luaopen_core(lua_State *L);
  25 +extern int init_blank_surface();
25 26
26 #endif 27 #endif
@@ -908,6 +908,7 @@ int main(int argc, char *argv[]) @@ -908,6 +908,7 @@ int main(int argc, char *argv[])
908 } 908 }
909 909
910 // setupDisplayTimer(30); 910 // setupDisplayTimer(30);
  911 + init_blank_surface();
911 912
912 boot_lua(2, FALSE, argc, argv); 913 boot_lua(2, FALSE, argc, argv);
913 914