Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Alfox

Member Since 17 Mar 2014
Offline Last Active Oct 25 2014 07:17 AM

#5163041 SOLVED: Render a vector to screen in opengl

Posted by Alfox on 26 June 2014 - 11:04 AM

Hi!

This works!! thanks a lot!

this is the update of the previous code:

		glDisableVertexAttribArray(0);
		glDisableVertexAttribArray(1);

		// Render to the screen
		glBindFramebuffer(GL_FRAMEBUFFER, 0);
		glViewport(0,0,1024,768); // Render on the whole framebuffer, complete from the lower left corner to the upper right
		/*---------------------------------------------------------*/
		int size = 1024*768*3;
		std::vector<GLfloat> pix(size);
		glGetTexImage (GL_TEXTURE_2D, 0, GL_RGB, GL_FLOAT, &pix[0]);
		for(int c = 0; c < size; c++){	
			if (pix[c] > 0.5)
				pix[c] = 1.0; //just a little modify for try, the cube should be yellow now (it was green)
		}
		glTexSubImage2D (GL_TEXTURE_2D,0,0,0,1024,768,GL_RGB,GL_FLOAT,&pix[0]);


		/*---------------------------------------------------------*/	
		// Clear the screen
		glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);



PARTNERS