Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Library : Other (not classified elsewhere) » opengl & tekstures
Re: opengl & tekstures [message #2714 is a reply to message #1853] Sat, 22 April 2006 12:05 Go to previous messageGo to previous message
lindquist is currently offline  lindquist
Messages: 33
Registered: March 2006
Location: Denmark
Member
I'm successfully using the GLCtrl with texturing.

Image img = PngEncoder::New()->LoadImageFile("texture/test.png");
PixelArray pix = ImageToPixelArray(img);

// pixelformat
GLuint chan,fmt,id;
switch (pix.GetBPP())
{
case 24:
	chan = 3;
	fmt = GL_RGB;
	break;

case 32:
	chan = 4;
	fmt = GL_RGBA;
	break;

default:
	Exclamation("Unsupported texture BPP ("+FormatInt(pix.GetBPP())+")");
	return false;
}

glGenTextures(1,&id);
glBindTexture(GL_TEXTURE_2D, id);

glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);

gluBuild2DMipmaps(GL_TEXTURE_2D, chan, pix.GetWidth(), pix.GetHeight(), fmt, GL_UNSIGNED_BYTE, pix.Begin());
return true;


My GLCtrl is slightly modified. First I'm using GLee for easy access to extensions, and second, I have the 'wglMakeCurrent(NULL, NULL);' line commented in GLCtrl::WindowProc.

I also inserted 'wglMakeCurrent(hDC, hRC);' at the end of 'GLCtrl::OpenGL'.

At first I had some issues, but it turned out to be my min filter that was LINEAR_MIPMAP_LINEAR while I used glTexImage2D...

I hope this is of help.

[Updated on: Sat, 22 April 2006 12:12]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: uvs wishes
Next Topic: namespace upp
Goto Forum:
  


Current Time: Fri Jul 18 05:39:30 CEST 2025

Total time taken to generate the page: 0.04887 seconds