Learn-OpenGLES-Tutorials icon indicating copy to clipboard operation
Learn-OpenGLES-Tutorials copied to clipboard

Lesson One, ported to Kotlin

Open elect86 opened this issue 8 years ago • 18 comments

Hi,

I ported to Kotlin the first Lesson.

If it's fine, I'll go on with the others one :)

elect86 avatar Aug 06 '17 09:08 elect86

Hi,

any feedbacks?

elect86 avatar Sep 20 '17 08:09 elect86

Hi, sorry, I'm not getting emails for any of these for some reason. I'll make a note to review everything and then get back to you.

learnopengles avatar Oct 13 '17 00:10 learnopengles

No problems, thanks! :)

elect86 avatar Oct 13 '17 13:10 elect86

Hi, it generally looks good. Would it be possible to put the implementation under its own folder; i.e. android/kotlin/ ? That way the base lessons would stay in Java and follow the website, and we would have both implementations in parallel without having to add too much complexity to the code itself.

learnopengles avatar Oct 16 '17 15:10 learnopengles

@elect86

I.e. /android/AndroidOpenGLESLessons /android/AndroidOpenGLESLessonsKotlin <-- The Kotlin commits would go here.

There's also another PR that wants to add NDK support so this will help to keep things more separated and self-contained.

learnopengles avatar Oct 31 '17 16:10 learnopengles

Hi, yeah

Sorry but I don't have so much time at the moment, I'll address this asap

elect86 avatar Nov 01 '17 08:11 elect86

No worries at all, it was lingering for quite a while on my side too :)

learnopengles avatar Nov 01 '17 18:11 learnopengles

Hi,

I tried to understand what you asked, so you want me to double all the files at the same level of AndroidOpenGLESLessonsCpp?

Because given the full compatibility between Java and Kotlin in my opinion it wouldn't have much sense since it's possible to implement Kotlin by simply creating a kt file on the same side of java and choose the corresponding render based on preferences.

But if you prefer that way, I can do it anyway

elect86 avatar Nov 14 '17 19:11 elect86

Hi @elect86, it does mean more duplication, but I want the java code to remain in relatively close sync with the site and focused on one implementation which makes it easier for a newbie to pick up. You don't have to duplicate everything, only the lessons you actually ported so in this case that would be only lesson 1.

learnopengles avatar Nov 14 '17 20:11 learnopengles

Basically I want someone looking through or trying to compile the Java project to not have to worry about either Kotlin or the NDK if their environment doesn't support either one for whichever reason (although I'm aware that Kotlin is now "official" :)).

It'd be better to just duplicate only the code and not the resources but I'm not sure right now of a way to do that without complicating the build or requiring users to be aware of those dependencies, so just duplicating everything seems to be the way to isolate things.

learnopengles avatar Nov 14 '17 20:11 learnopengles

I guess then in this case what you should do is simply using different branches:

  • java
  • webgl
  • ndk
  • kotlin

If you are so keen on keeping the java code in close sync with the website and you don't want the user to care about the other 3 options, whatever he chooses, than a branch for each thematic shall be just perfect

elect86 avatar Nov 15 '17 15:11 elect86

Hmm... branching can work but can also introduce its own complexity. I'm fine with the duplication for now! :)

learnopengles avatar Nov 15 '17 19:11 learnopengles

Ok, I'll do as you prefer

I'll be back when I'm done ^^

elect86 avatar Nov 16 '17 10:11 elect86

Nice :) I'll wait for it -- no rush!

learnopengles avatar Nov 16 '17 23:11 learnopengles

Can you create a copy of that? Because I'm not so sure how to do that..

I tried and then I converted the class to Kotlin as I also did in the past, but whenever I try to run it, it crashes without a reason:

Unfortunately, Learn OpenGL ES Tutorial has stopped

Idea doesnt show any error about it.. consoles are clear

Edit: maybe I fixed it..

elect86 avatar Nov 20 '17 21:11 elect86

Oh hmm? Is it OK now?

learnopengles avatar Nov 20 '17 23:11 learnopengles

Do you want me to keep exactly the same names? Or can I rename mModelMatrix to modelMatrix?

Shall I also allocate the matrices just once and reuse or can I allocate new ones every onDrawFrame?

elect86 avatar Nov 21 '17 19:11 elect86

Probably better to allocate the matrices just once and reuse, and the rename is OK with me!

learnopengles avatar Nov 21 '17 21:11 learnopengles