2010-04-02 4 views
1

그래서 좀 OpenGL을 코드 (예를 들면 코드)컴파일하지 않고 OpenGL 코드를 실행하는 방법은 무엇입니까?

/* 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; 
} 
내가 그것을 실행하려는

하지만 밖으로 프리 D 파일러에 있습니다. 그런 일을 할 수있는 방법이 있습니까

+0

'사전 컴파일'하지 않거나 '처음 컴파일'하지 않습니까? –

답변

2

LWJGL (OpenGL 바인딩)과 REPL (012VM)이 가능합니다 (JVM에서 실행 됨). Clojure/Jython과 같은 다른 언어도 LWJGL 또는 Jogl을 통해이 요청을 처리 할 수 ​​있다고 상상합니다. 또한 (명시 적) 컴파일을 필요로하지 않거나 자체 REPL 및/또는 '통합 IDE'와 함께 제공되는 전체 호스트 언어에 대한 OpenGL 바인딩이 있습니다.

일반적으로 항상 컴파일이 필요하지만 나는 이것을 찾았습니다 : http://neugierig.org/software/c-repl/ 그리고 다른 비슷한 프로젝트가 있습니다.

해피 코딩.