Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 2 of 2 FirstFirst 12
Results 11 to 12 of 12

Thread: Only last set of vertices render

  1. #11
    There must still be something wrong with my coordinates...Again here is my Init code:
    Code :
    void OGL_Renderer_3_2::initGL(){
    	glClearColor(0, 0, 0, 0);
    	glClear(GL_COLOR_BUFFER_BIT);
     
    	glDisable(GL_DEPTH_TEST);
     
    	glViewport(0, 0, width(), height());
     
     
    	// Spit out system graphics information.
    	cout << "\t- OpenGL System Info -" << endl;
     
     
    	driverName((char*)glGetString(GL_RENDERER));
     
     
    	cout << "\tVendor: " << glGetString(GL_VENDOR) << endl;
    	cout << "\tRenderer: " << driverName() << endl;
    	cout << "\tDriver Version: " << glGetString(GL_VERSION) << endl;
    	cout << "\tGLSL Version: " << glGetString(GL_SHADING_LANGUAGE_VERSION) << endl;
     
     
    //	if(!checkExtensions())
    //		throw Exception(0, "Graphics Requirements Not Met", "Your graphics driver does not meet the minimum requirements.");
     
     
    	glGenVertexArrays(1, &mVertexArray);
    	getError();
    	glBindVertexArray(mVertexArray);
    	getError();
     
     
    	glGenBuffers(1, &mVertexBufferObject);
    	getError();
    	glBindBuffer(GL_ARRAY_BUFFER, mVertexBufferObject);
    	getError();
    	glBufferData(GL_ARRAY_BUFFER, 4 * 6 * sizeof(GLfloat), DEFAULT_VERTEX_COORDS, GL_DYNAMIC_DRAW);
    	getError();
     
     
    	glGenBuffers(1, &mTextureBufferObject);
    	getError();
    	glBindBuffer(GL_ARRAY_BUFFER, mTextureBufferObject);
    	getError();
    	glBufferData(GL_ARRAY_BUFFER, 2 * sizeof(DEFAULT_TEXTURE_COORDS), DEFAULT_TEXTURE_COORDS, GL_STATIC_DRAW);
    	getError();
    	glEnableVertexAttribArray(0);
    	getError();
     
     
    	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
    	getError();
    }
     
     
     
     
    void OGL_Renderer_3_2::initVideo(unsigned int resX, unsigned int resY, unsigned int bpp, bool fullscreen, bool vsync)
    {
    	// Initialize SDL's Video Subsystems.
    	if(SDL_Init(SDL_INIT_VIDEO) < 0)
    		throw Exception(701, "Error starting SDL Video Library", SDL_GetError());
     
     
     
     
    	// Setup OpenGL parameters
    	SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
    	SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
    	SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
     
     
    	SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
    	SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);	/// \todo	Add checks to determine an appropriate depth buffer.
     
     
    	if(vsync)
    		SDL_GL_SetSwapInterval(1);
     
     
    	// Anti-aliasing... need to test this.
    	//SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
    	//SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 4);
     
     
    	Uint32 sdlFlags = SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN;
     
     
    	if(fullscreen)
    		sdlFlags = sdlFlags | SDL_WINDOW_FULLSCREEN;
     
     
    	mWindow = SDL_CreateWindow(title().c_str(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, resX, resY, sdlFlags);
     
     
    	if(!mWindow)
    	{
    		cout << "EXCEPTION: Could not create a Window: " << SDL_GetError() << endl;
    		throw Exception(0, "Window Creation Failed", "Unable to create a window.");
    	}
     
     
    	_window = mWindow;
     
     
    	mContext = SDL_GL_CreateContext(mWindow);
     
     
    	if(!mContext)
    	{
    		cout << "EXCEPTION: Could not create an OpenGL Context: " << SDL_GetError() << endl;
    		throw Exception(0, "Can't create OGL Context", "Unable to create an OpenGL Context.\n" + string(SDL_GetError()));
    	}
     
     
     
     
    	void* ptr = SDL_GL_GetProcAddress("glDrawArrays");
     
     
     
     
    	SDL_ShowCursor(false);
     
     
    	buildDisplayModeList();
    	initGL();
    	mShaderManager = new ShaderManager();
     
    	int w, h;
    	SDL_GetWindowSize(mWindow, &w, &h);
    	projection = glm::ortho(0.0f, static_cast<float>(w), static_cast<float>(h), 0.0f);
    	view = glm::lookAt(
    					   glm::vec3(0,0,-1), // Camera is at (0,0,5), in World Space
    					   glm::vec3(0,0,0), // and looks at the origin
    					   glm::vec3(0,-1,0)  // Head is up (set to 0,-1,0 to look upside-down)
    					   );
    	model = glm::mat4(1.0f);
    	ModelViewMatrix = projection * view * model;
    }

    This is the image I get when I don't clear the screen and tell the VertShader not to use my MVP uniform:
    Click image for larger version. 

Name:	Screen Shot 2013-02-13 at 11.19.31 PM.jpg 
Views:	43 
Size:	6.5 KB 
ID:	981

    If I use the MVP uniform still without clearing the screen I get:
    Click image for larger version. 

Name:	Screen Shot 2013-02-13 at 11.19.47 PM.jpg 
Views:	47 
Size:	5.2 KB 
ID:	982

    if I don't multiply the view and model from INIT and just send the projection, again without clearing the screen I get:
    Click image for larger version. 

Name:	Screen Shot 2013-02-13 at 11.29.23 PM.jpg 
Views:	44 
Size:	8.3 KB 
ID:	983
    *Note the above image has a background image command commented out so I can see the rest of the calls to draw other things.

    And if I add in a clear screen command at the start of an update, the screen just doesn't seem to have anything on it.

  2. #12
    Alright I actually fixed the flickering finally! However my mouse y-axis is upside down. In OpenGL 3.2 Core how do I invert that?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •