mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-25 00:00:11 +01:00
updated to use ARB extensions
This commit is contained in:
parent
2a7243481a
commit
66fa33e576
2 changed files with 34 additions and 26 deletions
|
|
@ -18,7 +18,7 @@
|
|||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#define GL_GLEXT_LEGACY
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glut.h>
|
||||
|
||||
/* Some <math.h> files do not define M_PI... */
|
||||
|
|
@ -264,15 +264,15 @@ menu(int option)
|
|||
case 0:
|
||||
makePointList();
|
||||
break;
|
||||
#if GL_EXT_point_parameters
|
||||
#if GL_ARB_point_parameters
|
||||
case 1:
|
||||
glPointParameterfvEXT(GL_DISTANCE_ATTENUATION_EXT, constant);
|
||||
glPointParameterfvARB(GL_POINT_DISTANCE_ATTENUATION_ARB, constant);
|
||||
break;
|
||||
case 2:
|
||||
glPointParameterfvEXT(GL_DISTANCE_ATTENUATION_EXT, linear);
|
||||
glPointParameterfvARB(GL_POINT_DISTANCE_ATTENUATION_ARB, linear);
|
||||
break;
|
||||
case 3:
|
||||
glPointParameterfvEXT(GL_DISTANCE_ATTENUATION_EXT, theQuad);
|
||||
glPointParameterfvARB(GL_POINT_DISTANCE_ATTENUATION_ARB, theQuad);
|
||||
break;
|
||||
#endif
|
||||
case 4:
|
||||
|
|
@ -281,12 +281,12 @@ menu(int option)
|
|||
case 5:
|
||||
blend = 0;
|
||||
break;
|
||||
#if GL_EXT_point_parameters
|
||||
#if GL_ARB_point_parameters
|
||||
case 6:
|
||||
glPointParameterfEXT(GL_POINT_FADE_THRESHOLD_SIZE_EXT, 1.0);
|
||||
glPointParameterfARB(GL_POINT_FADE_THRESHOLD_SIZE_ARB, 1.0);
|
||||
break;
|
||||
case 7:
|
||||
glPointParameterfEXT(GL_POINT_FADE_THRESHOLD_SIZE_EXT, 10.0);
|
||||
glPointParameterfARB(GL_POINT_FADE_THRESHOLD_SIZE_ARB, 10.0);
|
||||
break;
|
||||
#endif
|
||||
case 8:
|
||||
|
|
@ -468,8 +468,8 @@ main(int argc, char **argv)
|
|||
glEnable(GL_POINT_SMOOTH);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glPointSize(8.0);
|
||||
#if GL_EXT_point_parameters
|
||||
glPointParameterfvEXT(GL_DISTANCE_ATTENUATION_EXT, theQuad);
|
||||
#if GL_ARB_point_parameters
|
||||
glPointParameterfvARB(GL_POINT_DISTANCE_ATTENUATION_ARB, theQuad);
|
||||
#endif
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
gluPerspective( /* field of view in degree */ 40.0,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: winpos.c,v 1.5 2002/04/22 16:03:37 brianp Exp $ */
|
||||
/* $Id: winpos.c,v 1.6 2002/12/03 03:13:17 brianp Exp $ */
|
||||
|
||||
/*
|
||||
* Example of how to use the GL_MESA_window_pos extension.
|
||||
|
|
@ -12,7 +12,7 @@
|
|||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#define GL_GLEXT_LEGACY
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include "GL/glut.h"
|
||||
|
||||
#include "readtex.c" /* a hack, I know */
|
||||
|
|
@ -30,18 +30,12 @@ static GLubyte *Image;
|
|||
static int ImgWidth, ImgHeight;
|
||||
static GLenum ImgFormat;
|
||||
|
||||
static void (*WindowPosFunc)(GLfloat x, GLfloat y);
|
||||
|
||||
|
||||
static void draw( void )
|
||||
{
|
||||
GLfloat angle;
|
||||
char *extensions;
|
||||
|
||||
extensions = (char *) glGetString( GL_EXTENSIONS );
|
||||
if (strstr( extensions, "GL_MESA_window_pos")==NULL) {
|
||||
printf("Sorry, GL_MESA_window_pos extension not available.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
glClear( GL_COLOR_BUFFER_BIT );
|
||||
|
||||
|
|
@ -50,16 +44,14 @@ static void draw( void )
|
|||
GLfloat y = 50.0 + 200.0 * sin( angle * M_PI / 180.0 );
|
||||
|
||||
/* Don't need to worry about the modelview or projection matrices!!! */
|
||||
#ifdef GL_MESA_window_pos
|
||||
glWindowPos2fMESA( x, y );
|
||||
#endif
|
||||
(*WindowPosFunc)( x, y );
|
||||
|
||||
glDrawPixels( ImgWidth, ImgHeight, ImgFormat, GL_UNSIGNED_BYTE, Image );
|
||||
}
|
||||
glFinish();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static void key( unsigned char key, int x, int y )
|
||||
{
|
||||
(void) x;
|
||||
|
|
@ -71,7 +63,6 @@ static void key( unsigned char key, int x, int y )
|
|||
}
|
||||
|
||||
|
||||
|
||||
/* new window size or exposure */
|
||||
static void reshape( int width, int height )
|
||||
{
|
||||
|
|
@ -81,6 +72,24 @@ static void reshape( int width, int height )
|
|||
|
||||
static void init( void )
|
||||
{
|
||||
#ifdef GL_ARB_window_pos
|
||||
if (glutExtensionSupported("GL_ARB_window_pos")) {
|
||||
printf("Using GL_ARB_window_pos\n");
|
||||
WindowPosFunc = &glWindowPos2fARB;
|
||||
}
|
||||
else
|
||||
#elif defined(GL_ARB_window_pos)
|
||||
if (glutExtensionSupported("GL_MESA_window_pos")) {
|
||||
printf("Using GL_MESA_window_pos\n");
|
||||
WindowPosFunc = &glWindowPos2fMESA;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
printf("Sorry, GL_ARB/MESA_window_pos extension not available.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Image = LoadRGBImage( IMAGE_FILE, &ImgWidth, &ImgHeight, &ImgFormat );
|
||||
if (!Image) {
|
||||
printf("Couldn't read %s\n", IMAGE_FILE);
|
||||
|
|
@ -90,7 +99,6 @@ static void init( void )
|
|||
}
|
||||
|
||||
|
||||
|
||||
int main( int argc, char *argv[] )
|
||||
{
|
||||
glutInitWindowPosition(0, 0);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue