Hi all, I am very new in OpenGL. :o
I already spend more than one day thinking how to resize the texture image in my tutorial and I still cant find any solution.
Anyone here can help me to solve it?
Let me start by explaining a bit about my tutorial.
I am doing a program to display several images, and now I want to know how to set/change the resolution of origin texture image into the resolution I wanted by using the program.
Sorry if the question I asked is a bit to simple and easy… :sorrow:
I read the red book and search the web and i still dont know how?? :sorrow:
Many Thanks All in Advance! :o
If you want to resize it for display purposes, then you simply map it onto a larger surface and let OpenGL do the interpolation.
If you want to get the pixels and save an image smaller or larger than than the one you loaded then you have to implement your own interpolation.
Thanks for replying Budric.
Yea, I want to resize it for display purpose, but I need the textured surface fixed.
What I actually means is,
for an example:
I have an image with 800x600 resolution loaded into the program.
I want to display this image on 2 fixed texture surface. One textured surface is smaller and another one is larger, and I want to know is that any method to make the image resolution automatically change to a smaller resolution(example:320x240) in a smaller textured surface? While on the larger surface, the image remains the original loaded image resolution(800x600) on the large surface.
I want to know how to change the pixels of the loaded image by just using the program. Is there any method to do this?
I have think before on what you mentioned by implement own interpolation i desire and load the image again. But it’s not efficient which need to make 2 diffrent size on the same image and load into the program.
Just load your texture into a GL_TEXTURE_2D target, followed by
This will create a mipmapped texture which contains subsampled versions of the original texture. By setting:
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
OpenGL will automatically calculate the mipmap level to be sampled in order to avoid aliasing.
Thanks for reply NICO.
But I tried Your method, and I keep getting:
error LNK2019: unresolved external symbol…linker error.
Which i already include GL_EXT_framebuffer_object header files.
I searched that EXT are all FBO externals… since I am very new in OpenGL, is difficult for me to understand it so well. Any advise?
another question, is it I no need to use gluBuild2DMipmaps, if I use glGenerateMipmapEXT(GL_TEXTURE_2D);?
is kinda like FBO extentions is another method to do texture mapping?
This is the Linker Errors i Get… :sorrow:
Error 306 error LNK2019: unresolved external symbol _glBindFramebufferEXT referenced in function “void __cdecl init(void)” (?init@@YAXXZ)
Error 307 error LNK2019: unresolved external symbol _glGenFramebuffersEXT referenced in function “void __cdecl init(void)” (?init@@YAXXZ)
Error 308 error LNK2019: unresolved external symbol _glFramebufferTexture2DEXT referenced in function “void __cdecl displayavi(int)” (?displayavi@@YAXH@Z)
Error 309 error LNK2019: unresolved external symbol _glGenerateMipmapEXT referenced in function “void __cdecl displayavi(int)” (?displayavi@@YAXH@Z)
Error 310 error LNK2019: unresolved external symbol _glCheckFramebufferStatusEXT referenced in function “void __cdecl display(void)” (?display@@YAXXZ)
Those are problems relating to use of extensions. I recommend you use one of the extension mapping utilities or get familiar with wglGetProcAddress and extension querying in general.
The way to solve your problem is to draw a quad with the texture on it. You can draw the quad at any size and the image will be resized and filtered in texture hardware.
Use auto generate MIP maps for better quality when you size down.
For non 2^n textures there may be problems unless you have support for non power of two textures and this in turn can interact adversely with MIP map auto-generation. However all these problems are mitigated on newer graphics hardware.
To get an image back of a specific size you could draw it and glReadPixels or glCopyTexImage2@ to texture. Do this first then worry about getting fancy with render to texture etc.
Alternatively use a software image processing library to resize the images you have.
Please don’t flag posts with the moderator to expedite a reply, this is your one courtesy reply, don’t do it again, thanks.