summaryrefslogtreecommitdiffstats
path: root/src/controller/exp004processhits.c (plain)
blob: 29fbbbc07b100f076b1edbb82a1852d65d3bf153
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/* I seem to need this for glGenBuffers as per
   http://www.gamedev.net/community/forums/topic.asp?topic_id=422358 */
#define GL_GLEXT_PROTOTYPES

#include "exp004processhits.h"
#include "../view/exp004state0.h"
#include <stdio.h>

/*
 * The implementation of this function is based on
 * [Angel,2008,pp80-81].
 */
void
exp004processhits (GLint hits, GLuint buffer[])
{
  /*
   * A simple alias to make the code more readable.
   */
  EXP004STATE* S = &exp004state0;

  printf ("Hits: %d\n", hits);

  GLuint *hitlist = buffer;

  for (int i = 0; i < hits; i++)
    {
      hitlist += 3;

      /*
       * Report the hit to the terminal.
       */
      printf ("Hit %i: %s\n", i + 1, exp004state0.gi_data[*hitlist]);

      /*
       * Add the hits to the selection.
       */
      exp004state0.selection[*hitlist] = true;
      exp004state0.base_colors_data[*hitlist][0] = SELECT_COLOR_R;
      exp004state0.base_colors_data[*hitlist][1] = SELECT_COLOR_G;
      exp004state0.base_colors_data[*hitlist][2] = SELECT_COLOR_B;

      hitlist++;
    }

  glBindBuffer (GL_ARRAY_BUFFER, S->buffers[BASE_COLORS]);
  glColorPointer (3, GL_FLOAT, 0, 0);
  glBufferData (GL_ARRAY_BUFFER,
		sizeof (S->base_colors_data), S->base_colors_data,
		GL_STATIC_DRAW);

  printf ("\n");

  return;
}

Valid XHTML 1.0 Strict

Copyright © 2009 Don Pellegrino All Rights Reserved.