Hello,
I am calling native method from the Java Code to create one native Window and then initializing the OpenGL to render on the created window. I am able to create a window, OpenGL context, renderer context etc. OpenGL also clears the color but not render the line i have drawn. here is the code for the same...
JNIEXPORT void drawBox(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); // Clear The Screen And The Depth Buffer
glColor4f(1,1,1,1);
glBegin(GL_LINE); // Drawing Using Triangles
glVertex3f( 1.0f, 1.0f, 0.0f); // Top
glVertex3f(500.0f,500.0f, 0.0f); // Bottom Left
//glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right
glEnd();
}
JNIEXPORT void init(void)
{
/* Use depth buffering for hidden surface elimination. */
glEnable(GL_DEPTH_TEST); // Enables Depth Testing
glDepthFunc(GL_LEQUAL);
glViewport(0,0,500,500);
glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
glLoadIdentity();
glOrtho(0,500, 0,500, -1, 1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glClearColor(1,0,0,0);
}
JNIEXPORT int main(int argc, char **argv)
{
init();
while(true){
f_wglMakeCurrent(m_DeviceContext,m_RenderContext);
drawBox();
SwapBuffers(m_DeviceContext);
f_wglMakeCurrent(NULL,NULL);
::Sleep(2000);
}
return 0;
}
Hilighted area with red color works properly.
Any help would be appreciatedā¦
Thanks In Advanceā¦