Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Bagpuss

OpenGL OpenGL and Textures

This topic is 5742 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

Lo, I am struggling with a simple MFC program using Open GL. (All I am trying to do is draw an Isometric grid of tiles, using a combination of NeHe code, and MFC Tech Net Code. I did get this working on my laptop, but then it Was assigned to another engineer whilst I was away, and reformatted (Damn Tech Support, just ''cos VC++ wasn''t an approved program on that machine! ) Anyway, below is the Code that sets up the View, can anyone see whats wrong with it ? All I get is a block of blue squares, drawn in the correct place and with the correct rotation. The 2 Textures are 24 bit bitmaps, and are 64 pixels / side. The Initialisation code (at this point, the frustrum and main transform are glOrtho(0,m_WindowWidth,0,m_WindowHeight,0.0f, 10.0f); glTranslatef( 0.0f, 0.0f, -10.0f );
  
BOOL CTileEngine::InitializeOpenGL(CDC* ptrDC)
{

	m_pDC = ptrDC;

    if ( NULL == m_pDC ) // failure to get DC

        {
		::AfxMessageBox("Couldn''t get a valid DC.");
        return FALSE;
        }

    if ( !SetupPixelFormat() )
        {
		::AfxMessageBox("SetupPixelFormat failed.\n");
        return FALSE;
        }

    if ( 0 == (m_hRC = 
        ::wglCreateContext( m_pDC->GetSafeHdc() ) ) )
        {
		::AfxMessageBox("wglCreateContext failed.");
        return FALSE;
        }

    if ( FALSE == 
        ::wglMakeCurrent( m_pDC->GetSafeHdc(), m_hRC ) )
        {
		::AfxMessageBox("wglMakeCurrent failed.");
        return FALSE;
        }

	glEnable( GL_TEXTURE_2D );
	glShadeModel(GL_SMOOTH);
	glClearColor(0.0f, 0.0f, 0.0f, 0.5f);

	glClearDepth(1.0f);
	
	glDepthFunc(GL_LEQUAL); 
	glEnable(GL_DEPTH_TEST); 

	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);

	//blending

//	glColor4f(0.0f, 0.0f, 0.0f, 0.5f);

//	glBlendFunc(GL_SRC_ALPHA,GL_ONE); 


#ifdef _DEBUG
	UINT glErrorCode = 0;
	glErrorCode = glGetError();
	TRACE("Initialising Open GL = %d\n",glErrorCode);
#endif

	LoadGLTextures();

    return TRUE;
}
  
The actual texture loading code is generic NeHe with no modifications, as is the drawing code at present. Any help would be appreciated, Bp.

Share this post


Link to post
Share on other sites
Advertisement
Couple of questions then.

Did you try the code or does it just look ok ?

(I can''t see any reason why it won''t run either !)

Do you know anywhere I can get a couple of 64 * 64 tiles that definitely work, so I can check it isn''t my tiles.

Do you know anywhere I can get a sample MFC program configured to draw in glOrtho that I can compare with mine ?

I am new to OpenGL, is the setting of glOrtho and glTranslateF correct before I call the initialisation code ?

Any other things I can check out to see what is wrong ?

TIA,

Bp.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!