Loading a texture in GLM - c++

hey im using GLM(made by nate robins) with SFML and opengl on mingw32 with the IDE as CodeBlocks(windows)
when loading my texture with the GLM from: http://www.3dcodingtutorial.com/Working-with-3D-models/Getting-GLM.html
hey i managed to get rid of the color problem by changing up my code to better load the textures, but now im not able to get the texture to display...
heres the NEW link to my main: http://pastebin.com/gasu1Hux
i have been looking up GLm tutorials but i cant find any correct answers about my texture not displaying at all.....
maybe im missing something?
/////////////////////OLD/////////////////////////////
also i tried the one from devernay.free.fr, but i always get a texture error
(not gonna post because everytime i do, my question gets downed...)
i had gotten a small glitch where my whole model is blue instead of the default gray...
i found out that the GLM library i have doesnt load textures by itself..
so i managed to find a texture loader from 3dcodingtutorial.com
when i load the texture its not put on the model, it just changes its color.
right now im wondering why my model is one single color instead of the texture i setup.
heres some of the code that i used to make the texture and draw the model:
ok heres the main.cpp
sorry wrong paste ._.
the paste has been updated!!
http://pastebin.com/tcwwasb9

The default GL_TEXTURE_ENV_MODE is GL_MODULATE. Make sure you aren't inadvertently setting your color state somewhere, or force the issue with glColor3ub(255,255,255) before you render something with a texture.
EDIT: GL_DECAL is also an option.

Related

Ogre 3D load models created with Easy Ogre Exporter

I'm currently trying to export a .max file to .mesh and it success.
The problem is that I don't have any color on my form (it's a basic cylinder actually).
Easy Ogre Exporter gave me several more files like .scene .material .cg .program. I tried to set this .material to .mesh entity but it's still white.
Please help me, I really searched on the web but found nothing working.
Best regards,
Coucka
If Ogre encounters an issue with your materials / shaders / textures, it usually falls back to a material called "BaseWhite", which might be what you are experiencing.
First step: Check the Ogre.log file to see if the *.material file was loaded at all and if there were any error while parsing it. You should find an entry similar to this one:
23:45:10: Parsing script Test.material
If your material is also using the shader that was written into the *.cg shader file, check that it is loaded as well without any errors, plus check that a valid shader profile was used, that your hardware supports (otherwise you will find a note in the log, telling you that no supported profile was found). The supported shader profiles will also the output into the log file, like so:
23:45:10: * Supported Shader Profiles: hlsl ps_1_1 ps_1_2 ps_1_3 ps_1_4 ps_2_0 ps_2_a ps_2_b ps_2_x ps_3_0 vs_1_1 vs_2_0 vs_2_a vs_2_x vs_3_0
If you are using textures on your model, make sure that the needed texture files can be found by Ogre. To do so verify that all paths from where Ogre should load resources are listed in the configuration file resources.cfg. Also for textures to work, your model of course needs to have exported UV coordinates. If the texture was successfully loaded, the following entry should appear in the log (the types and formats of course could be different):
23:45:10: Texture: Texture.jpg: Loading 1 faces(PF_R8G8B8,256x256x1) Internal format is PF_X8R8G8B8,256x256x1.

LibGDX: BufferedImage into Texture

I'm trying to play videos within a LibGDX application. I've managed to load the individual video frames sequentially into a java.awt.BufferedImage using Xuggler.
Now I'm stuck trying to get that into a LibGDX Texture. Anyone know a way to do this?
I managed to find these two LibGDX files that happen to use BufferedImage's, however can't see how to use this to get my data into a Texture :(
LibGDX JoglPixmap.java
LibGDX JoglTexture.java
as soon as you transformed your bufferedImage to a pixmap just use the Texture constructor passing in a pixmap:
Texture newTexture = new Texture(myPixmap);
There are methods to construct an empty Pixmap and draw onto it. Use this pixmap then as described above
If you are using LibGDX, I have to say that I don't recommend also using BufferedImages (from Java2D), instead you could use a Pixmap, or if you really do need BufferedImages, then I guess you could use ImageIO to save the image to a file, bring the file back in as a texture, then delete the file, but that seems quite hacky and inefficient.

Google sketchup objects transparent in opengl?

I have made two objects in googlesketchup.
link1
.On the link you can see a picture of the model. I just made two rectangles and then used push and pull, later I used paint bucket to paint the textures on.
I export this file as .obj and then imported in opengl. The weird thing is that you can see one object through the other object. There is a picture.
link2
Any ideas how to make the objects non-transparent?
It looks to me a depth test problem.
You can notice it by rotating the model view matrix and you will notice that the transparency will follow an odd behavior.
Try to enable the DEPTH test in your code by adding the following code line:
Using C:
glEnable(GL_DEPTH_TEST);
Cheers
Forgot to enable depth testing? (glEnable(GL_DEPTH_TEST);)

QT and OpenGL how to integrate properly and display a texture

I have a few questions about using them both. At the moment I have a preexisting renderer I'm trying to use with QT and OpenGL.
A few questions are:
How can I get my results to draw in a QGraphicsScene? Is that even the right output to attempt to be using.
With OpenGL I want to be able to load textures and then be displayed in a window? Do I need to coordinate where to draw the texture or can I just say in the centre of a QWidget?
What paramenter would I usually need, I persume I need a Gluint for the texture, and then parameters for the size?
At the moment my results are quite poor, it seems to render something but basically not either in the correct window or not in the window of choice and basically it seems to 'hide' text e.g. hello, I can only see e. Odd I think.
I'm pretty sure this link will help you code with Qt and OpenGL:
http://wesley.vidiqatch.org/03-08-2009/nehe-opengl-lessons-in-qt-chapter-1-and-2
I used this and the NeHe tutorial to code a small Qt/OpenGL application, so all information you need is contained in both tutorials.

Texture Mapping C++ OpenGL

I have read around on this, including Nehe and here for solutions, but I cant find a specific answer.
I am trying to load a a photo, called stars.jpg. I want to make this my background of the scene, by mapping it using uv coordinates, doing it by
glBegin(GL_QUADS);
glTexCoord2f(0,0);
glVertex2f(0,0);
However I am just very confused about how to load the actual textures in, all the calls for
glActiveTexture();
glEnable(GL_TEXTURE_2d);
glBindTexture(GL_TEXTURE);
All they do is confuse me, what do all these mean/do, and in what order am I suppose to put these in, in order to get the stars.jpg to be my background?
Your number-one tool for loading textures in OpenGL is the Simple OpenGL Image Loader (SOIL) library. You just need to pass the filename and some flags and you'll get your texture ID.
Also, you're learning very old and outdated version of OpenGL now - you might want to have a google for newer tutorials or browse the specs whenever you feel ready.
Here's a step by step tutorial on loading textures
http://www.nullterminator.net/gltexture.html
Its important to remember that OpenGL is a state machine, so you have to tell it "I'm going to talk about textures now" that's where the glActiveTexture(); comes in.
Also keep in mind that you will have to load in pixel by pixel the colors from your .jpg (compressed) to your texture array, so either you will need to find a library that will give you bitmap values of your .jpg file or you will need to pre-convert it into a .ppm or a .bmp which will make reading in the values easier.