2014-01-10 1 views
0

것은 내가 Tao.FreeGlut 2.1.0와 함께 창을 초기화하기와 OpenTK 1.1 drawind하기 위해 노력하고있어, 그래서 간단한 프로그램을 만들어 :OpenTK와 Tao.FreeGlut을 함께 사용할 수 있습니까?

public static void Main() 
{ 
    Glut.glutInit(); 
    Glut.glutInitDisplayMode(Glut.GLUT_DOUBLE | Glut.GLUT_RGBA); 
    Glut.glutInitWindowSize(1024, 768); 
    Glut.glutInitWindowPosition(100, 100); 
    Glut.glutCreateWindow("Test"); 
    Glut.glutDisplayFunc(RenderScene); 

    GL.ClearColor(0.0f, 0.0f, 0.0f, 0.0f); 

    Glut.glutMainLoop(); 
} 

public static void RenderScene() 
{ 
    GL.Clear(ClearBufferMask.ColorBufferBit); 
    Glut.glutSwapBuffers(); 
} 

그러나 GL.ClearColor 통화가 null의 심판을 제외하고 충돌합니다. OpenTK가 자신의 OpenGL 컨텍스트를 저장하고 있기 때문에 Glut에 의해 생성되고 제대로 초기화되지 않은 컨텍스트와 동일하지 않기 때문에 이런 일이 발생한다고 생각합니다. 내가 과잉에서 컨텍스트를 얻을 수있는 방법을 발견하지, 그럼 내가 뭔가 할 시도 :

IWindowInfo window = Utilities.CreateWindowsWindowInfo(Glut.glutGetWindowData()); 
GraphicsContext context = new GraphicsContext(GraphicsMode.Default, window); 
context.MakeCurrent(window); 
context.LoadAll(); 

을 그리고 지금은 어쨌든, 컨텍스트 생성에 OpenTK에 정확하지 창을 충돌합니다.

OpenTK에서 Glut을 사용하고 수정하는 방법이 있습니까? 아니면 Glut을 사용하지 않고 OpenTK 메소드로 윈도우와 컨텍스트를 생성해야합니까?

답변

0

예, 가능합니다. documentation에서 :

Glut.glutCreateWindow("Test"); 

// Initialize OpenTK using the current GLUT context 
var opentk_context = new GraphicsContext(ContextHandle.Zero, null); 

// You can now call GL functions freely 
GL.ClearColor(0.0f, 0.0f, 0.0f, 0.0f); 

참고 GLUT 컨텍스트가 생성되고 현재해야한다는 당신은 new GraphicsContext()를 호출 할 때. freeglut documentation에 따르면 glutCreateWindow()이 반환 된 직후 인 경우입니다.

관련 문제