Skip to main content
GameDev.net gamedev.net
🔒 Locked

Issues loading textures

Started by norman784 Jun 12, 2018 at 11:04 AM 5 replies 1.4k views
Original Post
norman784
norman784

I'm having issues loading textures, as I'm clueless on how to handle / load images maybe I missing something, but the past few days I just google a lot to try to find a solution. Well theres two issues I think, one I'm using Kotlin Native (EAP) and OpenGL wrapper / STB image, so I'm not quite sure wheres the issue, if someone with more experience could give me some hints on how to solve this issue?

The code is here, if I'm not mistaken the workflow is pretty straight forward, stbi_load returns the pixels of the image (as char array or byte array) and you need to pass those pixels directly to glTexImage2D, so a I'm missing something here it seems.

Regards

ChuckNovice
ChuckNovice
9 hours ago, norman784 said:

if someone with more experience could give me some hints on how to solve this issue?

I would like to help but you haven't described anything about the issue that you're having nor the code that lead to this issue. The code that doesn't work is not the tutorial that you linked, right?

norman784
norman784

Sorry I was not not clear, and yes, I'm porting the opengl tutorial to kotlin native, so the link that leads to github is my code that is not working, well the expected result is the next image as the rectangle texture


logo.png.e4192b84bfdcc5c0e057307a6dd5776e.png


But the result that I'm having is this

1259763347_ScreenShot2018-06-13at11_44_14AM.png.585bd6c527648937b3d286789c1d4246.png

I'm not sure if is stbi_load, my image or the opengl code. But I'm doing some more test, this time in C (it will took me a while because I'm not used to C, besides is not that hard, the I don't know the tools).

Why I chose stb? because seems to be an easy to include a single header library into the projects, but if theres another recommended alternative to this library I'll try it.

norman784
norman784

Ok, I get it work on C, so is matter of time when I find the issue in the Kotlin side.

ChuckNovice
ChuckNovice
4 hours ago, norman784 said:

Ok, I get it work on C, so is matter of time when I find the issue in the Kotlin side.

From what I understand "Kotlin" is simply a library used to parse and retrieve the pixel data of image files (png, jpg etc...).

Since the result you get is a solid color I would suggest manually inspecting the byte array of data that it returns. It will be very easy to see if you see the same pixel data repeated over blocks of 4 or 3 bytes. If that's the case then the issue is indeed the image loading part with that library.

norman784
norman784

Well I finally solve it, and no, Kotlin in a language that has interoperability with C, so in some cases the interop adds odd stuffs and also because is in early development (Kotlin native itself) doesn't have so much documentation about the matter.

For some reference about how it was solved check this issue.

Edit: this is the final result I was looking for

923782673_ScreenShot2018-06-13at7_13_19PM.png.f722cbb87654d920c94c4125b78abcc4.png

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.