Sign in to follow this  

White Screen Using GLEW functions

This topic is 1316 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey i recently found out there is something wrong with my GLEW when i use its functions it's a white screen and when i resize my window it removes the white parts but not all (Image Attached To Post) some functions like glMultiDrawElements Or glDrawRangeElements  .

 

(i linked to glew32s(static) and freeglut , I used #define GLEW_STATIC , glewInit )

 

When I link to glew32 instead of glew32s and i don't define GLEW_STATIC Nothing will Change , Still The White screen.

 

Here is My Code :

#define GLEW_STATIC

#include <GL/glew.h>
#include <GL/glut.h>



void init(void){
	glClearColor(0,0,0,1);
	glShadeModel(GL_FLAT);
}

void reshape(int w,int h){
	glLoadIdentity();
	glMatrixMode(GL_MODELVIEW);
	glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
}



void display(void){
	
	glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

	double v[] = { 
		0,1,
		0,-1,
		1,-0.5,
		-1,-0.5,
		0,0
	};

	glLoadIdentity();
	
	glEnableClientState(GL_VERTEX_ARRAY);

	glVertexPointer(2,GL_DOUBLE,0,v);
	
	unsigned int index[] = {0,1,1,2};
	
	glDrawRangeElements(GL_LINES,1,3,4,GL_UNSIGNED_INT,index);
	//glDrawElements(GL_LINES,4,GL_UNSIGNED_INT,index);

	glDisableClientState(GL_VERTEX_ARRAY);
	
	glutSwapBuffers();
}

int main(int argc , char** argv){

	glewInit();
	glutInit(&argc , argv);
	glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGBA);
	glutInitWindowSize(500,500);
	glutInitWindowPosition(0,0);
	glutCreateWindow(argv[0]);
	init();
	glutDisplayFunc(display);
	glutReshapeFunc(reshape);
	glutMainLoop();
	return 0;
}

Thanks

Share this post


Link to post
Share on other sites
That cannot work. GLEW requires an active OpenGL context before you can initialize it. I'm not sure when GLUT guarantees you an active OpenGL context (check the documentation), but certainly not before the first GLUT call.

Edit: You should really get into the habit of checking return values. Checking the result of glewInit() would have put you onto the right track much sooner. Edited by BitMaster

Share this post


Link to post
Share on other sites
Sign in to follow this