arsd simpledisplay opengl 3d

Amorphorious Amorphorious at gmail.com
Tue Dec 26 07:57:02 UTC 2017


Hi Adam, I'm interested in using your simpledisplay for 3D in 
openGL. I have worked with 2D fine but 3D is problemattic. I 
cannot get any depth even though i have set up 3D mode by 
modifying gamehelpers:

SimpleWindow create2dWindow(int width = 512, int height = 512, 
int viewportWidth=512, int viewportHeight=512, string title="") {
	auto window = new SimpleWindow(width, height, title, 
OpenGlOptions.yes);

	window.setAsCurrentOpenGlContext();

	glEnable(eGL.BLEND);
	glBlendFunc(eGL.SRC_ALPHA, eGL.ONE_MINUS_SRC_ALPHA);
	glShadeModel(GL_SMOOTH);
	glClearColor(0,0,0,0);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear 
color and depth buffers
	glDepthFunc(GL_LESS);
	glDepthMask(GL_TRUE);
	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
	glEnable(GL_DEPTH_TEST);

	glMatrixMode(eGL.PROJECTION);
	glLoadIdentity();
	//glOrtho(0, viewportWidth, viewportHeight, 0, 0, 1);	// Specify 
opengl window size, which differs from OS window size
	//glMatrixMode(eGL.MODELVIEW);
	//glLoadIdentity();
	glMatrixMode( GL_PROJECTION );
	glLoadIdentity();
	gluPerspective(145, 1.333, 0.01, 100);
	
	
//	glDisable(eGL.DEPTH_TEST);
	glEnable(eGL.TEXTURE_2D);

	return window;
}

I've played around with various settings but either I get nothing 
or 2D. Any idea what I might be missing?


More information about the Digitalmars-d-learn mailing list