Problem displaying font texture (SDL Xcode 4 project) - iphone

The below project of mine works fine with OpenGL on Windows and the Mac but will not work on the iPhone simulator or physical device.
The below link is to an Xcode 4 project containing the usual SDL examples plus an extra one called Rectangles2. I can't get my font characters to appear on the screen - I just keep getting a white rectangle.
Can somebody please have a look and tell me what is wrong with my project?
Please don't be critical of how its coded - I would just like to know what I'm missing to make it work.
Xcode Project
Thanks

I've just been told the problem was my parameter to the glTexImage2D function. The code I borrowed uses some literal values 3 and 4 whatever they are. Anyway, changing these to GL_RGBA has solved my problem.. so I'll have to go and read up on what this function actually does and how it works etc.

Related

xcode 8 auto layout uiimageview problems

I have a Android background and now try to code for iOS.
I use Swift as the language and it works really good so far. Now I am getting some troubles to get my layout to work on different screen resolutions that means different iPhones.
I am using storyboards for my ViewController and for now everything worked well except getting UIImageViews to look the same on each iPhone.
I tried now for 2 whole days with dozens of different approaches to get my layout work, but without any success. If I place a single UIImageView on my layout I am able to set the constraints so that it looks the same on each iPhone. Once I place a UIImageView on top of my first UIImageView it destroys everything. I won´t tell you here what I already tried, because it was a lot and nothing worked for me.
I need really some hint or just someone who could just try it on his Storyboard and tell me how he achieved it to get it work. I am using Xcode 8.2.1.
This is how it should look like (iPhone 7):
This is how it looks on a iPhone 4s --> wrong! Proportions are not the same!
It's need more params and maybe UIStackViews.
https://github.com/OMGHaveFun/exampleAutolayout

XCode 6 Storyboard UI depiction does not translate to what's seen in simulator

I'm currently learning Swift as well as XCode 6 and have been following this tutorial on creating a Tip Calculator. I believe I have followed the tutorial on point, since I have downloaded the example project file and compared it to my own and don't see any differences.
However, whenever I run the iPhone simulation on the provided example project compared to my own project, there's a striking difference in how the content is displayed on the simulator vs. the storyboard - things get cut off, don't appear, wrong location, etc.) :
-how the storyboard looks like --
I searched through Stack Overflow and have tried the following - cleaning the rebuild folder, 'resolve auto layout issues', unchecking 'auto layout', refreshed constraints in order to insure that it was running the correct files after editing. Those helped adjust the simulation to look as close as possible to storyboard, but now I am not sure what to do. I also tried changing the width to 'compact' and kept height to 'any' but still to no avail.
And it doesn't seem to be just this project, any project I create using storyboard - even as simple as dragging and dropping labels doesn't seem to correlate properly. I feel like I'm missing something stupidly fundamental, but I can't figure out what.
So my question is as an XCode newbie -
1.) What is the purpose of keeping the simulation to all 'inferred' size/orientation/etc. if it won't translate properly to any of the different simulation types? - iPhone 6 looks quites different from the iPhone 4 simulations and more. Shouldn't the iOS's point system make what I do in storyboard dynamic so as to transpose properly onto any iPhone?
2.) Is there some specific action I should be taking to make what I see on the storyboard translate properly to the simulator?

OpenGL ES sprites no longer render after updating to iOS 7.1

I am using a simple 2D sprite class based on this tutorial to render PNG bitmaps to the screen:
http://www.raywenderlich.com/9743/how-to-create-a-simple-2d-iphone-game-with-opengl-es-2-0-and-glkit-part-1
Everything worked fine on both my iPhone 4S running iOS 6.1 and my iPhone 5S running iOS 7. Since I updated to iOS 7.1, and on my MacBook Air updated to Mavericks and XCode 5.1, sprites no longer appear on the screen (I just get an empty white screen, which is the color I cleared the background to). When I build the app using XCode 5.1 and run on my iPhone 4S again, it still works.
Does anyone know what could be causing this? Has anyone run into this issue? I am having trouble getting to the source of the problem due to my lack of understanding of OpenGL ES among other things. :) My sprite class is exactly the same as the one in the tutorial.
Let me know if more details/code snippets are required.
I'm not even going to look at the sample code since it doesn't sound like it's the same as your current code. (You said 'based on'.) But I'll tell you how to find your problem.
First, clear to something other than white (like red) as a test.
If the screen turns red you at least know that your view and context and open gl in general is working. That knocks out a lot of possible culprits.
Second.. use the debug tools and chances are it will take you right to your problem. You have to run on a tethered device though and not the sim. Run your app...
Click on FPS in the debug navigator. Then click analyze and be patient. It will take a one frame snapshot of whats happening in open gl. It has to do a bunch of stuff to make that happen and it takes about 30 seconds. But then you'll have an interactive thing that shows you the frame and will let you step through processes and see what code is making that happen, and the frame as it draws each element. It's super cool actually. And probably it will show you an error message (in red).
My guess is that it's no longer loading your sprite images. Something probably changed between 6 and 7 or the versions of Xcode or of OSX. In that case the screen is blank because they're not loaded and therefore not being drawn.
EDIT:
I think the analysis will help find your problem. But to offer more possibilities, in my experience when nothing is drawing it's often one of these things:
An overall OpenGL issue - set your clear color to red or blue to test.
Shader didn't compile - always output shader compile errors so you know.
Bad Shader math or logic - use gl_FragColor = vec4(0.0,0.0,1.0,1.0) or some contrasting color to test. Can you see your structures?
Program isn't getting an attribute. Did you remember glEnableVertexAttribArray
Program isn't getting a uniform. Use the Analyze feature above to check the uniform values to make sure they made it to the shader.
(i'll add more if I think of them)
When stuff does

Using Phonegap Barcode Scanner on Iphone

I'm trying to add a barcode scanner to a JQM phonegap project for iOS. I have followed the instructions listed, although I'm not 100% sure if I did the first and last steps correctly.
Copy the .h, .cpp and .mm files to the Plugins directory in your
project. You may need to set the compile options for
zxing-all-in-one.cc to turn off optimization.
I directly copied the three files into the plugins folder in xcode. It isn't giving me any errors, but it also isn't working. I have no idea how to do compiler options in xcode, so I haven't done the last step.
Currently my app still runs with no errors and running the scan function opens the camera with the ui for the barcode scanner up. The problem is that it doesn't seem to be either looking for or finding barcodes, it just stays up and does nothing (until you hit cancel, then it displays the cancelled message correctly).
Anyone have any ideas what's wrong or where I should look?
If the camera is turned on and the UI for scanning appears on the screen, then it means you've done everything right. The problem seems to be that the scanner doesn't detect the barcodes.
Be aware that recognizing 1D barcodes ("classical" barcodes) with zxing require an iPhone with autofocus lens (iPhone 4 or iPhone 4S). 1D barcodes are a little tricky to detect with mobile phone lenses, you need proper light and focus ; that's one reason why 2D codes like QR code where invented.
Try generating a QR code with http://zxing.appspot.com/generator/, display it on the screen and try scanning it with your app. If it works then good news, everything is OK, but bad news, your phone is not fit for 1D barcode scanning.
Another explanation for this behaviour are compiler flags. As mentioned on BarcodeScanner wiki, you may need to set the compile options for zxing-all-in-one.cc to turn off optimization.
In XCode4, click on your project, then select your target under Targets, go to Build Phases->Compile Sources, select zxing-all-in-one.cc and enter -O0 (that's dash oh naught) into the Compiler flags column.
That solved it for me.

IPhone simulator vs. Device issue (open GL)

I am developing an iPhone application using openGl ES 2.0, and after a lot of testing in the simulator I installed the application on my iPhone(3GS) to see how well it preformed. When the app launched it started up fine with no errors, but nothing showed up, however the background was the appropriate color.
Does anybody have any ideas/pointers about what might be causing this issue? If code/details would help just let me know what section of code you would like to see.
Check the constraints on various functions you may use. For example, by default the width and height for glTexImage2D must each be powers of 2 (or powers of 2 plus 2, if you are using a border). There is an extension that allows for non-power-of-two textures, but in my experience this extension is not present or is not completely implemented on at least some devices (i.e. it works for GL_CLAMP_TO_EDGE but not GL_REPEAT).
The Device is strict about case-sensitivity in filenames -- check to make sure that if you are loading Shaders, that the filenames referenced in your code are identical to their actual filesystem names.
Also, if you are in xCode 4, go to your Target Build Phases settings and make sure all of the shaders you use are in Copy Bundle Resources.
Finally, if the shaders appear in 'Compile Sources', you should remove them from there. You'll need to Clean your project and then re-build.