Skip to content
This repository has been archived by the owner on Feb 8, 2023. It is now read-only.

Commit

Permalink
bring everything into one build script
Browse files Browse the repository at this point in the history
  • Loading branch information
laanwj committed Jul 19, 2013
1 parent ca02c7c commit ba1eed7
Show file tree
Hide file tree
Showing 33 changed files with 359 additions and 726 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
576 changes: 283 additions & 293 deletions esTransform.c → Common/esTransform.c

Large diffs are not rendered by default.

File renamed without changes.
3 changes: 3 additions & 0 deletions opengles-book-samples/Common/esUtil.h → Common/esUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,9 @@ void ESUTIL_API esMatrixMultiply(ESMatrix *result, ESMatrix *srcA, ESMatrix *src
//
void ESUTIL_API esMatrixLoadIdentity(ESMatrix *result);

void ESUTIL_API esMatrixInverse3x3(ESMatrix *result, ESMatrix *input);
void ESUTIL_API esMatrixTranspose(ESMatrix *result, ESMatrix *input);

#ifdef __cplusplus
}
#endif
Expand Down
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions cube.c → Cube/cube.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include <sys/mman.h>
#include <stdarg.h>

#include "esTransform.h"
#include "esUtil.h"
#include "eglutil.h"
#include "dump_gl_screen.h"

Expand Down Expand Up @@ -78,6 +78,7 @@ int main(int argc, char *argv[])
GLuint program;
GLint ret;
GLint width, height;
int frame;

const char *vertex_shader_source =
"uniform mat4 modelviewMatrix;\n"
Expand Down Expand Up @@ -373,8 +374,7 @@ int main(int argc, char *argv[])
GLint modelviewprojectionmatrix_handle = glGetUniformLocation(program, "modelviewprojectionMatrix");
GLint normalmatrix_handle = glGetUniformLocation(program, "normalMatrix");


for(int frame=0; frame<NUM_FRAMES; ++frame)
for(frame=0; frame<NUM_FRAMES; ++frame)
{
if((frame % 100) == 0)
printf("Frame %i\n", frame);
Expand Down
11 changes: 6 additions & 5 deletions cube_vbo.c → CubeVBO/cube_vbo.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include <sys/mman.h>
#include <stdarg.h>

#include "esTransform.h"
#include "esUtil.h"
#include "eglutil.h"
#include "dump_gl_screen.h"

Expand Down Expand Up @@ -365,12 +365,12 @@ int main(int argc, char *argv[])
/* Make vertex buffer object */
float vtx_logical[NUM_VERTICES * COMPONENTS_PER_VERTEX * 3];
size_t stride = COMPONENTS_PER_VERTEX * 3;

for(int vert=0; vert<NUM_VERTICES; ++vert)
int vert, comp;
for(vert=0; vert<NUM_VERTICES; ++vert)
{
int src_idx = vert * COMPONENTS_PER_VERTEX;
int dest_idx = vert * stride;
for(int comp=0; comp<COMPONENTS_PER_VERTEX; ++comp)
for(comp=0; comp<COMPONENTS_PER_VERTEX; ++comp)
{
vtx_logical[dest_idx+comp+0] = vVertices[src_idx + comp]; /* 0 */
vtx_logical[dest_idx+comp+3] = vNormals[src_idx + comp]; /* 1 */
Expand All @@ -396,7 +396,8 @@ int main(int argc, char *argv[])
GLint modelviewprojectionmatrix_handle = glGetUniformLocation(program, "modelviewprojectionMatrix");
GLint normalmatrix_handle = glGetUniformLocation(program, "normalMatrix");

for(int frame=0; frame<NUM_FRAMES; ++frame)
int frame;
for(frame=0; frame<NUM_FRAMES; ++frame)
{
if((frame % 100) == 0)
printf("Frame %i\n", frame);
Expand Down
89 changes: 64 additions & 25 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,33 +1,72 @@
MESAPATH = /home/cubox/mesa
COMMON_FLAGS = -g -std=c99 -fPIC -I$(MESAPATH)/include
CFLAGS += $(COMMON_FLAGS) -DMESA_EGL_NO_X11_HEADERS
CXXFLAGS += $(COMMON_FLAGS)
LDFLAGS += -lm -L$(MESAPATH)/lib -lEGL -lGLESv2
#../mesa/lib/egl/egl_gallium.so
# Straight forward Makefile to compile all examples in a row
MESA_INCLUDE ?= /home/cubox/mesa/include
MESA_LIB ?= /home/cubox/mesa/lib

GL_LIBS = $(PLATFORM_GL_LIBS)
TARGETS = cube compile cube_vbo rect
LIB_OBJS = esTransform.o write_bmp.o dump_gl_screen.o eglutil.o
INCDIR=-g -O -I./Common -I${MESA_INCLUDE} -DMESA_EGL_NO_X11_HEADERS
LIBS=-L${MESA_LIB} -lGLESv2 -lEGL -lm

all: $(TARGETS)
COMMONSRC=./Common/esShader.c \
./Common/esTransform.c \
./Common/esShapes.c \
./Common/esUtil.c \
./Common/eglutil.c
COMMONHRD=esUtil.h eglutil.h write_bmp.h

clean:
rm -f *.o ../lib/*.o
rm -f $(TARGETS)

cube: cube.o $(LIB_OBJS)
$(CXX) $(CFLAGS) -o $@ $^ $(GL_LIBS) $(LDFLAGS)
CH02SRC=./Hello_Triangle/Hello_Triangle.c
CH08SRC=./Simple_VertexShader/Simple_VertexShader.c
CH09SRC1=./Simple_Texture2D/Simple_Texture2D.c
CH09SRC2=./MipMap2D/MipMap2D.c
CH09SRC3=./Simple_TextureCubemap/Simple_TextureCubemap.c
CH09SRC4=./TextureWrap/TextureWrap.c
CH10SRC=./MultiTexture/MultiTexture.c
CH11SRC=./Multisample/Multisample.c
CH11SRC2=./Stencil_Test/Stencil_Test.c
CH13SRC2=./ParticleSystem/ParticleSystem.c
CUBESRC=./Cube/cube.c
CUBEVBOSRC=./CubeVBO/cube_vbo.c

cube_vbo: cube_vbo.o $(LIB_OBJS)
$(CXX) $(CFLAGS) -o $@ $^ $(GL_LIBS) $(LDFLAGS)
default: all

rect: rect.o $(LIB_OBJS)
$(CXX) $(CFLAGS) -o $@ $^ $(GL_LIBS) $(LDFLAGS)
all: ./Hello_Triangle/CH02_HelloTriangle \
./Simple_VertexShader/CH08_SimpleVertexShader \
./Simple_Texture2D/CH09_SimpleTexture2D \
./MipMap2D/CH09_MipMap2D \
./Simple_TextureCubemap/CH09_TextureCubemap \
./TextureWrap/CH09_TextureWrap \
./MultiTexture/CH10_MultiTexture \
./Multisample/CH11_Multisample \
./Stencil_Test/CH11_Stencil_Test \
./ParticleSystem/CH13_ParticleSystem \
./Cube/cube \
./CubeVBO/cube_vbo

clean:
find . -name "CH??_*" | xargs rm -f

compile: compile.o $(LIB_OBJS)
$(CXX) $(CFLAGS) -o $@ $^ $(GL_LIBS) $(LDFLAGS)

eglinfo: eglinfo.o $(LIB_OBJS)
$(CXX) $(CFLAGS) -o $@ $^ $(GL_LIBS) $(LDFLAGS)
./Hello_Triangle/CH02_HelloTriangle: ${COMMONSRC} ${COMMONHDR} ${CH02SRC}
gcc ${COMMONSRC} ${CH02SRC} -o $@ ${INCDIR} ${LIBS}
./Simple_VertexShader/CH08_SimpleVertexShader: ${COMMONSRC} ${COMMONHDR} ${CH08SRC}
gcc ${COMMONSRC} ${CH08SRC} -o ./$@ ${INCDIR} ${LIBS}
./Simple_Texture2D/CH09_SimpleTexture2D: ${COMMONSRC} ${COMMONHDR} ${CH09SRC1}
gcc ${COMMONSRC} ${CH09SRC1} -o ./$@ ${INCDIR} ${LIBS}
./MipMap2D/CH09_MipMap2D: ${COMMONSRC} ${COMMONHDR} ${CH09SRC2}
gcc ${COMMONSRC} ${CH09SRC2} -o ./$@ ${INCDIR} ${LIBS}
./Simple_TextureCubemap/CH09_TextureCubemap: ${COMMONSRC} ${COMMONHDR} ${CH09SRC3}
gcc ${COMMONSRC} ${CH09SRC3} -o ./$@ ${INCDIR} ${LIBS}
./TextureWrap/CH09_TextureWrap: ${COMMONSRC} ${COMMONHDR} ${CH09SRC4}
gcc ${COMMONSRC} ${CH09SRC4} -o ./$@ ${INCDIR} ${LIBS}
./MultiTexture/CH10_MultiTexture: ${COMMONSRC} ${COMMONHDR} ${CH10SRC}
gcc ${COMMONSRC} ${CH10SRC} -o ./$@ ${INCDIR} ${LIBS}
./Multisample/CH11_Multisample: ${COMMONSRC} ${COMMONHDR} ${CH11SRC}
gcc ${COMMONSRC} ${CH11SRC} -o ./$@ ${INCDIR} ${LIBS}
./Stencil_Test/CH11_Stencil_Test: ${COMMONSRC} ${COMMONHDR} ${CH11SRC2}
gcc ${COMMONSRC} ${CH11SRC2} -o ./$@ ${INCDIR} ${LIBS}
./Noise3D/CH13_Noise3D: ${COMMONSRC} ${COMMONHDR} ${CH13SRC1}
gcc ${COMMONSRC} ${CH13SRC1} -o ./$@ ${INCDIR} ${LIBS}
./ParticleSystem/CH13_ParticleSystem: ${COMMONSRC} ${COMMONHDR} ${CH13SRC2}
gcc ${COMMONSRC} ${CH13SRC2} -o ./$@ ${INCDIR} ${LIBS}
./Cube/cube: ${COMMONSRC} ${COMMONHDR} ${CUBESRC}
gcc ${COMMONSRC} ${CUBESRC} -o ./$@ ${INCDIR} ${LIBS}
./CubeVBO/cube_vbo: ${COMMONSRC} ${COMMONHDR} ${CUBEVBOSRC}
gcc ${COMMONSRC} ${CUBEVBOSRC} -o ./$@ ${INCDIR} ${LIBS}

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
127 changes: 0 additions & 127 deletions esTransform.h

This file was deleted.

Loading

0 comments on commit ba1eed7

Please sign in to comment.