paysages: Sources refactoring (splitting lib and gui).
git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@200 b1fd45b6-86a6-48da-8261-f70d1f35bdcc
This commit is contained in:
parent
bfd25bcf42
commit
ef68f38061
14 changed files with 88 additions and 157 deletions
2
Makefile
2
Makefile
|
@ -1,7 +1,9 @@
|
||||||
all:
|
all:
|
||||||
cd lib_paysages && make
|
cd lib_paysages && make
|
||||||
|
cd gui_gtk && make
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
cd lib_paysages && make clean
|
cd lib_paysages && make clean
|
||||||
|
cd gui_gtk && make clean
|
||||||
|
|
||||||
.PHONY:all clean
|
.PHONY:all clean
|
||||||
|
|
21
gui_gtk/Makefile
Normal file
21
gui_gtk/Makefile
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
SOURCES=$(wildcard *.c)
|
||||||
|
OBJECTS=${SOURCES:.c=.o}
|
||||||
|
HEADERS=$(wildcard ../lib_paysages/shared/*.h ../lib_paysages/*.h *.h)
|
||||||
|
RESULT=paysages-gtk
|
||||||
|
CC_FLAGS=-g -pg -Wall $(shell pkg-config --cflags gtk+-3.0) -I..
|
||||||
|
CC_LDFLAGS=$(shell pkg-config --libs gtk+-3.0) -L../lib_paysages/ -lpaysages
|
||||||
|
|
||||||
|
all:${RESULT}
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f ${OBJECTS}
|
||||||
|
rm -f ${RESULT}
|
||||||
|
|
||||||
|
%.o:%.c ${HEADERS}
|
||||||
|
${CC} -c ${CC_FLAGS} $< -o $@
|
||||||
|
|
||||||
|
${RESULT}:${OBJECTS}
|
||||||
|
${CC} $^ ${CC_LDFLAGS} -o $@
|
||||||
|
|
||||||
|
.PHONY:all clean
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||||
|
|
||||||
#include "../shared/types.h"
|
#include "lib_paysages/shared/types.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
@ -24,6 +24,8 @@ static inline GtkWidget* _get_widget(const char* name, const char* file, int lin
|
||||||
}
|
}
|
||||||
#define GET_WIDGET(_name_) (_get_widget(_name_, __FILE__, __LINE__))
|
#define GET_WIDGET(_name_) (_get_widget(_name_, __FILE__, __LINE__))
|
||||||
|
|
||||||
|
void guiUpdate();
|
||||||
|
|
||||||
void guiTerrainInit();
|
void guiTerrainInit();
|
||||||
|
|
||||||
void guiWaterInit();
|
void guiWaterInit();
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/* Noise editor dialog */
|
/* Noise editor dialog */
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "../shared/functions.h"
|
#include "lib_paysages/shared/functions.h"
|
||||||
#include "../shared/constants.h"
|
#include "lib_paysages/shared/constants.h"
|
||||||
|
|
||||||
static GtkWidget* _dialog;
|
static GtkWidget* _dialog;
|
||||||
static SmallPreview* _preview;
|
static SmallPreview* _preview;
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||||
|
|
||||||
#include "../shared/functions.h"
|
#include "lib_paysages/shared/functions.h"
|
||||||
#include "../shared/constants.h"
|
#include "lib_paysages/shared/constants.h"
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
GtkBuilder* gui_definition;
|
GtkBuilder* gui_definition;
|
||||||
|
@ -106,3 +106,11 @@ void guiUpdate()
|
||||||
|
|
||||||
guiPreviewRedrawAll();
|
guiPreviewRedrawAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int main(int argc, char** argv)
|
||||||
|
{
|
||||||
|
paysagesInit();
|
||||||
|
guiInit();
|
||||||
|
guiStart();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
@ -3,11 +3,10 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "../shared/types.h"
|
#include "lib_paysages/shared/types.h"
|
||||||
#include "../shared/functions.h"
|
#include "lib_paysages/shared/functions.h"
|
||||||
#include "../shared/constants.h"
|
#include "lib_paysages/shared/constants.h"
|
||||||
#include "../shared/system.h"
|
#include "lib_paysages/shared/system.h"
|
||||||
#include "../water.h"
|
|
||||||
|
|
||||||
#define MAX_PREVIEWS 30
|
#define MAX_PREVIEWS 30
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
/* Terrain tab */
|
/* Terrain tab */
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "../shared/functions.h"
|
#include "lib_paysages/shared/functions.h"
|
||||||
#include "../shared/constants.h"
|
#include "lib_paysages/shared/constants.h"
|
||||||
#include "../clouds.h"
|
#include "lib_paysages/clouds.h"
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
static SmallPreview* _preview;
|
static SmallPreview* _preview;
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
/* Terrain tab */
|
/* Terrain tab */
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "../shared/functions.h"
|
#include "lib_paysages/shared/functions.h"
|
||||||
#include "../shared/constants.h"
|
#include "lib_paysages/shared/constants.h"
|
||||||
#include "../shared/globals.h"
|
#include "lib_paysages/shared/globals.h"
|
||||||
#include "../shared/system.h"
|
#include "lib_paysages/shared/system.h"
|
||||||
|
|
||||||
static GtkImage* _render_final;
|
static GtkImage* _render_final;
|
||||||
static GdkPixbuf* _render_buffer = NULL;
|
static GdkPixbuf* _render_buffer = NULL;
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
/* Terrain tab */
|
/* Terrain tab */
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "../shared/functions.h"
|
#include "lib_paysages/shared/functions.h"
|
||||||
#include "../shared/constants.h"
|
#include "lib_paysages/shared/constants.h"
|
||||||
#include "../sky.h"
|
#include "lib_paysages/sky.h"
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
static SmallPreview* _preview_horizon;
|
static SmallPreview* _preview_horizon;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/* Terrain tab */
|
/* Terrain tab */
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "../shared/functions.h"
|
#include "lib_paysages/shared/functions.h"
|
||||||
|
|
||||||
static SmallPreview* _preview;
|
static SmallPreview* _preview;
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
/* Terrain tab */
|
/* Terrain tab */
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "../shared/functions.h"
|
#include "lib_paysages/shared/functions.h"
|
||||||
#include "../shared/constants.h"
|
#include "lib_paysages/shared/constants.h"
|
||||||
#include "../water.h"
|
#include "lib_paysages/water.h"
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
static SmallPreview* _preview_coverage;
|
static SmallPreview* _preview_coverage;
|
||||||
|
|
|
@ -3,7 +3,7 @@ OBJECTS=${SOURCES:.c=.o}
|
||||||
HEADERS=$(wildcard shared/*.h *.h)
|
HEADERS=$(wildcard shared/*.h *.h)
|
||||||
RESULT=libpaysages.so
|
RESULT=libpaysages.so
|
||||||
CC_FLAGS=-g -pg -Wall $(shell pkg-config --cflags glib-2.0)
|
CC_FLAGS=-g -pg -Wall $(shell pkg-config --cflags glib-2.0)
|
||||||
CC_LDFLAGS=$(shell pkg-config --libs glib-2.0)
|
CC_LDFLAGS=$(shell pkg-config --libs glib-2.0) -lIL -lILU
|
||||||
|
|
||||||
all:${RESULT}
|
all:${RESULT}
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ clean:
|
||||||
${CC} -c ${CC_FLAGS} $< -o $@
|
${CC} -c ${CC_FLAGS} $< -o $@
|
||||||
|
|
||||||
${RESULT}:${OBJECTS}
|
${RESULT}:${OBJECTS}
|
||||||
${CC} -o $@ -shared -Wl ${CC_LDFLAGS} $*
|
${CC} $^ -shared ${CC_LDFLAGS} -o $@
|
||||||
|
|
||||||
.PHONY:all clean
|
.PHONY:all clean
|
||||||
|
|
||||||
|
|
|
@ -12,94 +12,8 @@
|
||||||
#include "shared/functions.h"
|
#include "shared/functions.h"
|
||||||
#include "shared/globals.h"
|
#include "shared/globals.h"
|
||||||
|
|
||||||
/*static char _filename[22];
|
void paysagesInit()
|
||||||
|
|
||||||
static void _setupFilename(int number)
|
|
||||||
{
|
{
|
||||||
_filename[15] = (char)(97 + number / 26);
|
|
||||||
_filename[16] = (char)(97 + number % 26);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void _doRender(int number, int postonly)
|
|
||||||
{
|
|
||||||
_setupFilename(number);
|
|
||||||
fprintf(stderr, "Rendering %s...\n", _filename);
|
|
||||||
|
|
||||||
autoRenderAll(postonly);
|
|
||||||
|
|
||||||
fprintf(stderr, "Saving %s...\n", _filename);
|
|
||||||
remove(_filename);
|
|
||||||
renderSaveToFile(_filename);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void _renderTurnTable(int count)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < count; i++)
|
|
||||||
{
|
|
||||||
cameraSetLocation(sin(M_PI * 2.0 * (double)i / (double)count) * 20.0, 8.0, cos(M_PI * 2.0 * (double)i / (double)count) * 20.0);
|
|
||||||
|
|
||||||
_doRender(i, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void _renderFly(int count, double speed)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
double x, y, z, ty1;
|
|
||||||
|
|
||||||
x = 0.0;
|
|
||||||
y = 8.0;
|
|
||||||
z = 0.0;
|
|
||||||
for (i = 0; i < count; i++)
|
|
||||||
{
|
|
||||||
cameraSetLocation(x, y, z);
|
|
||||||
cameraSetTarget(x, y, z + 1.0);
|
|
||||||
_doRender(i, 0);
|
|
||||||
|
|
||||||
ty1 = terrainGetHeight(x, z);
|
|
||||||
if (y > ty1 + 9.0)
|
|
||||||
{
|
|
||||||
y -= speed;
|
|
||||||
}
|
|
||||||
if (y < ty1 + 7.0)
|
|
||||||
{
|
|
||||||
y += speed;
|
|
||||||
}
|
|
||||||
z += speed;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void _renderDayTime(int count)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < count; i++)
|
|
||||||
{
|
|
||||||
autoSetDaytimeFraction(0.4 + (double)i / (double)count);
|
|
||||||
|
|
||||||
_doRender(i, i > 0 ? 1 : 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void _renderQuality()
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 1; i <= 10; i++)
|
|
||||||
{
|
|
||||||
autoSetRenderQuality(i);
|
|
||||||
renderSetSize(800, 600);
|
|
||||||
|
|
||||||
_doRender(i - 1, 0);
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
|
||||||
{
|
|
||||||
/*strcpy(_filename, "./output/result__.png");*/
|
|
||||||
|
|
||||||
ilInit();
|
ilInit();
|
||||||
iluInit();
|
iluInit();
|
||||||
|
|
||||||
|
@ -107,20 +21,8 @@ int main(int argc, char** argv)
|
||||||
cameraSetTarget(0.0, 5.0, 0.0);
|
cameraSetTarget(0.0, 5.0, 0.0);
|
||||||
|
|
||||||
autoInit();
|
autoInit();
|
||||||
guiInit();
|
|
||||||
|
|
||||||
autoSetRenderQuality(5);
|
autoSetRenderQuality(5);
|
||||||
autoGenRealisticLandscape(0);
|
autoGenRealisticLandscape(0);
|
||||||
autoSetDaytime(8, 30);
|
autoSetDaytime(8, 30);
|
||||||
|
|
||||||
guiStart();
|
|
||||||
|
|
||||||
//_doRender(0, 0);
|
|
||||||
//_renderTurnTable(600);
|
|
||||||
//_renderDayTime(600);
|
|
||||||
//_renderFly(600, 0.1);
|
|
||||||
//_renderQuality();
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
void paysagesInit();
|
||||||
|
|
||||||
/* array.c */
|
/* array.c */
|
||||||
void arrayCreate(Array* array, int item_size);
|
void arrayCreate(Array* array, int item_size);
|
||||||
void arrayDelete(Array* array);
|
void arrayDelete(Array* array);
|
||||||
|
@ -91,11 +93,6 @@ void fogSetColor(Color col);
|
||||||
void fogSetDistance(double near, double far);
|
void fogSetDistance(double near, double far);
|
||||||
Color fogApplyToLocation(Vector3 location, Color base);
|
Color fogApplyToLocation(Vector3 location, Color base);
|
||||||
|
|
||||||
/* gui.c */
|
|
||||||
void guiInit();
|
|
||||||
void guiStart();
|
|
||||||
void guiUpdate();
|
|
||||||
|
|
||||||
/* lighting.c */
|
/* lighting.c */
|
||||||
void lightingSave(FILE* f);
|
void lightingSave(FILE* f);
|
||||||
void lightingLoad(FILE* f);
|
void lightingLoad(FILE* f);
|
||||||
|
|
Loading…
Reference in a new issue