~ubuntu-branches/ubuntu/jaunty/mesa/jaunty

« back to all changes in this revision

Viewing changes to progs/fp/tri-mov.c

  • Committer: Bazaar Package Importer
  • Author(s): Timo Aaltonen
  • Date: 2009-01-23 10:20:24 UTC
  • mfrom: (1.2.14 upstream)
  • Revision ID: james.westby@ubuntu.com-20090123102024-1f3kmb3aea7wzk67
Tags: 7.3~rc3-1ubuntu1
* Merge with Debian experimental.
* Drop 102_dont_vblank.patch, since the new drm code in the kernel
  fixes the bugs that it worked around.
* Bump the build-dependency of libdrm to 2.4.4. It's the first version
  with necessary changes to build this.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
 
2
 
#include <stdio.h>
3
 
#include <string.h>
4
 
#include <stdlib.h>
5
 
#define GL_GLEXT_PROTOTYPES
6
 
#include <GL/glut.h>
7
 
#include "GL/gl.h"
8
 
 
9
 
static void Init( void )
10
 
{
11
 
   static const char *modulate2D =
12
 
      "!!ARBfp1.0\n"
13
 
      "MOV result.color, fragment.color; \n"
14
 
      "END"
15
 
      ;
16
 
   GLuint modulateProg;
17
 
 
18
 
   if (!glutExtensionSupported("GL_ARB_fragment_program")) {
19
 
      printf("Error: GL_ARB_fragment_program not supported!\n");
20
 
      exit(1);
21
 
   }
22
 
   printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
23
 
 
24
 
   /* Setup the fragment program */
25
 
   glGenProgramsARB(1, &modulateProg);
26
 
   glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg);
27
 
   glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
28
 
                        strlen(modulate2D), (const GLubyte *)modulate2D);
29
 
 
30
 
   printf("glGetError = 0x%x\n", (int) glGetError());
31
 
   printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n",
32
 
          (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB));
33
 
 
34
 
   glEnable(GL_FRAGMENT_PROGRAM_ARB);
35
 
 
36
 
   glClearColor(.3, .3, .3, 0);
37
 
}
38
 
 
39
 
static void Reshape(int width, int height)
40
 
{
41
 
 
42
 
    glViewport(0, 0, (GLint)width, (GLint)height);
43
 
 
44
 
    glMatrixMode(GL_PROJECTION);
45
 
    glLoadIdentity();
46
 
    glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
47
 
    glMatrixMode(GL_MODELVIEW);
48
 
}
49
 
 
50
 
static void Key(unsigned char key, int x, int y)
51
 
{
52
 
 
53
 
    switch (key) {
54
 
      case 27:
55
 
        exit(1);
56
 
      default:
57
 
        return;
58
 
    }
59
 
 
60
 
    glutPostRedisplay();
61
 
}
62
 
 
63
 
static void Draw(void)
64
 
{
65
 
   glClear(GL_COLOR_BUFFER_BIT); 
66
 
 
67
 
   glBegin(GL_TRIANGLES);
68
 
   glColor3f(0,0,1); 
69
 
   glVertex3f( 0.9, -0.9, -30.0);
70
 
   glColor3f(1,0,0); 
71
 
   glVertex3f( 0.9,  0.9, -30.0);
72
 
   glColor3f(0,1,0); 
73
 
   glVertex3f(-0.9,  0.0, -30.0);
74
 
   glEnd();
75
 
 
76
 
   glFlush();
77
 
}
78
 
 
79
 
 
80
 
int main(int argc, char **argv)
81
 
{
82
 
    GLenum type;
83
 
 
84
 
    glutInit(&argc, argv);
85
 
 
86
 
    glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
87
 
 
88
 
    type = GLUT_RGB | GLUT_SINGLE;
89
 
    glutInitDisplayMode(type);
90
 
 
91
 
    if (glutCreateWindow("First Tri") == GL_FALSE) {
92
 
        exit(1);
93
 
    }
94
 
 
95
 
    Init();
96
 
 
97
 
    glutReshapeFunc(Reshape);
98
 
    glutKeyboardFunc(Key);
99
 
    glutDisplayFunc(Draw);
100
 
    glutMainLoop();
101
 
        return 0;
102
 
}