Clone of mesa.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

point-position.c 2.3KB

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