mirror of
https://github.com/glfw/glfw.git
synced 2025-02-12 11:47:43 +00:00
Merge branch 'master' of ssh://glfw.git.sourceforge.net/gitroot/glfw/glfw
This commit is contained in:
commit
37d366dc9f
@ -8,8 +8,7 @@ set(GLFW_VERSION_MINOR "0")
|
|||||||
set(GLFW_VERSION_PATCH "0")
|
set(GLFW_VERSION_PATCH "0")
|
||||||
set(GLFW_VERSION_EXTRA "")
|
set(GLFW_VERSION_EXTRA "")
|
||||||
set(GLFW_VERSION "${GLFW_VERSION_MAJOR}.${GLFW_VERSION_MINOR}")
|
set(GLFW_VERSION "${GLFW_VERSION_MAJOR}.${GLFW_VERSION_MINOR}")
|
||||||
set(GLFW_VERSION_FULL
|
set(GLFW_VERSION_FULL "${GLFW_VERSION}.${GLFW_VERSION_PATCH}${GLFW_VERSION_EXTRA}")
|
||||||
"${GLFW_VERSION}.${GLFW_VERSION_PATCH}${GLFW_VERSION_EXTRA}")
|
|
||||||
|
|
||||||
include(CheckFunctionExists)
|
include(CheckFunctionExists)
|
||||||
include(CheckSymbolExists)
|
include(CheckSymbolExists)
|
||||||
@ -159,8 +158,7 @@ install(FILES COPYING.txt readme.html
|
|||||||
# Uninstall operation
|
# Uninstall operation
|
||||||
#--------------------------------------------------------------------
|
#--------------------------------------------------------------------
|
||||||
configure_file(${GLFW_SOURCE_DIR}/cmake_uninstall.cmake.in
|
configure_file(${GLFW_SOURCE_DIR}/cmake_uninstall.cmake.in
|
||||||
${GLFW_BINARY_DIR}/cmake_uninstall.cmake
|
${GLFW_BINARY_DIR}/cmake_uninstall.cmake IMMEDIATE @ONLY)
|
||||||
IMMEDIATE @ONLY)
|
|
||||||
|
|
||||||
add_custom_target(uninstall
|
add_custom_target(uninstall
|
||||||
${CMAKE_COMMAND} -P
|
${CMAKE_COMMAND} -P
|
||||||
|
@ -1,122 +0,0 @@
|
|||||||
//========================================================================
|
|
||||||
// This is an example program for the GLFW library
|
|
||||||
//
|
|
||||||
// It shows texture loading with mipmap generation and rendering with
|
|
||||||
// trilienar texture filtering
|
|
||||||
//========================================================================
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#include <GL/glfw.h>
|
|
||||||
|
|
||||||
int main( void )
|
|
||||||
{
|
|
||||||
int width, height, x;
|
|
||||||
double time;
|
|
||||||
GLboolean running;
|
|
||||||
GLuint textureID;
|
|
||||||
char* texturePath = "mipmaps.tga";
|
|
||||||
|
|
||||||
// Initialise GLFW
|
|
||||||
if( !glfwInit() )
|
|
||||||
{
|
|
||||||
fprintf( stderr, "Failed to initialize GLFW\n" );
|
|
||||||
exit( EXIT_FAILURE );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Open OpenGL window
|
|
||||||
if( !glfwOpenWindow( 640, 480, 0,0,0,0, 0,0, GLFW_WINDOW ) )
|
|
||||||
{
|
|
||||||
fprintf( stderr, "Failed to open GLFW window\n" );
|
|
||||||
glfwTerminate();
|
|
||||||
exit( EXIT_FAILURE );
|
|
||||||
}
|
|
||||||
|
|
||||||
glfwSetWindowTitle( "Trilinear interpolation" );
|
|
||||||
|
|
||||||
// Enable sticky keys
|
|
||||||
glfwEnable( GLFW_STICKY_KEYS );
|
|
||||||
|
|
||||||
// Enable vertical sync (on cards that support it)
|
|
||||||
glfwSwapInterval( 1 );
|
|
||||||
|
|
||||||
// Generate and bind our texture ID
|
|
||||||
glGenTextures( 1, &textureID );
|
|
||||||
glBindTexture( GL_TEXTURE_2D, textureID );
|
|
||||||
|
|
||||||
// Load texture from file into video memory, including mipmap levels
|
|
||||||
if( !glfwLoadTexture2D( texturePath, GLFW_BUILD_MIPMAPS_BIT ) )
|
|
||||||
{
|
|
||||||
fprintf( stderr, "Failed to load texture %s\n", texturePath );
|
|
||||||
glfwTerminate();
|
|
||||||
exit( EXIT_FAILURE );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Use trilinear interpolation (GL_LINEAR_MIPMAP_LINEAR)
|
|
||||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
|
|
||||||
GL_LINEAR_MIPMAP_LINEAR );
|
|
||||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
|
|
||||||
GL_LINEAR );
|
|
||||||
|
|
||||||
// Enable plain 2D texturing
|
|
||||||
glEnable( GL_TEXTURE_2D );
|
|
||||||
|
|
||||||
running = GL_TRUE;
|
|
||||||
while( running )
|
|
||||||
{
|
|
||||||
// Get time and mouse position
|
|
||||||
time = glfwGetTime();
|
|
||||||
glfwGetMousePos( &x, NULL );
|
|
||||||
|
|
||||||
// Get window size (may be different than the requested size)
|
|
||||||
glfwGetWindowSize( &width, &height );
|
|
||||||
height = height > 0 ? height : 1;
|
|
||||||
|
|
||||||
// Set viewport
|
|
||||||
glViewport( 0, 0, width, height );
|
|
||||||
|
|
||||||
// Clear color buffer
|
|
||||||
glClearColor( 0.0f, 0.0f, 0.0f, 0.0f);
|
|
||||||
glClear( GL_COLOR_BUFFER_BIT );
|
|
||||||
|
|
||||||
// Select and setup the projection matrix
|
|
||||||
glMatrixMode( GL_PROJECTION );
|
|
||||||
glLoadIdentity();
|
|
||||||
gluPerspective( 65.0f, (GLfloat)width / (GLfloat)height, 1.0f,
|
|
||||||
50.0f );
|
|
||||||
|
|
||||||
// Select and setup the modelview matrix
|
|
||||||
glMatrixMode( GL_MODELVIEW );
|
|
||||||
glLoadIdentity();
|
|
||||||
gluLookAt( 0.0f, 3.0f, -20.0f, // Eye-position
|
|
||||||
0.0f, -4.0f, -11.0f, // View-point
|
|
||||||
0.0f, 1.0f, 0.0f ); // Up-vector
|
|
||||||
|
|
||||||
// Draw a textured quad
|
|
||||||
glRotatef( 0.05f * (GLfloat)x + (GLfloat)time * 5.0f, 0.0f, 1.0f, 0.0f );
|
|
||||||
glBegin( GL_QUADS );
|
|
||||||
glTexCoord2f( -20.0f, 20.0f );
|
|
||||||
glVertex3f( -50.0f, 0.0f, -50.0f );
|
|
||||||
glTexCoord2f( 20.0f, 20.0f );
|
|
||||||
glVertex3f( 50.0f, 0.0f, -50.0f );
|
|
||||||
glTexCoord2f( 20.0f, -20.0f );
|
|
||||||
glVertex3f( 50.0f, 0.0f, 50.0f );
|
|
||||||
glTexCoord2f( -20.0f, -20.0f );
|
|
||||||
glVertex3f( -50.0f, 0.0f, 50.0f );
|
|
||||||
glEnd();
|
|
||||||
|
|
||||||
// Swap buffers
|
|
||||||
glfwSwapBuffers();
|
|
||||||
|
|
||||||
// Check if the ESC key was pressed or the window was closed
|
|
||||||
running = !glfwGetKey( GLFW_KEY_ESC ) &&
|
|
||||||
glfwGetWindowParam( GLFW_OPENED );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Close OpenGL window and terminate GLFW
|
|
||||||
glfwTerminate();
|
|
||||||
|
|
||||||
exit( EXIT_SUCCESS );
|
|
||||||
}
|
|
||||||
|
|
Binary file not shown.
@ -92,6 +92,7 @@ static void drawTorus( void )
|
|||||||
glVertex3f((float) x, (float) y, (float) z);
|
glVertex3f((float) x, (float) y, (float) z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
glEnd();
|
glEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -210,13 +211,9 @@ static void drawAllViews( void )
|
|||||||
|
|
||||||
// Calculate aspect of window
|
// Calculate aspect of window
|
||||||
if (height > 0)
|
if (height > 0)
|
||||||
{
|
|
||||||
aspect = (double) width / (double) height;
|
aspect = (double) width / (double) height;
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
aspect = 1.0;
|
aspect = 1.0;
|
||||||
}
|
|
||||||
|
|
||||||
// Clear screen
|
// Clear screen
|
||||||
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
@ -229,7 +226,6 @@ static void drawAllViews( void )
|
|||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
glDepthFunc(GL_LEQUAL);
|
glDepthFunc(GL_LEQUAL);
|
||||||
|
|
||||||
|
|
||||||
// ** ORTHOGONAL VIEWS **
|
// ** ORTHOGONAL VIEWS **
|
||||||
|
|
||||||
// For orthogonal views, use wireframe rendering
|
// For orthogonal views, use wireframe rendering
|
||||||
@ -282,7 +278,6 @@ static void drawAllViews( void )
|
|||||||
glDisable(GL_LINE_SMOOTH);
|
glDisable(GL_LINE_SMOOTH);
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
|
|
||||||
|
|
||||||
// ** PERSPECTIVE VIEW **
|
// ** PERSPECTIVE VIEW **
|
||||||
|
|
||||||
// For perspective view, use solid rendering
|
// For perspective view, use solid rendering
|
||||||
@ -330,18 +325,21 @@ static void drawAllViews( void )
|
|||||||
// Disable scissor test
|
// Disable scissor test
|
||||||
glDisable(GL_SCISSOR_TEST);
|
glDisable(GL_SCISSOR_TEST);
|
||||||
|
|
||||||
|
|
||||||
// Draw a border around the active view
|
// Draw a border around the active view
|
||||||
if (active_view > 0 && active_view != 2)
|
if (active_view > 0 && active_view != 2)
|
||||||
{
|
{
|
||||||
glViewport(0, 0, width, height);
|
glViewport(0, 0, width, height);
|
||||||
|
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
glOrtho(0.0, 2.0, 0.0, 2.0, 0.0, 1.0);
|
glOrtho(0.0, 2.0, 0.0, 2.0, 0.0, 1.0);
|
||||||
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
glColor3f( 1.0f, 1.0f, 0.6f );
|
|
||||||
glTranslatef((GLfloat) ((active_view - 1) & 1), (GLfloat) (1 - (active_view - 1) / 2), 0.0f);
|
glTranslatef((GLfloat) ((active_view - 1) & 1), (GLfloat) (1 - (active_view - 1) / 2), 0.0f);
|
||||||
|
|
||||||
|
glColor3f(1.0f, 1.0f, 0.6f);
|
||||||
|
|
||||||
glBegin(GL_LINE_STRIP);
|
glBegin(GL_LINE_STRIP);
|
||||||
glVertex2i(0, 0);
|
glVertex2i(0, 0);
|
||||||
glVertex2i(1, 0);
|
glVertex2i(1, 0);
|
||||||
@ -416,22 +414,15 @@ static void mousePosFun( GLFWwindow window, int x, int y )
|
|||||||
|
|
||||||
static void mouseButtonFun(GLFWwindow window, int button, int action)
|
static void mouseButtonFun(GLFWwindow window, int button, int action)
|
||||||
{
|
{
|
||||||
// Button clicked?
|
|
||||||
if ((button == GLFW_MOUSE_BUTTON_LEFT) && action == GLFW_PRESS)
|
if ((button == GLFW_MOUSE_BUTTON_LEFT) && action == GLFW_PRESS)
|
||||||
{
|
{
|
||||||
// Detect which of the four views was clicked
|
// Detect which of the four views was clicked
|
||||||
active_view = 1;
|
active_view = 1;
|
||||||
if (xpos >= width / 2)
|
if (xpos >= width / 2)
|
||||||
{
|
|
||||||
active_view += 1;
|
active_view += 1;
|
||||||
}
|
|
||||||
if (ypos >= height / 2)
|
if (ypos >= height / 2)
|
||||||
{
|
|
||||||
active_view += 2;
|
active_view += 2;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Button released?
|
|
||||||
else if (button == GLFW_MOUSE_BUTTON_LEFT)
|
else if (button == GLFW_MOUSE_BUTTON_LEFT)
|
||||||
{
|
{
|
||||||
// Deselect any previously selected view
|
// Deselect any previously selected view
|
||||||
@ -443,7 +434,7 @@ static void mouseButtonFun( GLFWwindow window, int button, int action )
|
|||||||
|
|
||||||
|
|
||||||
//========================================================================
|
//========================================================================
|
||||||
// main()
|
// main
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
@ -464,7 +455,6 @@ int main( void )
|
|||||||
if (!window)
|
if (!window)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Failed to open GLFW window\n");
|
fprintf(stderr, "Failed to open GLFW window\n");
|
||||||
glfwTerminate();
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,13 +6,12 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <GL/glfw3.h>
|
|
||||||
|
|
||||||
|
#include <GL/glfw3.h>
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
int width, height, x;
|
int width, height, x;
|
||||||
double t;
|
|
||||||
GLFWwindow window;
|
GLFWwindow window;
|
||||||
|
|
||||||
// Initialise GLFW
|
// Initialise GLFW
|
||||||
@ -27,8 +26,6 @@ int main( void )
|
|||||||
if (!window)
|
if (!window)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Failed to open GLFW window\n");
|
fprintf(stderr, "Failed to open GLFW window\n");
|
||||||
|
|
||||||
glfwTerminate();
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,7 +37,7 @@ int main( void )
|
|||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
t = glfwGetTime();
|
double t = glfwGetTime();
|
||||||
glfwGetMousePos(window, &x, NULL);
|
glfwGetMousePos(window, &x, NULL);
|
||||||
|
|
||||||
// Get window size (may be different than the requested size)
|
// Get window size (may be different than the requested size)
|
||||||
@ -52,31 +49,32 @@ int main( void )
|
|||||||
glViewport(0, 0, width, height);
|
glViewport(0, 0, width, height);
|
||||||
|
|
||||||
// Clear color buffer to black
|
// Clear color buffer to black
|
||||||
glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
|
glClearColor(0.f, 0.f, 0.f, 0.f);
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
// Select and setup the projection matrix
|
// Select and setup the projection matrix
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
gluPerspective( 65.0f, (GLfloat)width/(GLfloat)height, 1.0f, 100.0f );
|
gluPerspective(65.f, (GLfloat) width / (GLfloat) height, 1.f, 100.f);
|
||||||
|
|
||||||
// Select and setup the modelview matrix
|
// Select and setup the modelview matrix
|
||||||
glMatrixMode( GL_MODELVIEW );
|
glMatrixMode( GL_MODELVIEW );
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
gluLookAt( 0.0f, 1.0f, 0.0f, // Eye-position
|
gluLookAt(0.f, 1.f, 0.f, // Eye-position
|
||||||
0.0f, 20.0f, 0.0f, // View-point
|
0.f, 20.f, 0.f, // View-point
|
||||||
0.0f, 0.0f, 1.0f ); // Up-vector
|
0.f, 0.f, 1.f); // Up-vector
|
||||||
|
|
||||||
// Draw a rotating colorful triangle
|
// Draw a rotating colorful triangle
|
||||||
glTranslatef( 0.0f, 14.0f, 0.0f );
|
glTranslatef(0.f, 14.f, 0.f);
|
||||||
glRotatef( 0.3f*(GLfloat)x + (GLfloat)t*100.0f, 0.0f, 0.0f, 1.0f );
|
glRotatef(0.3f * (GLfloat) x + (GLfloat) t * 100.f, 0.f, 0.f, 1.f);
|
||||||
|
|
||||||
glBegin(GL_TRIANGLES);
|
glBegin(GL_TRIANGLES);
|
||||||
glColor3f( 1.0f, 0.0f, 0.0f );
|
glColor3f(1.f, 0.f, 0.f);
|
||||||
glVertex3f( -5.0f, 0.0f, -4.0f );
|
glVertex3f(-5.f, 0.f, -4.f);
|
||||||
glColor3f( 0.0f, 1.0f, 0.0f );
|
glColor3f(0.f, 1.f, 0.f);
|
||||||
glVertex3f( 5.0f, 0.0f, -4.0f );
|
glVertex3f(5.f, 0.f, -4.f);
|
||||||
glColor3f( 0.0f, 0.0f, 1.0f );
|
glColor3f(0.f, 0.f, 1.f);
|
||||||
glVertex3f( 0.0f, 0.0f, 6.0f );
|
glVertex3f(0.f, 0.f, 6.f);
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
// Swap buffers
|
// Swap buffers
|
||||||
|
232
examples/wave.c
232
examples/wave.c
@ -5,6 +5,7 @@
|
|||||||
* Modified for GLFW by Sylvain Hellegouarch - sh@programmationworld.com
|
* Modified for GLFW by Sylvain Hellegouarch - sh@programmationworld.com
|
||||||
* Modified for variable frame rate by Marcus Geelnard
|
* Modified for variable frame rate by Marcus Geelnard
|
||||||
* 2003-Jan-31: Minor cleanups and speedups / MG
|
* 2003-Jan-31: Minor cleanups and speedups / MG
|
||||||
|
* 2010-10-24: Formatting and cleanup - Camilla Berglund
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -16,17 +17,16 @@
|
|||||||
#define M_PI 3.1415926535897932384626433832795
|
#define M_PI 3.1415926535897932384626433832795
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Maximum delta T to allow for differential calculations */
|
// Maximum delta T to allow for differential calculations
|
||||||
#define MAX_DELTA_T 0.01
|
#define MAX_DELTA_T 0.01
|
||||||
|
|
||||||
/* Animation speed (10.0 looks good) */
|
// Animation speed (10.0 looks good)
|
||||||
#define ANIMATION_SPEED 10.0
|
#define ANIMATION_SPEED 10.0
|
||||||
|
|
||||||
|
GLfloat alpha = 210.f, beta = -70.f;
|
||||||
|
GLfloat zoom = 2.f;
|
||||||
|
|
||||||
GLfloat alpha = 210.0f, beta = -70.0f;
|
GLboolean running = GL_TRUE;
|
||||||
GLfloat zoom = 2.0f;
|
|
||||||
|
|
||||||
int running = 1;
|
|
||||||
|
|
||||||
struct Vertex
|
struct Vertex
|
||||||
{
|
{
|
||||||
@ -56,47 +56,46 @@ struct Vertex vertex[VERTEXNUM];
|
|||||||
* 0 1 2
|
* 0 1 2
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void initVertices( void )
|
//========================================================================
|
||||||
|
// Initialize grid geometry
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
|
void init_vertices(void)
|
||||||
{
|
{
|
||||||
int x, y, p;
|
int x, y, p;
|
||||||
|
|
||||||
/* place the vertices in a grid */
|
// Place the vertices in a grid
|
||||||
for (y = 0; y < GRIDH; y++)
|
for (y = 0; y < GRIDH; y++)
|
||||||
|
{
|
||||||
for (x = 0; x < GRIDW; x++)
|
for (x = 0; x < GRIDW; x++)
|
||||||
{
|
{
|
||||||
p = y * GRIDW + x;
|
p = y * GRIDW + x;
|
||||||
|
|
||||||
//vertex[p].x = (-GRIDW/2)+x+sin(2.0*M_PI*(double)y/(double)GRIDH);
|
|
||||||
//vertex[p].y = (-GRIDH/2)+y+cos(2.0*M_PI*(double)x/(double)GRIDW);
|
|
||||||
vertex[p].x = (GLfloat) (x - GRIDW / 2) / (GLfloat) (GRIDW / 2);
|
vertex[p].x = (GLfloat) (x - GRIDW / 2) / (GLfloat) (GRIDW / 2);
|
||||||
vertex[p].y = (GLfloat) (y - GRIDH / 2) / (GLfloat) (GRIDH / 2);
|
vertex[p].y = (GLfloat) (y - GRIDH / 2) / (GLfloat) (GRIDH / 2);
|
||||||
vertex[p].z = 0;//sin(d*M_PI);
|
vertex[p].z = 0;
|
||||||
//vertex[p].r = (GLfloat)x/(GLfloat)GRIDW;
|
|
||||||
//vertex[p].g = (GLfloat)y/(GLfloat)GRIDH;
|
|
||||||
//vertex[p].b = 1.0-((GLfloat)x/(GLfloat)GRIDW+(GLfloat)y/(GLfloat)GRIDH)/2.0;
|
|
||||||
if ((x % 4 < 2) ^ (y % 4 < 2))
|
if ((x % 4 < 2) ^ (y % 4 < 2))
|
||||||
{
|
|
||||||
vertex[p].r = 0.0;
|
vertex[p].r = 0.0;
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
vertex[p].r = 1.0;
|
vertex[p].r = 1.0;
|
||||||
}
|
|
||||||
|
|
||||||
vertex[p].g = (GLfloat) y / (GLfloat) GRIDH;
|
vertex[p].g = (GLfloat) y / (GLfloat) GRIDH;
|
||||||
vertex[p].b = 1.f - ((GLfloat) x / (GLfloat) GRIDW + (GLfloat) y / (GLfloat) GRIDH) / 2.f;
|
vertex[p].b = 1.f - ((GLfloat) x / (GLfloat) GRIDW + (GLfloat) y / (GLfloat) GRIDH) / 2.f;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (y = 0; y < QUADH; y++)
|
for (y = 0; y < QUADH; y++)
|
||||||
|
{
|
||||||
for (x = 0; x < QUADW; x++)
|
for (x = 0; x < QUADW; x++)
|
||||||
{
|
{
|
||||||
p = 4 * (y * QUADW + x);
|
p = 4 * (y * QUADW + x);
|
||||||
|
|
||||||
/* first quad */
|
quad[p + 0] = y * GRIDW + x; // Some point
|
||||||
quad[p+0] = y *GRIDW+x; /* some point */
|
quad[p + 1] = y * GRIDW + x + 1; // Neighbor at the right side
|
||||||
quad[p+1] = y *GRIDW+x+1; /* neighbor at the right side */
|
quad[p + 2] = (y + 1) * GRIDW + x + 1; // Upper right neighbor
|
||||||
quad[p+2] = (y+1)*GRIDW+x+1; /* upper right neighbor */
|
quad[p + 3] = (y + 1) * GRIDW + x; // Upper neighbor
|
||||||
quad[p+3] = (y+1)*GRIDW+x; /* upper neighbor */
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,9 +104,11 @@ double p[GRIDW][GRIDH];
|
|||||||
double vx[GRIDW][GRIDH], vy[GRIDW][GRIDH];
|
double vx[GRIDW][GRIDH], vy[GRIDW][GRIDH];
|
||||||
double ax[GRIDW][GRIDH], ay[GRIDW][GRIDH];
|
double ax[GRIDW][GRIDH], ay[GRIDW][GRIDH];
|
||||||
|
|
||||||
|
//========================================================================
|
||||||
|
// Initialize grid
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
|
void init_grid(void)
|
||||||
void initSurface( void )
|
|
||||||
{
|
{
|
||||||
int x, y;
|
int x, y;
|
||||||
double dx, dy, d;
|
double dx, dy, d;
|
||||||
@ -125,9 +126,8 @@ void initSurface( void )
|
|||||||
p[x][y] = -cos(d * (M_PI / (double)(GRIDW * 4))) * 100.0;
|
p[x][y] = -cos(d * (M_PI / (double)(GRIDW * 4))) * 100.0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
p[x][y] = 0.0;
|
p[x][y] = 0.0;
|
||||||
}
|
|
||||||
vx[x][y] = 0.0;
|
vx[x][y] = 0.0;
|
||||||
vy[x][y] = 0.0;
|
vy[x][y] = 0.0;
|
||||||
}
|
}
|
||||||
@ -135,57 +135,60 @@ void initSurface( void )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Draw view */
|
//========================================================================
|
||||||
void draw_screen( void )
|
// Draw scene
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
|
void draw_scene(void)
|
||||||
{
|
{
|
||||||
/* Clear the color and depth buffers. */
|
// Clear the color and depth buffers
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
/* We don't want to modify the projection matrix. */
|
// We don't want to modify the projection matrix
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
|
|
||||||
/* Move back. */
|
// Move back
|
||||||
glTranslatef(0.0, 0.0, -zoom);
|
glTranslatef(0.0, 0.0, -zoom);
|
||||||
/* Rotate the view */
|
// Rotate the view
|
||||||
glRotatef(beta, 1.0, 0.0, 0.0);
|
glRotatef(beta, 1.0, 0.0, 0.0);
|
||||||
glRotatef(alpha, 0.0, 0.0, 1.0);
|
glRotatef(alpha, 0.0, 0.0, 1.0);
|
||||||
|
|
||||||
//glDrawArrays(GL_POINTS,0,VERTEXNUM); /* Points only */
|
|
||||||
glDrawElements(GL_QUADS, 4 * QUADNUM, GL_UNSIGNED_INT, quad);
|
glDrawElements(GL_QUADS, 4 * QUADNUM, GL_UNSIGNED_INT, quad);
|
||||||
//glDrawElements(GL_LINES, QUADNUM, GL_UNSIGNED_INT, quad);
|
|
||||||
|
|
||||||
glfwSwapBuffers();
|
glfwSwapBuffers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Initialize OpenGL */
|
//========================================================================
|
||||||
void setup_opengl( void )
|
// Initialize Miscellaneous OpenGL state
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
|
void init_opengl(void)
|
||||||
{
|
{
|
||||||
/* Our shading model--Gouraud (smooth). */
|
// Use Gouraud (smooth) shading
|
||||||
glShadeModel(GL_SMOOTH);
|
glShadeModel(GL_SMOOTH);
|
||||||
|
|
||||||
/* Culling. */
|
// Switch on the z-buffer
|
||||||
//glCullFace(GL_BACK);
|
|
||||||
//glFrontFace(GL_CCW);
|
|
||||||
//glEnable(GL_CULL_FACE);
|
|
||||||
|
|
||||||
/* Switch on the z-buffer. */
|
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
|
||||||
glEnableClientState(GL_VERTEX_ARRAY);
|
glEnableClientState(GL_VERTEX_ARRAY);
|
||||||
glEnableClientState(GL_COLOR_ARRAY);
|
glEnableClientState(GL_COLOR_ARRAY);
|
||||||
glVertexPointer(3/*3 components per vertex (x,y,z)*/, GL_FLOAT, sizeof(struct Vertex), vertex);
|
glVertexPointer(3, GL_FLOAT, sizeof(struct Vertex), vertex);
|
||||||
glColorPointer(3/*3 components per vertex (r,g,b)*/, GL_FLOAT, sizeof(struct Vertex), &vertex[0].r); //Pointer to the first color
|
glColorPointer(3, GL_FLOAT, sizeof(struct Vertex), &vertex[0].r); // Pointer to the first color
|
||||||
|
|
||||||
glPointSize(2.0);
|
glPointSize(2.0);
|
||||||
|
|
||||||
/* Background color is black. */
|
// Background color is black
|
||||||
glClearColor(0, 0, 0, 0);
|
glClearColor(0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Modify the height of each vertex according to the pressure. */
|
//========================================================================
|
||||||
void adjustGrid( void )
|
// Modify the height of each vertex according to the pressure
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
|
void adjust_grid(void)
|
||||||
{
|
{
|
||||||
int pos;
|
int pos;
|
||||||
int x, y;
|
int x, y;
|
||||||
@ -201,32 +204,31 @@ void adjustGrid( void )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Calculate wave propagation */
|
//========================================================================
|
||||||
void calc( void )
|
// Calculate wave propagation
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
|
void calc_grid(void)
|
||||||
{
|
{
|
||||||
int x, y, x2, y2;
|
int x, y, x2, y2;
|
||||||
double time_step = dt * ANIMATION_SPEED;
|
double time_step = dt * ANIMATION_SPEED;
|
||||||
|
|
||||||
/* compute accelerations */
|
// Compute accelerations
|
||||||
for (x = 0; x < GRIDW; x++)
|
for (x = 0; x < GRIDW; x++)
|
||||||
{
|
{
|
||||||
x2 = (x + 1) % GRIDW;
|
x2 = (x + 1) % GRIDW;
|
||||||
for(y = 0; y < GRIDH; y++)
|
for(y = 0; y < GRIDH; y++)
|
||||||
{
|
|
||||||
ax[x][y] = p[x][y] - p[x2][y];
|
ax[x][y] = p[x][y] - p[x2][y];
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
for (y = 0; y < GRIDH; y++)
|
for (y = 0; y < GRIDH; y++)
|
||||||
{
|
{
|
||||||
y2 = (y + 1) % GRIDH;
|
y2 = (y + 1) % GRIDH;
|
||||||
for(x = 0; x < GRIDW; x++)
|
for(x = 0; x < GRIDW; x++)
|
||||||
{
|
|
||||||
ay[x][y] = p[x][y] - p[x][y2];
|
ay[x][y] = p[x][y] - p[x][y2];
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* compute speeds */
|
// Compute speeds
|
||||||
for (x = 0; x < GRIDW; x++)
|
for (x = 0; x < GRIDW; x++)
|
||||||
{
|
{
|
||||||
for (y = 0; y < GRIDH; y++)
|
for (y = 0; y < GRIDH; y++)
|
||||||
@ -236,7 +238,7 @@ void calc( void )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* compute pressure */
|
// Compute pressure
|
||||||
for (x = 1; x < GRIDW; x++)
|
for (x = 1; x < GRIDW; x++)
|
||||||
{
|
{
|
||||||
x2 = x - 1;
|
x2 = x - 1;
|
||||||
@ -249,20 +251,22 @@ void calc( void )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Handle key strokes */
|
//========================================================================
|
||||||
void handle_key_down(GLFWwindow window, int key, int action)
|
// Handle key strokes
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
|
void key_callback(GLFWwindow window, int key, int action)
|
||||||
{
|
{
|
||||||
if (action != GLFW_PRESS)
|
if (action != GLFW_PRESS)
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
switch(key) {
|
switch (key)
|
||||||
|
{
|
||||||
case GLFW_KEY_ESC:
|
case GLFW_KEY_ESC:
|
||||||
running = 0;
|
running = 0;
|
||||||
break;
|
break;
|
||||||
case GLFW_KEY_SPACE:
|
case GLFW_KEY_SPACE:
|
||||||
initSurface();
|
init_grid();
|
||||||
break;
|
break;
|
||||||
case GLFW_KEY_LEFT:
|
case GLFW_KEY_LEFT:
|
||||||
alpha += 5;
|
alpha += 5;
|
||||||
@ -277,7 +281,8 @@ void handle_key_down(GLFWwindow window, int key, int action)
|
|||||||
beta += 5;
|
beta += 5;
|
||||||
break;
|
break;
|
||||||
case GLFW_KEY_PAGEUP:
|
case GLFW_KEY_PAGEUP:
|
||||||
if(zoom>1) zoom-=1;
|
if (zoom > 1)
|
||||||
|
zoom -= 1;
|
||||||
break;
|
break;
|
||||||
case GLFW_KEY_PAGEDOWN:
|
case GLFW_KEY_PAGEDOWN:
|
||||||
zoom += 1;
|
zoom += 1;
|
||||||
@ -288,115 +293,98 @@ void handle_key_down(GLFWwindow window, int key, int action)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Callback function for window resize events */
|
//========================================================================
|
||||||
void handle_resize( GLFWwindow window, int width, int height )
|
// Callback function for window resize events
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
|
void window_resize_callback(GLFWwindow window, int width, int height)
|
||||||
{
|
{
|
||||||
float ratio = 1.0f;
|
float ratio = 1.f;
|
||||||
|
|
||||||
if (height > 0)
|
if (height > 0)
|
||||||
{
|
|
||||||
ratio = (float) width / (float) height;
|
ratio = (float) width / (float) height;
|
||||||
}
|
|
||||||
|
|
||||||
/* Setup viewport (Place where the stuff will appear in the main window). */
|
// Setup viewport
|
||||||
glViewport(0, 0, width, height);
|
glViewport(0, 0, width, height);
|
||||||
|
|
||||||
/*
|
// Change to the projection matrix and set our viewing volume
|
||||||
* Change to the projection matrix and set
|
|
||||||
* our viewing volume.
|
|
||||||
*/
|
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
gluPerspective(60.0, ratio, 1.0, 1024.0);
|
gluPerspective(60.0, ratio, 1.0, 1024.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Program entry point */
|
//========================================================================
|
||||||
|
// main
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
/* Dimensions of our window. */
|
|
||||||
int width, height;
|
|
||||||
/* Style of our window. */
|
|
||||||
int mode;
|
|
||||||
/* Frame time */
|
|
||||||
double t, t_old, dt_total;
|
|
||||||
GLFWwindow window;
|
GLFWwindow window;
|
||||||
|
double t, dt_total, t_old;
|
||||||
|
|
||||||
/* Initialize GLFW */
|
if (!glfwInit())
|
||||||
if(glfwInit() == GL_FALSE)
|
|
||||||
{
|
{
|
||||||
fprintf(stderr, "GLFW initialization failed\n");
|
fprintf(stderr, "GLFW initialization failed\n");
|
||||||
exit(-1);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Desired window properties */
|
window = glfwOpenWindow(640, 480, GLFW_WINDOWED, "Wave Simulation", NULL);
|
||||||
width = 640;
|
|
||||||
height = 480;
|
|
||||||
mode = GLFW_WINDOWED;
|
|
||||||
|
|
||||||
glfwOpenWindowHint(GLFW_DEPTH_BITS, 16);
|
|
||||||
|
|
||||||
/* Open window */
|
|
||||||
window = glfwOpenWindow(width, height, mode, "Wave Simulation", NULL);
|
|
||||||
if (!window)
|
if (!window)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Could not open window\n");
|
fprintf(stderr, "Could not open window\n");
|
||||||
glfwTerminate();
|
exit(EXIT_FAILURE);
|
||||||
exit(-1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glfwSwapInterval(1);
|
glfwSwapInterval(1);
|
||||||
|
|
||||||
/* Keyboard handler */
|
// Keyboard handler
|
||||||
glfwSetKeyCallback( window, handle_key_down );
|
glfwSetKeyCallback(window, key_callback);
|
||||||
glfwEnable(window, GLFW_KEY_REPEAT);
|
glfwEnable(window, GLFW_KEY_REPEAT);
|
||||||
|
|
||||||
/* Window resize handler */
|
// Window resize handler
|
||||||
glfwSetWindowSizeCallback( window, handle_resize );
|
glfwSetWindowSizeCallback(window, window_resize_callback);
|
||||||
|
|
||||||
/* Initialize OpenGL */
|
// Initialize OpenGL
|
||||||
setup_opengl();
|
init_opengl();
|
||||||
|
|
||||||
/* Initialize simulation */
|
// Initialize simulation
|
||||||
initVertices();
|
init_vertices();
|
||||||
initSurface();
|
init_grid();
|
||||||
adjustGrid();
|
adjust_grid();
|
||||||
|
|
||||||
/* Initialize timer */
|
// Initialize timer
|
||||||
t_old = glfwGetTime() - 0.01;
|
t_old = glfwGetTime() - 0.01;
|
||||||
|
|
||||||
/* Main loop */
|
|
||||||
while (running)
|
while (running)
|
||||||
{
|
{
|
||||||
/* Timing */
|
|
||||||
t = glfwGetTime();
|
t = glfwGetTime();
|
||||||
dt_total = t - t_old;
|
dt_total = t - t_old;
|
||||||
t_old = t;
|
t_old = t;
|
||||||
|
|
||||||
/* Safety - iterate if dt_total is too large */
|
// Safety - iterate if dt_total is too large
|
||||||
while( dt_total > 0.0f )
|
while (dt_total > 0.f)
|
||||||
{
|
{
|
||||||
/* Select iteration time step */
|
// Select iteration time step
|
||||||
dt = dt_total > MAX_DELTA_T ? MAX_DELTA_T : dt_total;
|
dt = dt_total > MAX_DELTA_T ? MAX_DELTA_T : dt_total;
|
||||||
dt_total -= dt;
|
dt_total -= dt;
|
||||||
|
|
||||||
/* Calculate wave propagation */
|
// Calculate wave propagation
|
||||||
calc();
|
calc_grid();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Compute height of each vertex */
|
// Compute height of each vertex
|
||||||
adjustGrid();
|
adjust_grid();
|
||||||
|
|
||||||
/* Draw wave grid to OpenGL display */
|
// Draw wave grid to OpenGL display
|
||||||
draw_screen();
|
draw_scene();
|
||||||
|
|
||||||
glfwPollEvents();
|
glfwPollEvents();
|
||||||
|
|
||||||
/* Still running? */
|
// Still running?
|
||||||
running = running && glfwIsWindow(window);
|
running = running && glfwIsWindow(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
glfwTerminate();
|
exit(EXIT_SUCCESS);
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
|
|
||||||
configure_file(
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libglfw.pc.cmake
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/libglfw.pc.cmake
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/libglfw.pc @ONLY)
|
${CMAKE_CURRENT_BINARY_DIR}/libglfw.pc @ONLY)
|
||||||
|
|
||||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}
|
include_directories(${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
@ -8,8 +7,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}
|
|||||||
${GLFW_BINARY_DIR}/src
|
${GLFW_BINARY_DIR}/src
|
||||||
${GLFW_INCLUDE_DIR})
|
${GLFW_INCLUDE_DIR})
|
||||||
|
|
||||||
set(cocoa_SOURCES
|
set(cocoa_SOURCES cocoa_enable.m
|
||||||
cocoa_enable.m
|
|
||||||
cocoa_fullscreen.m
|
cocoa_fullscreen.m
|
||||||
cocoa_glext.m
|
cocoa_glext.m
|
||||||
cocoa_init.m
|
cocoa_init.m
|
||||||
@ -20,17 +18,14 @@ set(cocoa_SOURCES
|
|||||||
# For some reason, CMake doesn't know about .m
|
# For some reason, CMake doesn't know about .m
|
||||||
set_source_files_properties(${cocoa_SOURCES} PROPERTIES LANGUAGE C)
|
set_source_files_properties(${cocoa_SOURCES} PROPERTIES LANGUAGE C)
|
||||||
|
|
||||||
set(libglfw_SOURCES
|
set(libglfw_SOURCES ${common_SOURCES} ${cocoa_SOURCES})
|
||||||
${common_SOURCES}
|
|
||||||
${cocoa_SOURCES})
|
|
||||||
|
|
||||||
add_library(libglfwStatic STATIC ${libglfw_SOURCES})
|
add_library(libglfwStatic STATIC ${libglfw_SOURCES})
|
||||||
add_library(libglfwShared SHARED ${libglfw_SOURCES})
|
add_library(libglfwShared SHARED ${libglfw_SOURCES})
|
||||||
target_link_libraries(libglfwShared ${GLFW_LIBRARIES})
|
target_link_libraries(libglfwShared ${GLFW_LIBRARIES})
|
||||||
set_target_properties(libglfwStatic libglfwShared PROPERTIES
|
set_target_properties(libglfwStatic libglfwShared PROPERTIES
|
||||||
CLEAN_DIRECT_OUTPUT 1
|
CLEAN_DIRECT_OUTPUT 1
|
||||||
OUTPUT_NAME glfw
|
OUTPUT_NAME glfw)
|
||||||
)
|
|
||||||
|
|
||||||
# Append -fno-common to the compile flags to work around a bug in the Apple GCC
|
# Append -fno-common to the compile flags to work around a bug in the Apple GCC
|
||||||
get_target_property(CFLAGS libglfwShared COMPILE_FLAGS)
|
get_target_property(CFLAGS libglfwShared COMPILE_FLAGS)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
if(CYGWIN)
|
if(CYGWIN)
|
||||||
configure_file(
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/libglfw.pc.cmake
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libglfw.pc.cmake
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/libglfw.pc @ONLY)
|
${CMAKE_CURRENT_BINARY_DIR}/libglfw.pc @ONLY)
|
||||||
|
|
||||||
# These lines are intended to remove the --export-all-symbols
|
# These lines are intended to remove the --export-all-symbols
|
||||||
@ -19,8 +19,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}
|
|||||||
${GLFW_BINARY_DIR}/src
|
${GLFW_BINARY_DIR}/src
|
||||||
${GLFW_INCLUDE_DIR})
|
${GLFW_INCLUDE_DIR})
|
||||||
|
|
||||||
set(libglfw_SOURCES
|
set(libglfw_SOURCES ${common_SOURCES}
|
||||||
${common_SOURCES}
|
|
||||||
win32_enable.c
|
win32_enable.c
|
||||||
win32_fullscreen.c
|
win32_fullscreen.c
|
||||||
win32_gamma.c
|
win32_gamma.c
|
||||||
@ -47,8 +46,9 @@ set_target_properties(libglfwStatic libglfwShared PROPERTIES
|
|||||||
|
|
||||||
if(CYGWIN)
|
if(CYGWIN)
|
||||||
# Build for the regular Win32 environment (not Cygwin)
|
# Build for the regular Win32 environment (not Cygwin)
|
||||||
set_target_properties(libglfwStatic libglfwShared PROPERTIES COMPILE_FLAGS "-mwin32 -mno-cygwin")
|
set_target_properties(libglfwStatic libglfwShared PROPERTIES
|
||||||
set_target_properties(libglfwStatic libglfwShared PROPERTIES LINK_FLAGS "-mwin32 -mno-cygwin")
|
COMPILE_FLAGS "-mwin32 -mno-cygwin"
|
||||||
|
LINK_FLAGS "-mwin32 -mno-cygwin")
|
||||||
endif(CYGWIN)
|
endif(CYGWIN)
|
||||||
|
|
||||||
install(TARGETS libglfwStatic libglfwShared DESTINATION lib)
|
install(TARGETS libglfwStatic libglfwShared DESTINATION lib)
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
|
|
||||||
configure_file(
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libglfw.pc.cmake
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/libglfw.pc.cmake
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/libglfw.pc @ONLY)
|
${CMAKE_CURRENT_BINARY_DIR}/libglfw.pc @ONLY)
|
||||||
|
|
||||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}
|
include_directories(${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
@ -8,8 +7,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}
|
|||||||
${GLFW_BINARY_DIR}/src
|
${GLFW_BINARY_DIR}/src
|
||||||
${GLFW_INCLUDE_DIR})
|
${GLFW_INCLUDE_DIR})
|
||||||
|
|
||||||
set(libglfw_SOURCES
|
set(libglfw_SOURCES ${common_SOURCES}
|
||||||
${common_SOURCES}
|
|
||||||
x11_enable.c
|
x11_enable.c
|
||||||
x11_fullscreen.c
|
x11_fullscreen.c
|
||||||
x11_gamma.c
|
x11_gamma.c
|
||||||
@ -25,8 +23,7 @@ add_library(libglfwShared SHARED ${libglfw_SOURCES})
|
|||||||
target_link_libraries(libglfwShared ${GLFW_LIBRARIES})
|
target_link_libraries(libglfwShared ${GLFW_LIBRARIES})
|
||||||
set_target_properties(libglfwStatic libglfwShared PROPERTIES
|
set_target_properties(libglfwStatic libglfwShared PROPERTIES
|
||||||
CLEAN_DIRECT_OUTPUT 1
|
CLEAN_DIRECT_OUTPUT 1
|
||||||
OUTPUT_NAME glfw
|
OUTPUT_NAME glfw)
|
||||||
)
|
|
||||||
|
|
||||||
install(TARGETS libglfwStatic libglfwShared DESTINATION lib)
|
install(TARGETS libglfwStatic libglfwShared DESTINATION lib)
|
||||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libglfw.pc DESTINATION lib/pkgconfig)
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libglfw.pc DESTINATION lib/pkgconfig)
|
||||||
|
@ -55,6 +55,8 @@ void _glfwPlatformGetGammaRamp(GLFWgammaramp* ramp)
|
|||||||
XRRCrtcGamma* gamma = XRRGetCrtcGamma(_glfwLibrary.X11.display,
|
XRRCrtcGamma* gamma = XRRGetCrtcGamma(_glfwLibrary.X11.display,
|
||||||
rr->crtcs[0]);
|
rr->crtcs[0]);
|
||||||
|
|
||||||
|
// TODO: Handle case of original ramp size having a size other than 256
|
||||||
|
|
||||||
memcpy(ramp->red, gamma->red, size);
|
memcpy(ramp->red, gamma->red, size);
|
||||||
memcpy(ramp->green, gamma->green, size);
|
memcpy(ramp->green, gamma->green, size);
|
||||||
memcpy(ramp->blue, gamma->blue, size);
|
memcpy(ramp->blue, gamma->blue, size);
|
||||||
|
@ -176,7 +176,7 @@ static void initGammaRamp(void)
|
|||||||
#endif /*_GLFW_HAS_XF86VIDMODE*/
|
#endif /*_GLFW_HAS_XF86VIDMODE*/
|
||||||
|
|
||||||
if (!_glfwLibrary.originalRampSize)
|
if (!_glfwLibrary.originalRampSize)
|
||||||
fprintf(stderr, "Gamma ramp setting unsupported\n");
|
fprintf(stderr, "No supported gamma ramp API found\n");
|
||||||
|
|
||||||
// Save the original gamma ramp
|
// Save the original gamma ramp
|
||||||
_glfwPlatformGetGammaRamp(&_glfwLibrary.originalRamp);
|
_glfwPlatformGetGammaRamp(&_glfwLibrary.originalRamp);
|
||||||
@ -310,14 +310,14 @@ const char* _glfwPlatformGetVersionString(void)
|
|||||||
#elif defined(_GLFW_HAS_GLXGETPROCADDRESSEXT)
|
#elif defined(_GLFW_HAS_GLXGETPROCADDRESSEXT)
|
||||||
" glXGetProcAddressEXT"
|
" glXGetProcAddressEXT"
|
||||||
#elif defined(_GLFW_DLOPEN_LIBGL)
|
#elif defined(_GLFW_DLOPEN_LIBGL)
|
||||||
" dlopen(libGL)"
|
" dlsym(libGL)"
|
||||||
#else
|
#else
|
||||||
" (no OpenGL extension support)"
|
" (no OpenGL extension support)"
|
||||||
#endif
|
#endif
|
||||||
#if defined(_GLFW_USE_LINUX_JOYSTICKS)
|
#if defined(_GLFW_USE_LINUX_JOYSTICKS)
|
||||||
" Linux joystick API"
|
" Linux-joystick-API"
|
||||||
#else
|
#else
|
||||||
" (no joystick support)"
|
" no-joystick-support"
|
||||||
#endif
|
#endif
|
||||||
;
|
;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user