progs: Get more samples building on windows.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
SConscript([
|
||||
'util/SConscript',
|
||||
'demos/SConscript',
|
||||
'trivial/SConscript',
|
||||
'vp/SConscript',
|
||||
|
@@ -1,11 +1,22 @@
|
||||
Import('env')
|
||||
Import('*')
|
||||
|
||||
if not env['GLUT']:
|
||||
Return()
|
||||
|
||||
env = env.Clone()
|
||||
|
||||
env.Prepend(LIBS = ['$GLUT_LIB'])
|
||||
env.Prepend(CPPPATH = [
|
||||
'../util',
|
||||
])
|
||||
|
||||
env.Prepend(LIBS = [
|
||||
util,
|
||||
'$GLUT_LIB'
|
||||
])
|
||||
|
||||
if env['platform'] == 'windows':
|
||||
env.Append(CPPDEFINES = ['NOMINMAX'])
|
||||
env.Prepend(LIBS = ['winmm'])
|
||||
|
||||
progs = [
|
||||
'arbfplight',
|
||||
@@ -38,7 +49,6 @@ progs = [
|
||||
'multiarb',
|
||||
'paltex',
|
||||
'pointblast',
|
||||
'rain',
|
||||
'ray',
|
||||
'readpix',
|
||||
'reflect',
|
||||
@@ -65,7 +75,15 @@ progs = [
|
||||
]
|
||||
|
||||
for prog in progs:
|
||||
prog = env.Program(
|
||||
env.Program(
|
||||
target = prog,
|
||||
source = prog + '.c',
|
||||
)
|
||||
|
||||
env.Program(
|
||||
target = 'rain',
|
||||
source = [
|
||||
'rain.cxx',
|
||||
'particles.cxx',
|
||||
]
|
||||
)
|
||||
|
@@ -7,19 +7,16 @@
|
||||
* Daniel Borca
|
||||
*/
|
||||
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <GL/glew.h>
|
||||
#include <GL/glut.h>
|
||||
|
||||
#define DEPTH 5.0f
|
||||
|
||||
static PFNGLFOGCOORDFEXTPROC glFogCoordf_ext;
|
||||
static PFNGLFOGCOORDPOINTEREXTPROC glFogCoordPointer_ext;
|
||||
|
||||
static GLboolean have_fog_coord;
|
||||
|
||||
static GLfloat camz;
|
||||
|
||||
static GLint fogMode;
|
||||
@@ -45,10 +42,11 @@ Reset(void)
|
||||
}
|
||||
|
||||
|
||||
static void APIENTRY
|
||||
glFogCoordf_nop (GLfloat f)
|
||||
static void
|
||||
glFogCoordf_ext (GLfloat f)
|
||||
{
|
||||
(void)f;
|
||||
if (fogCoord)
|
||||
glFogCoordfEXT(f);
|
||||
}
|
||||
|
||||
|
||||
@@ -120,14 +118,11 @@ SetFogMode(GLint fogMode)
|
||||
static GLboolean
|
||||
SetFogCoord(GLboolean fogCoord)
|
||||
{
|
||||
glFogCoordf_ext = glFogCoordf_nop;
|
||||
|
||||
if (!have_fog_coord) {
|
||||
if (!GLEW_EXT_fog_coord) {
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
if (fogCoord) {
|
||||
glFogCoordf_ext = (PFNGLFOGCOORDFEXTPROC)glutGetProcAddress("glFogCoordfEXT");
|
||||
glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FOG_COORDINATE_EXT);
|
||||
}
|
||||
else {
|
||||
@@ -340,7 +335,7 @@ Key( unsigned char key, int x, int y )
|
||||
SetFogMode(fogMode);
|
||||
break;
|
||||
case 'c':
|
||||
fogCoord = SetFogCoord(fogCoord ^ GL_TRUE);
|
||||
fogCoord = SetFogCoord(fogCoord ^ GL_TRUE);
|
||||
break;
|
||||
case 't':
|
||||
Texture = !Texture;
|
||||
@@ -372,8 +367,7 @@ Init(void)
|
||||
|
||||
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
|
||||
have_fog_coord = glutExtensionSupported("GL_EXT_fog_coord");
|
||||
if (!have_fog_coord) {
|
||||
if (!GLEW_EXT_fog_coord) {
|
||||
printf("GL_EXT_fog_coord not supported!\n");
|
||||
}
|
||||
|
||||
@@ -400,10 +394,9 @@ Init(void)
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glTexCoordPointer(2, GL_FLOAT, 0, texcoord_pointer);
|
||||
|
||||
if (have_fog_coord) {
|
||||
glFogCoordPointer_ext = (PFNGLFOGCOORDPOINTEREXTPROC)glutGetProcAddress("glFogCoordPointerEXT");
|
||||
if (GLEW_EXT_fog_coord) {
|
||||
glEnableClientState(GL_FOG_COORDINATE_ARRAY_EXT);
|
||||
glFogCoordPointer_ext(GL_FLOAT, 0, fogcoord_pointer);
|
||||
glFogCoordPointerEXT(GL_FLOAT, 0, fogcoord_pointer);
|
||||
}
|
||||
|
||||
Reset();
|
||||
@@ -417,6 +410,7 @@ main( int argc, char *argv[] )
|
||||
glutInitWindowSize( 600, 600 );
|
||||
glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH );
|
||||
glutCreateWindow(argv[0]);
|
||||
glewInit();
|
||||
glutReshapeFunc( Reshape );
|
||||
glutKeyboardFunc( Key );
|
||||
glutDisplayFunc( Display );
|
||||
|
@@ -22,6 +22,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
#include <GL/glew.h>
|
||||
#include <GL/glut.h>
|
||||
|
||||
#include "readtex.h"
|
||||
@@ -438,6 +439,7 @@ int main( int argc, char *argv[] )
|
||||
glutInitWindowSize(WinWidth, WinHeight);
|
||||
glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH );
|
||||
glutCreateWindow(argv[0] );
|
||||
glewInit();
|
||||
glutReshapeFunc( Reshape );
|
||||
glutKeyboardFunc( Key );
|
||||
glutDisplayFunc( Display );
|
||||
|
@@ -14,6 +14,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <GL/glew.h>
|
||||
#include <GL/glut.h>
|
||||
|
||||
#include "readtex.h"
|
||||
@@ -326,6 +327,7 @@ int main( int argc, char *argv[] )
|
||||
glutInitWindowPosition( 0, 0 );
|
||||
glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE );
|
||||
glutCreateWindow(argv[0] );
|
||||
glewInit();
|
||||
|
||||
Init( argc, argv );
|
||||
|
||||
|
@@ -24,8 +24,6 @@ extern "C" {
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#include <mmsystem.h>
|
||||
#include "particles.cxx"
|
||||
#include "readtex.c"
|
||||
#endif
|
||||
|
||||
#ifdef XMESA
|
||||
|
@@ -18,7 +18,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glew.h>
|
||||
#include <GL/glut.h>
|
||||
|
||||
|
||||
@@ -662,6 +662,8 @@ main(int argc, char **argv)
|
||||
exit(0);
|
||||
}
|
||||
|
||||
glewInit();
|
||||
|
||||
init();
|
||||
|
||||
printHelp();
|
||||
|
@@ -11,7 +11,7 @@
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include "GL/glew.h"
|
||||
#include "GL/glut.h"
|
||||
|
||||
#include "readtex.h"
|
||||
@@ -29,8 +29,7 @@ static GLubyte *Image;
|
||||
static int ImgWidth, ImgHeight;
|
||||
static GLenum ImgFormat;
|
||||
|
||||
typedef void (APIENTRY * PFNWINDOWPOSFUNC)(GLfloat x, GLfloat y);
|
||||
static PFNWINDOWPOSFUNC WindowPosFunc;
|
||||
static PFNGLWINDOWPOS2FPROC WindowPosFunc;
|
||||
|
||||
static void draw( void )
|
||||
{
|
||||
@@ -71,19 +70,16 @@ static void reshape( int width, int height )
|
||||
|
||||
static void init( void )
|
||||
{
|
||||
#ifdef GL_ARB_window_pos
|
||||
if (glutExtensionSupported("GL_ARB_window_pos")) {
|
||||
if (GLEW_ARB_window_pos) {
|
||||
printf("Using GL_ARB_window_pos\n");
|
||||
WindowPosFunc = &glWindowPos2fARB;
|
||||
WindowPosFunc = glWindowPos2fARB;
|
||||
}
|
||||
else
|
||||
#elif defined(GL_MESA_window_pos)
|
||||
if (glutExtensionSupported("GL_MESA_window_pos")) {
|
||||
if (GLEW_MESA_window_pos) {
|
||||
printf("Using GL_MESA_window_pos\n");
|
||||
WindowPosFunc = &glWindowPos2fMESA;
|
||||
WindowPosFunc = glWindowPos2fMESA;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
printf("Sorry, GL_ARB/MESA_window_pos extension not available.\n");
|
||||
exit(1);
|
||||
@@ -109,6 +105,8 @@ int main( int argc, char *argv[] )
|
||||
exit(0);
|
||||
}
|
||||
|
||||
glewInit();
|
||||
|
||||
init();
|
||||
|
||||
glutReshapeFunc( reshape );
|
||||
|
@@ -5,10 +5,8 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glew.h>
|
||||
#include <GL/glut.h>
|
||||
#include <GL/glext.h>
|
||||
#include "extfuncs.h"
|
||||
|
||||
|
||||
static GLuint fragShader;
|
||||
@@ -56,9 +54,9 @@ Reshape(int width, int height)
|
||||
static void
|
||||
CleanUp(void)
|
||||
{
|
||||
glDeleteShader_func(fragShader);
|
||||
glDeleteShader_func(vertShader);
|
||||
glDeleteProgram_func(program);
|
||||
glDeleteShader(fragShader);
|
||||
glDeleteShader(vertShader);
|
||||
glDeleteProgram(program);
|
||||
glutDestroyWindow(win);
|
||||
}
|
||||
|
||||
@@ -110,15 +108,15 @@ LoadAndCompileShader(GLuint shader, const char *text)
|
||||
{
|
||||
GLint stat;
|
||||
|
||||
glShaderSource_func(shader, 1, (const GLchar **) &text, NULL);
|
||||
glShaderSource(shader, 1, (const GLchar **) &text, NULL);
|
||||
|
||||
glCompileShader_func(shader);
|
||||
glCompileShader(shader);
|
||||
|
||||
glGetShaderiv_func(shader, GL_COMPILE_STATUS, &stat);
|
||||
glGetShaderiv(shader, GL_COMPILE_STATUS, &stat);
|
||||
if (!stat) {
|
||||
GLchar log[1000];
|
||||
GLsizei len;
|
||||
glGetShaderInfoLog_func(shader, 1000, &len, log);
|
||||
glGetShaderInfoLog(shader, 1000, &len, log);
|
||||
fprintf(stderr, "fslight: problem compiling shader:\n%s\n", log);
|
||||
exit(1);
|
||||
}
|
||||
@@ -129,11 +127,11 @@ static void
|
||||
CheckLink(GLuint prog)
|
||||
{
|
||||
GLint stat;
|
||||
glGetProgramiv_func(prog, GL_LINK_STATUS, &stat);
|
||||
glGetProgramiv(prog, GL_LINK_STATUS, &stat);
|
||||
if (!stat) {
|
||||
GLchar log[1000];
|
||||
GLsizei len;
|
||||
glGetProgramInfoLog_func(prog, 1000, &len, log);
|
||||
glGetProgramInfoLog(prog, 1000, &len, log);
|
||||
fprintf(stderr, "Linker error:\n%s\n", log);
|
||||
}
|
||||
}
|
||||
@@ -165,24 +163,22 @@ Init(void)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
GetExtensionFuncs();
|
||||
|
||||
fragShader = glCreateShader_func(GL_FRAGMENT_SHADER);
|
||||
fragShader = glCreateShader(GL_FRAGMENT_SHADER);
|
||||
LoadAndCompileShader(fragShader, fragShaderText);
|
||||
|
||||
#if 0
|
||||
vertShader = glCreateShader_func(GL_VERTEX_SHADER);
|
||||
vertShader = glCreateShader(GL_VERTEX_SHADER);
|
||||
LoadAndCompileShader(vertShader, vertShaderText);
|
||||
#endif
|
||||
|
||||
program = glCreateProgram_func();
|
||||
glAttachShader_func(program, fragShader);
|
||||
program = glCreateProgram();
|
||||
glAttachShader(program, fragShader);
|
||||
#if 0
|
||||
glAttachShader_func(program, vertShader);
|
||||
glAttachShader(program, vertShader);
|
||||
#endif
|
||||
glLinkProgram_func(program);
|
||||
glLinkProgram(program);
|
||||
CheckLink(program);
|
||||
glUseProgram_func(program);
|
||||
glUseProgram(program);
|
||||
|
||||
assert(glGetError() == 0);
|
||||
|
||||
@@ -200,6 +196,7 @@ main(int argc, char *argv[])
|
||||
glutInitWindowSize(200, 200);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||
win = glutCreateWindow(argv[0]);
|
||||
glewInit();
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutSpecialFunc(SpecialKey);
|
||||
|
15
progs/util/SConscript
Normal file
15
progs/util/SConscript
Normal file
@@ -0,0 +1,15 @@
|
||||
Import('env')
|
||||
|
||||
env = env.Clone()
|
||||
|
||||
util = env.StaticLibrary(
|
||||
target = ['util'],
|
||||
source = [
|
||||
'readtex.c',
|
||||
'trackball.c',
|
||||
'showbuffer.c',
|
||||
'shaderutil.c',
|
||||
],
|
||||
)
|
||||
|
||||
Export('util')
|
@@ -303,7 +303,7 @@ def generate(env):
|
||||
#'_UNICODE',
|
||||
#'UNICODE',
|
||||
# http://msdn2.microsoft.com/en-us/library/6dwk3a1z.aspx,
|
||||
'WIN32_LEAN_AND_MEAN',
|
||||
#'WIN32_LEAN_AND_MEAN',
|
||||
'VC_EXTRALEAN',
|
||||
'_CRT_SECURE_NO_DEPRECATE',
|
||||
]
|
||||
@@ -362,24 +362,26 @@ def generate(env):
|
||||
])
|
||||
|
||||
# C compiler options
|
||||
cflags = []
|
||||
cflags = [] # C
|
||||
cxxflags = [] # C++
|
||||
ccflags = [] # C & C++
|
||||
if gcc:
|
||||
if debug:
|
||||
cflags += ['-O0', '-g3']
|
||||
ccflags += ['-O0', '-g3']
|
||||
else:
|
||||
cflags += ['-O3', '-g0']
|
||||
ccflags += ['-O3', '-g0']
|
||||
if env['profile']:
|
||||
cflags += ['-pg']
|
||||
ccflags += ['-pg']
|
||||
if env['machine'] == 'x86':
|
||||
cflags += [
|
||||
ccflags += [
|
||||
'-m32',
|
||||
#'-march=pentium4',
|
||||
'-mmmx', '-msse', '-msse2', # enable SIMD intrinsics
|
||||
#'-mfpmath=sse',
|
||||
]
|
||||
if env['machine'] == 'x86_64':
|
||||
cflags += ['-m64']
|
||||
cflags += [
|
||||
ccflags += ['-m64']
|
||||
ccflags += [
|
||||
'-Wall',
|
||||
'-Wmissing-prototypes',
|
||||
'-Wno-long-long',
|
||||
@@ -387,43 +389,46 @@ def generate(env):
|
||||
'-pedantic',
|
||||
'-fmessage-length=0', # be nice to Eclipse
|
||||
]
|
||||
cflags += [
|
||||
'-Wmissing-prototypes',
|
||||
]
|
||||
if msvc:
|
||||
# See also:
|
||||
# - http://msdn.microsoft.com/en-us/library/19z1t1wy.aspx
|
||||
# - cl /?
|
||||
if debug:
|
||||
cflags += [
|
||||
ccflags += [
|
||||
'/Od', # disable optimizations
|
||||
'/Oi', # enable intrinsic functions
|
||||
'/Oy-', # disable frame pointer omission
|
||||
]
|
||||
else:
|
||||
cflags += [
|
||||
ccflags += [
|
||||
'/Ox', # maximum optimizations
|
||||
'/Oi', # enable intrinsic functions
|
||||
'/Ot', # favor code speed
|
||||
#'/fp:fast', # fast floating point
|
||||
]
|
||||
if env['profile']:
|
||||
cflags += [
|
||||
ccflags += [
|
||||
'/Gh', # enable _penter hook function
|
||||
'/GH', # enable _pexit hook function
|
||||
]
|
||||
cflags += [
|
||||
ccflags += [
|
||||
'/W3', # warning level
|
||||
#'/Wp64', # enable 64 bit porting warnings
|
||||
]
|
||||
if env['machine'] == 'x86':
|
||||
cflags += [
|
||||
ccflags += [
|
||||
#'/QIfist', # Suppress _ftol
|
||||
#'/arch:SSE2', # use the SSE2 instructions
|
||||
]
|
||||
if platform == 'windows':
|
||||
cflags += [
|
||||
ccflags += [
|
||||
# TODO
|
||||
]
|
||||
if platform == 'winddk':
|
||||
cflags += [
|
||||
ccflags += [
|
||||
'/Zl', # omit default library name in .OBJ
|
||||
'/Zp8', # 8bytes struct member alignment
|
||||
'/Gy', # separate functions for linker
|
||||
@@ -442,7 +447,7 @@ def generate(env):
|
||||
]
|
||||
if platform == 'wince':
|
||||
# See also C:\WINCE600\public\common\oak\misc\makefile.def
|
||||
cflags += [
|
||||
ccflags += [
|
||||
'/Zl', # omit default library name in .OBJ
|
||||
'/GF', # enable read-only string pooling
|
||||
'/GR-', # disable C++ RTTI
|
||||
@@ -459,8 +464,9 @@ def generate(env):
|
||||
# See http://scons.tigris.org/issues/show_bug.cgi?id=1656
|
||||
env.EnsureSConsVersion(0, 98, 0)
|
||||
env['PDB'] = '${TARGET.base}.pdb'
|
||||
env.Append(CCFLAGS = ccflags)
|
||||
env.Append(CFLAGS = cflags)
|
||||
env.Append(CXXFLAGS = cflags)
|
||||
env.Append(CXXFLAGS = cxxflags)
|
||||
|
||||
if env['platform'] == 'windows' and msvc:
|
||||
# Choose the appropriate MSVC CRT
|
||||
|
Reference in New Issue
Block a user