*/ 60 private int mTextureUniformHandle Ħ1 62 /** This will be used to pass in model position information. */ 57 private int mMVMatrixHandle ĥ8 59 /** This will be used to pass in the texture. */ 54 private int mMVPMatrixHandle ĥ5 56 /** This will be used to pass in the modelview matrix. */ 49 private final FloatBuffer mCubePositions ĥ0 private final FloatBuffer mCubeColors ĥ1 private final FloatBuffer mCubeTextureCoordinates ĥ2 53 /** This will be used to pass in the transformation matrix. */ 46 private float mMVPMatrix = new float Ĥ7 48 /** Store our model data in a float buffer. This will be passed into the shader program. */ 43 private float mProjectionMatrix = new float Ĥ4 45 /** Allocate storage for the final combined matrix. This is used to project the scene onto a 2D viewport. This matrix transforms world space to eye space ģ8 * it positions things relative to our eye.ģ9 */ 40 private float mViewMatrix = new float Ĥ1 42 /** Store the projection matrix. This matrix is used to move models from object space (where each model can be thoughtģ2 * of being located at the center of the universe) to world space.ģ3 */ 34 private float mModelMatrix = new float ģ5 36 /** 37 * Store the view matrix. */ 26 private static final String TAG = "Test7Renderer" Ģ7 28 private final Context mActivit圜ontext Ģ9 30 /** 31 * Store the model matrix. Note that the GL10 parameter passed in is unused for OpenGL ES 2.0Ģ1 * renderers - the static class GLES20 is used instead.Ģ2 */ 23 public class Test7Renderer implements GLSurfaceView.RendererĢ5 /** Used for debug logs. If they are, then that is most likely your problem, as engineer.jpg might *actually* be named or or whatever else.7 8 import .EGLConfig ĩ import .GL10 ġ8 19 /** 20 * This class implements our custom renderer. Is Windows showing file extensions by default in Explorer for you? If it is *not*, then look at your image files and see if they are. I was about to say if that doesn't work then I have no idea, but then I had an idea. If any or all of that fails, run visual studio as administrator, and find the program executable for your program and change it run as administrator and try to loading one of the images that fails. as 3 or 4 channels and the only thing that matter is how you allocate your textures on the GPU.Īnyway, do you still have a copy of container.jpg that will load correctly? If so, can you try making a copy of it and seeing if the copy will load? If the copy will load, try opening it in MS Paint or anything else, and then just overwriting it with itself, and then try to get it to load in your program again. The number of channels you request be returned in the image data shouldn't matter when it comes to the image type, by which I mean you can have it return a PNG, JPG, BMP, PPM, etc. I assume you're on Windows, and I assume when you say "VS" that you mean Visual Studio, and not VSCode. Std::cout << "Failed to load image: " << failureReason << GlTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, Unsigned char* data2 = stbi_load("engineer.jpg", &width, &height, &nrChannels, 0) Std::cout << "Failed to load image: " << failureReason << std::endl GlTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, data1) Ĭonst char* failureReason = stbi_failure_reason() Unsigned char* data1 = stbi_load("container.jpg", &width, &height, &nrChannels, 0) ![]() Stbi_set_flip_vertically_on_load(true) // tell stb_image.h to flip loaded textures on the y-axis load image, create texture and generate mipmap GlTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR) GlTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR) GlTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT) GlTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT) Here's my code, but just as an fyi I also tried the solution code and had the same problem so I'm not really sure where to go from here.ĮDIT: Forgot to mention this but width, height, and nrChannels all return 0 and data is set to null when an image other than container.jpg is sent to stbi_load. I've tried dozens of other png/jpg files and the only one that does not return null is container.jpg. I've been working through the textbook and I've run into a problem where stbi_load refuses to load anything other than the container.jpg image provided by the online textbook. SOLVED: I made the mistake of adding the files VIA the solution explorer instead of directly adding them to the project files so the imgs were treated as links to the img file locations in my PC's download folder.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |