I am looking for a way to create an updating texture from iOS to an OpenGL Context. I have seen Render contents of UIView as an OpenGL texture but this is quite slow, as it requires the whole view to be rerendered every time it changes. This means webviews in particular are hit very hard as the whole page needs blitting around. This breaks animations in web views, and makes everything very static. I was wondering if there is a technique using some other APIs in iOS that would enable a link to be created between view to texture (much like video textures do).
This seems to be a fundamental requirement of OS display composition, but it feels like it always happens under the covers and is not exposed to developers. Perhaps I am wrong!
Bonus points for anyone that can tell me if any other OSes support this feature.
Take a look at RosyWriter sample project form Apple.
It uses CVOpenGLESTextureCache to improve performance of rendering camera frames as opengl textures.
I've encountered a problem whilst learning how to texture in OpenGL (from OpenGL 5th Edition Bible). The problem is that I can't display my texture. I load it from a BMP file with a function I've written myself.
Since code is quite lengthy I uploaded all neccessery files. You can download it from here.
EDIT: I've tried copying code from the mentioned book (TGA loading described there) and it doesn't work as well. It seems that loading stucks at loading image data from file (strange). I suppose it isn't relevant as far as my problem is concern.
There are general debug steps for checking for problems. I will list them below in the hope you might find the bug (and for future readers):
Does the file exist? Is the file being read properly according to the format? Did you get it to gel well with OpenGL? My suggestion: Do not mess with these things yourself. Use a library. There's an amazingly light weight SOIL (Simple OpenGL Image library)
Are you loading the textures before initialising OpenGL? This was always my problem because I used to "load" and do a glBindTexture(..) in the constructor (of some class). The objects were created before OpenGL was initialised.
Have you enabled GL_TEXTURE_2D? Check the initialise code, use: glEnable(GL_TEXTURE_2D)
Did you map the textures properly with the quad or the shape you want it on? Expanding on this here is (sort of) out of scope. There are great tutorials out there.
(Would seem stupid, but happens sometimes) Are you blacking out the object by glColor3f(0,0,0) ?
There could be more checks, but these are the ones hitting my head now
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);)
I'm new to graphics, and I have to make a model of a building for an assignment using only GLUT or OpenGL.
Basically the school building's model( only the exterior portion) is to be made, and I have no clue where to start. Upto now I have drawn polygons, other shapes using GLUT, nothing in which there are multiple shapes. All the drawing upto now is using lines, or points, or polygons and mathematics.
Could you please give me an idea of how to go about it?
Update: I just want to know what steps I can follow to get it done. Some reference links would be awesome!
You could use modeling programs to create your model, and then use tools such as COLLADA to get your model into OpenGL.
The problem with hand-coding a complex object like that is that it takes a great number of lines of code just to define the vertices of the object.
People usually use 3D modeler software to build complex 3D objects, like Maya, 3DSMax or Blender and then export them in a format to be read into your OpenGL application.
Think about what you want your building to look like, and think about what kind of triangles you need to render in order to make that. You can either draw the entire thing in some sort of modelling software, and then import it into OpenGL, or you can come up with the triangles/textures yourself and do it by hand in OpenGL.
The exterior of the building will probably have a similar texture on the whole thing (brick, etc), and then there will be windows, doors, and a roof. Maybe some sort of sign that says "School Building". Take this all into account, what exactly you want your building to look like, and then think about what textures you will need to draw these things.
For example, say you're doing a brick building that is in the shape of a box, with a door and a few windows. I'd use one texture for the brick, and first draw an entire wall of brick. Then, I'd use a grey/blue looking texture for the window, and draw it over the brick wall. Then I'd do the same (different texture) for the door.
Just think about the design, and then just try things out - experiment. Good luck!
I once had a simillar homework. I did it by creating the models with Google SketchUp, then export the models to .3ds file and use my program to render it.
I choose Google SketchUp because it's the easiest to use among those tool I tried. Plus, they had a discount for students. You could also use Blender, which is free but take too much time to learn IMHO. 3dsMax is too expensive to pay for a homework.
To load the model into my program, I used Assimp library.
I am using Cheetah3D if it mattters.
The UV coordinates I am reading in my object made in Cheetah3D are NOT between 0 and 1 like the example model I was provided with the 3DS model object loading code.
Some go above 1 as high as 1.56 or so while others go below 0, as far as -4.56. This is causing extreme abnormalities when trying to map the texture to the object.
Any ideas? Should I contact the Cheetah3D folks or is there a way to fix this in code myself dynamically? (The reason for posting on SO).
Well without seeing screenshots the only thing that comes to mind is that the texture cords should be wrapped but you're clamping them. See the documentation for glTexParameter* on how to change that setting. A screenshot of a SIMPLE model would really help here.