Android Question OpenGl problem

GiovanniPolese

Well-Known Member
Licensed User
Longtime User
Hi. I have a situation for which I cannot make any test program, so it will be just "teoretical" question. I have done an App using OpenGL. Besides the "little" problem that I cannot use debugger and OpenGL to see the data, I have another weird problem. I am using a Panel to display Maps with OpenGL. On this panel, I have put some labels. I use some of them just to display the results of some calculations. These labels are set initially "Not Visible" and "not enabled" in the Designer. As a matter of fact, the data that they must display depend on cursor position: if cursor is in determinate positions, perhaps these data have no sense and the relative label must not appear. Ok. I could display them empty, but this is not the matter. In fact I am forced to do it, and it works: I have put a button "Activate labels" and, when I click it, they are set Visible,Enabled and BringToFront, even if the cursor position is such that it is nonsense to display them empty. No problem working in this way. Instead, the question is another: same activation cannot be done "dynamically" while I am moving the cursor. In fact I get, in this case:

android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.

Resuming:
1) Labels invisible and inactive initially
2) Labels activated by a Button: they are shown empty and display data when cursor is in determinate positions.
3) Labels activated directly when the cursor moves: crash

With debugger, despite not seeing the image .. both cases work and labels may be actvated dinamically.. Attach more log lines, for experts.. Maybe I miss something ..
Thanks for reading
 

Attachments

  • log.txt
    1.4 KB · Views: 95

MasterGy

Member
Licensed User
Hello ! If you want to write values and images over opengl, then this will be fine. This is how I managed to solve drawing over opengl, I show the sequence.

drawing over opengl:
Sub Activity_Create(FirstTime As Boolean)


'correct initialization in order (opengl, canvas, orientation, gesture) -------------------------


        Activity.Initialize("")
    orientation.StartListening("Orientation")
    
    canvasfresh.Initialize("canvasfresh",300)  '<-------  canvas redraw frame rate
    glsv.Initialize(glsv.RENDERMODE_WHEN_DIRTY, "glsv")
    Activity.AddView(glsv,0 ,0,100%x,100%y)
    
    pnl.Initialize("pnl")
    pnl.Tag = "pnl"
    gest.SetOnTouchListener(pnl, "pnl_gesture")
    Activity.AddView(pnl, 0, 0, 100%x, 100%y)
    
    gamecanvas.Initialize(pnl)



'Turns on opengl and canvas -------------------------------------------

    dosetup = True  'opengl on
    canvasfresh.enabled = True  'draw to canvas on


'from here you can draw on the canvas ('gamecanvas'), and opengl will be visible below it, from example ------------------------

        rect2.Initialize (0,0,Activity.width*.5,Activity.height*.5)
    gamecanvas.DrawBitmap(intropic ,rect2)
    gamecanvas.invalidate
 
Upvote 0

GiovanniPolese

Well-Known Member
Licensed User
Longtime User
To be sincere, this is not my problem. My problem is that i cannot display some labels created by Designer and set initially as invisible, while i move the cursor in a panel where I display a map drawn with openGL. I resolve this problem activating the labels (i.e. setting visible and enabled) by a button. They appear empty and after they display the calculated values thar depend on cursor movements. The idea was to activate the labels without pressing any button, just on the fly, during cursor movements. Anyway thank you and your suggestion may be useful, because, at the end, describe a similar situation. Thanks
 
Upvote 0
Top