Search the Community
Showing results for tags 'Open GL'.
-
OK back again. Working my way through the API trying to understand what's possible with Gizmo. This time I'm on to the graphics API and open GL drawing. I've got a couple of questions. My main question relates to how to align png images placed in planemaker with Gizmo code generated open gl drawing elements. What I can currently do is have some gl generated text and number elements drawn with font.drawString nicely align in the desired locations within a planemaker png while the screen size window is less than or equal to the panel.png resolution (1920x1080 in this case). I do this by reading the acf file for the png location (yes, I've also been playing with the IO APi too) and formatting the open gl co-ordinates such that the gizmo drawn elements are using the same reference point. The formatting is simple maths to allow for the fact that planemaker and open gl co-ordinates do not directly reference the same point on the screen. What i'm struggling with is when I extend the x-plane window beyond either the 1920, 1080 or both x-plane scales and shifts the panel such that my open gl draws are now no longer aligned with the desired location of the planemaker png. I have tried some simple maths solutions using combinations of screen size and panel size information which improve a little but they don't solve the problem for all window sizes. I have a dual monitor ( 2 x 1920x1200) set-up that i used for this testing. I really would like to get gizmo playing nice with my existing planemaker generated panels. Any idea's on how to make this work? My second question relates to function calls from OnDraw_Gauges(). I tried to call a function that draws a png to the screen from OnDraw_Gauges(), but the png just would not show. However as soon as I put a gfx.drawString into the function the png draws fine (see code below). What's happening here? Also when should I use OnDraw_Gauges() and/or OnDraw_BeforeGauges(). ------file1dofile("file2.lua")function OnDraw_Gauges() draw_imageA()end------file2function draw_imageA() gfx.setColor(0,0,0,1) gfx.drawString("." , 944, 116 ) --call from OnDrawGauges() to draw_imageA() will not draw image without this png_file = "/image_path/Bezel.png" draw_png( 942, 114, 550, 145, 1, png_file ) --draw and place Bezel endfunction draw_png(x, y, width, height, zoom, file) png_texture = gfx.newTexture() local width = width * zoom local height = height * zoom gl.PushMatrix() gl.Translate (x, y, 0 ) gfx.loadPng(png_texture, file ) gfx.useTexture(png_texture) gfx.setColor(1,1,1,1) gl.Begin('QUADS') gl.TexCoord( 0, 0 ); gl.Vertex( 0, 0, 0 ); gl.TexCoord( 0, 1 ); gl.Vertex( 0, height, 0 ); gl.TexCoord( 1, 1 ); gl.Vertex( width, height, 0 ); gl.TexCoord( 1, 0 ); gl.Vertex( width, 0, 0 ); gl.End() gl.PopMatrix()end