Jump to content
  • Advertisement
Sign in to follow this  
norman784

OpenGL Issues loading textures

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
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?

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites
Posted (edited)
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.

Edited by ChuckNovice

Share this post


Link to post
Share on other sites
Posted (edited)

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

Edited by norman784

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!