Only getting one pixel of a texture [Windows]

For my project I need to create a plugin for Unity3D to render into an another window the exact same thing than the in-game rendering of the editor.

I use the same OpenGL context than unity, however the window context is different.

I use the GetNativeTextureID() in the Unity c# environment to get the texture ID. In the C++ plugin code a full screen textured quad is draw show the texture into the plugin generated window.

My problem is that I can only see one pixel of the texture. I was wondering which states of OpenGL could cause that? Maybe it’s because I use a different OpenGL version?

Thats my OpenGL code:

Thanks for any help =)


                // Start Rendering into the plugin window
		window->setContextToWindow();


		glViewport(0,0, config->getWidth(), config->getHeight() );

		glEnable(GL_TEXTURE_2D);
		glDisable(GL_LIGHTING);
		glDisable(GL_CULL_FACE);

		glClearColor( 0.5f, 0.5f, 0.5f, 0.0f );
		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
		glDisable(GL_DEPTH_TEST);

		glMatrixMode(GL_TEXTURE);
		glLoadIdentity();

		glMatrixMode(GL_PROJECTION);
		glLoadIdentity();
		gluOrtho2D(-1.0f,1.0f,-1.0f,1.0f);

		glMatrixMode(GL_MODELVIEW);
		glLoadIdentity();
		
		glBindTexture(GL_TEXTURE_2D, textureIndex_);

		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
		glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
		glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
		glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);

	
		glPushMatrix();

 		glBegin( GL_QUADS );
 			//glColor3f(1.0f,1.0f,1.0f);
 			glTexCoord2d(0.0f, 0.0f);glVertex2f( -1.0f, -1.0f );
 			glTexCoord2d(1.0f, 0.0f);glVertex2f( 1.0f, -1.0f );
 			glTexCoord2d(1.0f, 1.0f);glVertex2f( 1.0f, 1.0f );
 			glTexCoord2d(0.0f, 1.0f);glVertex2f( -1.0f, 1.0f );
 		glEnd();
		glPopMatrix();

		if (!SwapBuffers( window->getHdc() ))
		{
			int error = GetLastError();
			cout << "Cant swap buff: " << error << endl;
		}

		// Continue rendering into the Unity Editor
		window->setContextToExtern();

Even if I create and apply my own texture on the quad it shows only one pixel of the texture. If I test the same code on my own executable it works perfectly.

Double-check your viewport dimensions, and ensure that you don’t have scissor enabled seem to be the first 2 places to look.

I forgot to say that the pixel is being rendered on the entire quad(The entire screen). It’s like OpenGL is setting the same texture coordinate for all the vertices.

I resolved my problem! I wanted to verify the texture coordinate using a shader. I found that the texture coordinate looked ok in the color output of the fragment shaders. and I decided to use a shader to output the texture. It worked. There was something in the Unity context that was preventing opengl to use texture coordinate without a shader.