Skip to content

Commit

Permalink
reverted to glfw2.7.2 (from glfw3) for easier use of AntTweakBar, whi…
Browse files Browse the repository at this point in the history
…ch was also added
  • Loading branch information
pixeljetstream committed Jan 21, 2012
1 parent 76c3b6a commit d4b99c8
Show file tree
Hide file tree
Showing 22 changed files with 1,375 additions and 972 deletions.
20 changes: 11 additions & 9 deletions backend/_project/main.cpp
Expand Up @@ -12,25 +12,27 @@ int main(int argc, const char** argv)
int status = 1;

glfwInit();
glfwOpenWindowHint(GLFW_DEPTH_BITS,24);
glfwOpenWindowHint(GLFW_STENCIL_BITS,8);
GLFWwindow win = glfwOpenWindow(1024,768,GLFW_WINDOWED,caption.c_str(),0);
glfwOpenWindow( 640, 480, 8,8,8,8,24,8, GLFW_WINDOW);
glfwSetWindowTitle(caption.c_str());
glewInit();

glfwDisable(GLFW_AUTO_POLL_EVENTS);
glfwSwapInterval(1);

if (test){
status = test->onInit(win,argc,argv);
status = test->onInit(argc,argv);
}
if (status){
return 0;
}


ProjectManager::Get().initTimer();
while( glfwIsWindow(win) && glfwGetKey(win,GLFW_KEY_ESCAPE) != GLFW_PRESS)
while( glfwGetWindowParam(GLFW_OPENED) && glfwGetKey(GLFW_KEY_ESC) != GLFW_PRESS)
{
int width;
int height;
glfwGetWindowSize(win, &width, &height);
glfwGetWindowSize(&width, &height);
glViewport(0,0,width,height);

status = test->onDraw(width, height);
Expand All @@ -45,14 +47,14 @@ int main(int argc, const char** argv)
char buffer[128];
double dur = ProjectManager::Get().getLastTime();
sprintf_s(buffer,128," %.1f ms %5d fps", dur * 1000.0, (int)floor(1.0/dur));
glfwSetWindowTitle(win, (caption + std::string(buffer)).c_str());
glfwSetWindowTitle((caption + std::string(buffer)).c_str());
}
}
}

if (glfwIsWindow(win)){
if (glfwGetWindowParam(GLFW_OPENED)){
test->onDeinit();
glfwCloseWindow(win);
glfwCloseWindow();
}

return 0;
Expand Down
7 changes: 3 additions & 4 deletions backend/_project/project.cpp
Expand Up @@ -47,9 +47,8 @@ std::string ReadFileContent(const char* filename)

//////////////////////////////////////////////////////////////////////////

void RenderHelper::init(GLFWwindow win, const lxCVector3& up)
void RenderHelper::init(const lxCVector3& up)
{
m_window = win;
m_up = up;

glDepthFunc(GL_LEQUAL);
Expand Down Expand Up @@ -157,7 +156,7 @@ void RenderHelper::doCameraControl()
{
// Mouse Updates
for (int i = 0; i < 3; i++){
int button = glfwGetMouseButton(m_window,i);
int button = glfwGetMouseButton(i);
m_buttonsToggle[i] = button != m_buttons[i];
m_buttons[i] = button;
}
Expand Down Expand Up @@ -254,7 +253,7 @@ void RenderHelper::update( int width, int height )
m_winheight = height;

int mx, my;
glfwGetMousePos(m_window,&mx,&my);
glfwGetMousePos(&mx,&my);
m_mpos.Set(float(mx),float(my),0);
}

Expand Down
13 changes: 6 additions & 7 deletions backend/_project/project.hpp
Expand Up @@ -6,7 +6,8 @@
#define __LUXTEST_PROJECT_H__

#include <GL/glew.h>
#include <GL/glfw3.h>
#define GLFW_DLL
#include <GL/glfw.h>

#include <luxinia/luxmath/luxmath.h>
#include <luxinia/luxmath/basetypes.hpp>
Expand Down Expand Up @@ -43,10 +44,10 @@ class KeyTracker
KeyTracker() {
memset(m_states,0,sizeof(m_states));
}
void update(GLFWwindow win){
void update(){
for (size_t i = 0; i < m_tracked.size(); i++){
int key = m_tracked[i];
int state = glfwGetKey(win,key);
int state = glfwGetKey(key);
m_states[key].toggled = m_states[key].last != state;
m_states[key].last = state;
}
Expand Down Expand Up @@ -242,7 +243,7 @@ class RenderHelper {
static void generateUVData( int w, int h, lxCVector3 *pixels);
static GLuint loadShader(GLenum type, const char* filename, const char* prepend );

void init(GLFWwindow win, const lxCVector3& up);
void init(const lxCVector3& up);
void update(int width, int height);

void cameraOrtho(lxBoundingBox_t* bbox, const lxCVector3* delta=NULL);
Expand Down Expand Up @@ -285,8 +286,6 @@ class RenderHelper {

private:

GLFWwindow m_window;

lxCVector3 m_orbitCenter;
lxCVector3 m_sceneCenter;
lxCVector3 m_sceneSize;
Expand Down Expand Up @@ -357,7 +356,7 @@ class Project
return m_dirname;
}
virtual int onDraw(int width, int height) { return 0; }
virtual int onInit(GLFWwindow window, int argc, const char** argv) { return 0; }
virtual int onInit(int argc, const char** argv) { return 0; }
virtual void onDeinit() {}

private:
Expand Down
62 changes: 31 additions & 31 deletions backend/luxmath/fastmathxmm.cpp
Expand Up @@ -89,18 +89,18 @@ _PI32_CONST(2, 2);
_PI32_CONST(4, 4);
_PI32_CONST(0x7f, 0x7f);

_PS_CONST(cephes_SQRTHF, 0.707106781186547524);
_PS_CONST(cephes_log_p0, 7.0376836292E-2);
_PS_CONST(cephes_log_p1, - 1.1514610310E-1);
_PS_CONST(cephes_log_p2, 1.1676998740E-1);
_PS_CONST(cephes_log_p3, - 1.2420140846E-1);
_PS_CONST(cephes_log_p4, + 1.4249322787E-1);
_PS_CONST(cephes_log_p5, - 1.6668057665E-1);
_PS_CONST(cephes_log_p6, + 2.0000714765E-1);
_PS_CONST(cephes_log_p7, - 2.4999993993E-1);
_PS_CONST(cephes_log_p8, + 3.3333331174E-1);
_PS_CONST(cephes_log_q1, -2.12194440e-4);
_PS_CONST(cephes_log_q2, 0.693359375);
_PS_CONST(cephes_SQRTHF, 0.707106781186547524f);
_PS_CONST(cephes_log_p0, 7.0376836292E-2f);
_PS_CONST(cephes_log_p1, - 1.1514610310E-1f);
_PS_CONST(cephes_log_p2, 1.1676998740E-1f);
_PS_CONST(cephes_log_p3, - 1.2420140846E-1f);
_PS_CONST(cephes_log_p4, + 1.4249322787E-1f);
_PS_CONST(cephes_log_p5, - 1.6668057665E-1f);
_PS_CONST(cephes_log_p6, + 2.0000714765E-1f);
_PS_CONST(cephes_log_p7, - 2.4999993993E-1f);
_PS_CONST(cephes_log_p8, + 3.3333331174E-1f);
_PS_CONST(cephes_log_q1, -2.12194440e-4f);
_PS_CONST(cephes_log_q2, 0.693359375f);

#if defined (__MINGW32__)

Expand Down Expand Up @@ -263,16 +263,16 @@ LUX_API v4sf lxFastLog_ps(v4sf x) {
_PS_CONST(exp_hi, 88.3762626647949f);
_PS_CONST(exp_lo, -88.3762626647949f);

_PS_CONST(cephes_LOG2EF, 1.44269504088896341);
_PS_CONST(cephes_exp_C1, 0.693359375);
_PS_CONST(cephes_exp_C2, -2.12194440e-4);
_PS_CONST(cephes_LOG2EF, 1.44269504088896341f);
_PS_CONST(cephes_exp_C1, 0.693359375f);
_PS_CONST(cephes_exp_C2, -2.12194440e-4f);

_PS_CONST(cephes_exp_p0, 1.9875691500E-4);
_PS_CONST(cephes_exp_p1, 1.3981999507E-3);
_PS_CONST(cephes_exp_p2, 8.3334519073E-3);
_PS_CONST(cephes_exp_p3, 4.1665795894E-2);
_PS_CONST(cephes_exp_p4, 1.6666665459E-1);
_PS_CONST(cephes_exp_p5, 5.0000001201E-1);
_PS_CONST(cephes_exp_p0, 1.9875691500E-4f);
_PS_CONST(cephes_exp_p1, 1.3981999507E-3f);
_PS_CONST(cephes_exp_p2, 8.3334519073E-3f);
_PS_CONST(cephes_exp_p3, 4.1665795894E-2f);
_PS_CONST(cephes_exp_p4, 1.6666665459E-1f);
_PS_CONST(cephes_exp_p5, 5.0000001201E-1f);

LUX_API v4sf lxFastExp_ps(v4sf x) {
v4sf tmp = _mm_setzero_ps(), fx;
Expand Down Expand Up @@ -352,16 +352,16 @@ LUX_API v4sf lxFastExp_ps(v4sf x) {
return y;
}

_PS_CONST(minus_cephes_DP1, -0.78515625);
_PS_CONST(minus_cephes_DP2, -2.4187564849853515625e-4);
_PS_CONST(minus_cephes_DP3, -3.77489497744594108e-8);
_PS_CONST(sincof_p0, -1.9515295891E-4);
_PS_CONST(sincof_p1, 8.3321608736E-3);
_PS_CONST(sincof_p2, -1.6666654611E-1);
_PS_CONST(coscof_p0, 2.443315711809948E-005);
_PS_CONST(coscof_p1, -1.388731625493765E-003);
_PS_CONST(coscof_p2, 4.166664568298827E-002);
_PS_CONST(cephes_FOPI, 1.27323954473516); // 4 / M_PI
_PS_CONST(minus_cephes_DP1, -0.78515625f);
_PS_CONST(minus_cephes_DP2, -2.4187564849853515625e-4f);
_PS_CONST(minus_cephes_DP3, -3.77489497744594108e-8f);
_PS_CONST(sincof_p0, -1.9515295891E-4f);
_PS_CONST(sincof_p1, 8.3321608736E-3f);
_PS_CONST(sincof_p2, -1.6666654611E-1f);
_PS_CONST(coscof_p0, 2.443315711809948E-005f);
_PS_CONST(coscof_p1, -1.388731625493765E-003f);
_PS_CONST(coscof_p2, 4.166664568298827E-002f);
_PS_CONST(cephes_FOPI, 1.27323954473516f); // 4 / M_PI


/* evaluation of 4 sines at onces, using only SSE1+MMX intrinsics so
Expand Down
8 changes: 3 additions & 5 deletions backend/test/gfxprogram.cpp
Expand Up @@ -80,7 +80,6 @@ class GfxProgram : public Project
GeometryBox m_box;

KeyTracker m_keys;
GLFWwindow m_window;

lxgContext_t m_ctx;
RenderProgram m_prog;
Expand All @@ -100,16 +99,15 @@ class GfxProgram : public Project



int onInit(GLFWwindow win, int argc, const char** argv) {
m_window = win;
int onInit(int argc, const char** argv) {

updateGeometry(4,4,4);

lxBoundingBox_t bbox;
lxVector3Set(bbox.min,-2,-2,-2);
lxVector3Set(bbox.max, 2, 2, 2);
lxCVector3 up(0,1,0);
m_rh.init(win,up);
m_rh.init(up);
m_rh.cameraPerspective(&bbox, 30.0f);
m_rh.cameraOrtho(&bbox);

Expand Down Expand Up @@ -142,7 +140,7 @@ class GfxProgram : public Project

void logic(int width, int height)
{
m_keys.update(m_window);
m_keys.update();

}

Expand Down
8 changes: 3 additions & 5 deletions backend/test/gfxtexture.cpp
Expand Up @@ -13,7 +13,6 @@ class GfxTexture : public Project
GeometryBox m_box;

KeyTracker m_keys;
GLFWwindow m_window;

lxgContext_t m_ctx;
lxgTexture_t m_tex;
Expand All @@ -33,16 +32,15 @@ class GfxTexture : public Project
m_box.update(x,y,z);
}

int onInit(GLFWwindow win, int argc, const char** argv) {
m_window = win;
int onInit(int argc, const char** argv) {

updateGeometry(4,4,4);

lxBoundingBox_t bbox;
lxVector3Set(bbox.min,-1,-1,-1);
lxVector3Set(bbox.max, 1, 1, 1);
lxCVector3 up(0,1,0);
m_rh.init(win,up);
m_rh.init(up);
m_rh.cameraPerspective(&bbox, 30.0f);
m_rh.cameraOrtho(&bbox);

Expand Down Expand Up @@ -74,7 +72,7 @@ class GfxTexture : public Project

void logic(int width, int height)
{
m_keys.update(m_window);
m_keys.update();
if (m_keys.onPress(GLFW_KEY_SPACE)){
m_sampler = m_sampler == &m_samplerNearest ? &m_samplerTriLinear : &m_samplerNearest;
}
Expand Down
8 changes: 3 additions & 5 deletions backend/test/gfxvertex.cpp
Expand Up @@ -13,7 +13,6 @@ class GfxVertex : public Project
GeometryBox m_box;

KeyTracker m_keys;
GLFWwindow m_window;
GLuint m_texture;

lxgContext_t m_ctx;
Expand All @@ -35,16 +34,15 @@ class GfxVertex : public Project
m_box.update(x,y,z);
}

int onInit(GLFWwindow win, int argc, const char** argv) {
m_window = win;
int onInit(int argc, const char** argv) {

// scene
updateGeometry(4,4,4);
lxBoundingBox_t bbox;
lxVector3Set(bbox.min,-1,-1,-1);
lxVector3Set(bbox.max, 1, 1, 1);
lxCVector3 up(0,1,0);
m_rh.init(win,up);
m_rh.init(up);
m_rh.cameraPerspective(&bbox, 30.0f);
m_rh.cameraOrtho(&bbox);

Expand Down Expand Up @@ -105,7 +103,7 @@ class GfxVertex : public Project

void logic(int width, int height)
{
m_keys.update(m_window);
m_keys.update();

}

Expand Down
9 changes: 3 additions & 6 deletions backend/test/mesh.cpp
Expand Up @@ -20,7 +20,6 @@ class MeshTest : public Project
int m_numGeometries;

KeyTracker m_keys;
GLFWwindow m_window;
GLuint m_texture;

public:
Expand Down Expand Up @@ -48,16 +47,14 @@ class MeshTest : public Project
m_sphere.update(x,y);
}

int onInit(GLFWwindow win, int argc, const char** argv) {
m_window = win;

int onInit(int argc, const char** argv) {
updateGeometry(4,2,1);

lxBoundingBox_t bbox;
lxVector3Set(bbox.min,-1,-1,-1);
lxVector3Set(bbox.max, 1, 1, 1);
lxCVector3 up(0,1,0);
m_rh.init(win,up);
m_rh.init(up);
m_rh.cameraPerspective(&bbox, 30.0f);
m_rh.cameraOrtho(&bbox);

Expand All @@ -68,7 +65,7 @@ class MeshTest : public Project

void logic(int width, int height)
{
m_keys.update(m_window);
m_keys.update();
if (m_keys.onPress(GLFW_KEY_SPACE)){
m_model++;
if (m_model >= m_numGeometries*2){
Expand Down

0 comments on commit d4b99c8

Please sign in to comment.