12 #define TEXTURE_FILE DEMOS_DATA_DIR "girl.rgb"
16 static void Init( void )
18 static const char *modulate2D
=
20 "TEX result.color, fragment.color, texture[0], 2D; \n"
26 if (!GLAD_GL_ARB_fragment_program
) {
27 printf("Error: GL_ARB_fragment_program not supported!\n");
30 printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER
));
32 /* Setup the fragment program */
33 glGenProgramsARB(1, &modulateProg
);
34 glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB
, modulateProg
);
35 glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB
, GL_PROGRAM_FORMAT_ASCII_ARB
,
36 strlen(modulate2D
), (const GLubyte
*)modulate2D
);
38 printf("glGetError = 0x%x\n", (int) glGetError());
39 printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n",
40 (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB
));
41 assert(glIsProgramARB(modulateProg
));
43 glEnable(GL_FRAGMENT_PROGRAM_ARB
);
46 glGenTextures(1, &Texture
);
47 glBindTexture(GL_TEXTURE_2D
, Texture
);
48 glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MIN_FILTER
, GL_LINEAR
);
49 glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, GL_LINEAR
);
50 glPixelStorei(GL_UNPACK_ALIGNMENT
, 1);
51 if (!LoadRGBMipmaps(TEXTURE_FILE
, GL_RGB
)) {
52 printf("Error: couldn't load texture image file %s\n", TEXTURE_FILE
);
55 /* XXX this enable shouldn't really be needed!!! */
56 glEnable(GL_TEXTURE_2D
);
58 glClearColor(.3, .3, .3, 0);
61 static void Reshape(int width
, int height
)
64 glViewport(0, 0, (GLint
)width
, (GLint
)height
);
66 glMatrixMode(GL_PROJECTION
);
68 glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
69 glMatrixMode(GL_MODELVIEW
);
72 static void Key(unsigned char key
, int x
, int y
)
85 static void Draw(void)
87 glClear(GL_COLOR_BUFFER_BIT
);
89 glBegin(GL_TRIANGLES
);
91 /* glTexCoord2f(1, 0); */
92 glVertex3f( 0.9, -0.9, -30.0);
94 /* glTexCoord2f(1, 1); */
95 glVertex3f( 0.9, 0.9, -30.0);
97 /* glTexCoord2f(0, .5); */
98 glVertex3f(-0.9, 0.0, -30.0);
105 int main(int argc
, char **argv
)
109 glutInit(&argc
, argv
);
113 glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
117 glutInitDisplayMode(type
);
119 if (glutCreateWindow("First Tri") == GL_FALSE
) {
127 glutReshapeFunc(Reshape
);
128 glutKeyboardFunc(Key
);
129 glutDisplayFunc(Draw
);