Permalink
Browse files

Merged upstream master / 07bdde7, support for sprite-depth stuff

  • Loading branch information...
1 parent c8229f3 commit 3abdf2cf94595ee967bab54da42a9639900a255e @superjer committed Mar 13, 2012
View
@@ -1,7 +1,6 @@
*.dll
*.[oa]
*.swp
-*.sh
cscope.*
tags
spartor_linux
View
@@ -22,6 +22,7 @@ OBJS = engine/main.o \
engine/sprite_helpers.o \
engine/projection.o \
engine/sjglob.o \
+ engine/helpers.o \
engine/mt19937ar/mt19937ar.o
FLAGS = --std=c99 -g -Wall -Wextra -Wno-unused-parameter -Wno-overlength-strings -pedantic -DGLEW_STATIC
INC = -Iengine -Igame
View
@@ -27,6 +27,11 @@ connect connect <host> [[:]port]
Connect to a server. E.g. connect 127.0.0.1:31103
+depth depth
+
+ Display depth buffer values.
+
+
dimetric dimetric
Switch the current context to render mode dimetric. See also
@@ -121,6 +126,12 @@ report report
Show a report of all the game objects.
+resprite resprite
+
+ Reload all sprite information from texture definition files
+ ( game/textures/*.png.txt )
+ for all currently loaded textures.
+
save save <mapname>
Saves the current context to mapname.txt. If it already exists,
View
@@ -325,8 +325,8 @@ static void music_test( int *buf, int len )
else if( t <= e->sustain ) ;
else if( t <= e->release ) veloc *= (e->release-t)/(e->release-e->sustain);
- double tr_freq = e->start_freq * pow(TWELFTH_ROOT,e->tremolo_steps);
- double vi_freq = e->start_freq * pow(TWELFTH_ROOT,e->vibrato_steps);
+ //double tr_freq = e->start_freq * pow(TWELFTH_ROOT,e->tremolo_steps);
+ //double vi_freq = e->start_freq * pow(TWELFTH_ROOT,e->vibrato_steps);
e->tremolo_period += e->tremolo_speed;
e->tremolo_speed += e->tremolo_accel;
View
@@ -0,0 +1,43 @@
+/**
+ ** SPARToR
+ ** Network Game Engine
+ ** Copyright (C) 2010-2012 Jer Wilson
+ **
+ ** See COPYING for details.
+ **
+ ** http://www.superjer.com/
+ ** http://www.spartor.com/
+ ** http://github.com/superjer/SPARToR
+ **/
+
+
+#include <stdlib.h>
+#include <string.h>
+
+
+#define POINTLIS_CHUNK 80
+
+
+typedef void *thing;
+
+
+// build a unique list of pointers with no storage limit and no storage overhead
+// returns true if adding for the 1st time
+int pointlis_add( thing **list, thing item )
+{
+ if( !list[0] ) list[0] = calloc( POINTLIS_CHUNK, sizeof **list );
+
+ size_t n = 0;
+ while( list[0][n] ) {
+ if( list[0][n] == item ) return 0; // found!
+ n++;
+ }
+
+ if( n % POINTLIS_CHUNK == POINTLIS_CHUNK-1 ) { // need to grow
+ list[0] = realloc( list[0], (n+1+POINTLIS_CHUNK) * sizeof **list );
+ memset( list[0]+n+1, 0, POINTLIS_CHUNK * sizeof **list );
+ }
+
+ list[0][n] = item;
+ return 1;
+}
View
@@ -0,0 +1,8 @@
+
+#ifndef SPARTOR_HELPERS__
+#define SPARTOR_HELPERS__
+
+int pointlis_add( void ***list, void *item );
+
+#endif
+
View
@@ -269,8 +269,15 @@ int load_context(const char *name,int context,int loadfr)
co->x = x;
co->y = y;
co->z = z;
- if( co->map ) free(co->map ); //FIXME remove hack_map someday and don't free this stuff here
- if( co->dmap ) free(co->dmap);
+
+ // FIXME: MEM LEAK!
+ // Using resprite shortly after unloading a context WOULD cause a crash
+ // Garbage collection of old contexts is NOT implemented yet, so they just leak for now
+ // FIXME: MEM LEAK!
+
+ // if( co->map ) free(co->map ); //FIXME remove hack_map someday and don't free this stuff here
+ // if( co->dmap ) free(co->dmap);
+
co->map = hack_map = map;
co->dmap = hack_dmap = dmap;
View
@@ -52,25 +52,60 @@ void SJGL_SetTex(GLuint tex)
glBindTexture(GL_TEXTURE_2D,0); //FIXME: hack 4 win, suddenly also useful for handling an invalid tex
- if( tex >= tex_count ) { SJC_Write("Attempted to set invalid texture (%d/%d)",tex,tex_count); return; }
+ if( tex >= tex_count ) { /*SJC_Write("Attempted to set invalid texture (%d/%d)",tex,tex_count);*/ return; }
glBindTexture( GL_TEXTURE_2D, textures[tex].glname );
}
-//uses GL to do draw a sprite
+// wrapper for SJFL_Blit when there's only one z
int SJGL_Blit(REC *s, int x, int y, int z)
{
- if( z<0 ) z = (y+s->h)*-z;
+ return SJGL_BlitSkew(s,x,y,z,z);
+}
+
+//uses GL to do draw a sprite
+int SJGL_BlitSkew(REC *s, int x, int y, int zlo, int zhi)
+{
int x2 = ( s->w > 0 ? x+s->w : x-s->w );
int y2 = ( s->h > 0 ? y+s->h : y-s->h );
+ int rhi=0, ghi=0, bhi=0;
+ int rlo=0, glo=0, blo=0;
+
+ if( m_showdepth ) {
+ int grad;
+ int sect;
+
+ #define GET_COLOR(z,r,g,b) \
+ grad = z + 512; \
+ sect = (grad / 256 + 70) % 7; \
+ grad = grad % 256; \
+ \
+ switch( sect ) { \
+ case 0: r = grad; break; \
+ case 1: r = 255; b = grad; break; \
+ case 2: r = 255 - grad; b = 255; break; \
+ case 3: b = 255; g = grad; break; \
+ case 4: b = 255 - grad; g = 255; break; \
+ case 5: r = grad; g = 255; break; \
+ case 6: r = 255; b = grad; g = 255; break; \
+ }
+
+ GET_COLOR(zlo,rlo,glo,blo);
+ GET_COLOR(zhi,rhi,ghi,bhi);
+
+ glBindTexture(GL_TEXTURE_2D,0);
+ }
+
glBegin(GL_QUADS);
- glTexCoord3i(s->x , s->y , z); glVertex3i(x , y , z);
- glTexCoord3i(s->x+s->w, s->y , z); glVertex3i(x2, y , z);
- glTexCoord3i(s->x+s->w, s->y+s->h, z); glVertex3i(x2, y2, z);
- glTexCoord3i(s->x , s->y+s->h, z); glVertex3i(x , y2, z);
+ if( m_showdepth ) glColor3ub(rhi,ghi,bhi);
+ glTexCoord2i(s->x , s->y ); glVertex3i(x , y , zhi);
+ glTexCoord2i(s->x+s->w, s->y ); glVertex3i(x2, y , zhi);
+ if( m_showdepth ) glColor3ub(rlo,glo,blo);
+ glTexCoord2i(s->x+s->w, s->y+s->h); glVertex3i(x2, y2, zlo);
+ glTexCoord2i(s->x , s->y+s->h); glVertex3i(x , y2, zlo);
glEnd();
return 0;
View
@@ -21,6 +21,7 @@ typedef struct{
SDL_Surface *SJDL_CopyScaled(SDL_Surface *src, Uint32 flags, int scale);
void SJGL_SetTex(GLuint tex);
int SJGL_Blit(REC *s, int x, int y, int z);
+int SJGL_BlitSkew(REC *s, int x, int y, int zlo, int zhi);
void SJDL_SetPixel(SDL_Surface *surf, int x, int y, Uint8 R, Uint8 G, Uint8 B);
void SJDL_GetPixel(SDL_Surface *surf, int x, int y, Uint8 *R, Uint8 *G, Uint8 *B);
GLenum SJDL_GLFormatOf(SDL_Surface *surf);
Oops, something went wrong.

0 comments on commit 3abdf2c

Please sign in to comment.