Pregunta

Así que tengo algo de código OpenGL (como por ejemplo el código)

/*   FUNCTION:        YCamera :: CalculateWorldCoordinates
     ARGUMENTS:       x         mouse x coordinate
                      y         mouse y coordinate
                      vec       where to store coordinates
     RETURN:          n/a
     DESCRIPTION:     Convert mouse coordinates into world coordinates
*/
void YCamera :: CalculateWorldCoordinates(float x, float y, YVector3 *vec) { // START GLint viewport[4]; GLdouble mvmatrix[16], projmatrix[16];

 GLint real_y;
GLdouble mx, my, mz;

glGetIntegerv(GL_VIEWPORT, viewport);
glGetDoublev(GL_MODELVIEW_MATRIX, mvmatrix);
glGetDoublev(GL_PROJECTION_MATRIX, projmatrix);

real_y = viewport[3] - (GLint) y - 1;   // viewport[3] is height of window in pixels
gluUnProject((GLdouble) x, (GLdouble) real_y, 1.0, mvmatrix, projmatrix, viewport, &mx, &my, &mz);

/*      'mouse' is the point where mouse projection reaches FAR_PLANE.
        World coordinates is intersection of line(camera->mouse) with plane(z=0) (see LaMothe 306)

        Equation of line in 3D:
                (x-x0)/a = (y-y0)/b = (z-z0)/c          

        Intersection of line with plane:
                z = 0
                x-x0 = a(z-z0)/c  <=> x = x0+a(0-z0)/c  <=> x = x0 -a*z0/c
                y = y0 - b*z0/c

*/
double lx = fPosition.x - mx;
double ly = fPosition.y - my;
double lz = fPosition.z - mz;
double sum = lx*lx + ly*ly + lz*lz;
double normal = sqrt(sum);
double z0_c = fPosition.z / (lz/normal);

vec->x = (float) (fPosition.x - (lx/normal)*z0_c);
vec->y = (float) (fPosition.y - (ly/normal)*z0_c);
vec->z = 0.0f;
}

Quiero ejecutarlo pero con un vistazo a la precompilación. ¿Hay alguna manera de hacer tal cosa

¿Fue útil?

Solución

Esto es posible con LWJGL (OpenGL de unión) y el REPL en Scala (se ejecuta en la JVM). Imagino que otros lenguajes como Clojure / Jython también podrían manejar esta solicitud - ya sea a través LWJGL o JOGL. También hay enlaces de OpenGL para una gran cantidad de idiomas que no requieren (explícito) compilar o vienen con su propio REPL y / o 'IDE integrado'.

C normalmente requiere siempre una compilación, pero encontré esto: http://neugierig.org/software/c-repl/ y estoy seguro hay otros proyectos similares en la naturaleza.

Happy codificación.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top