Others have already pointed out problems, potential and verifiable.
But I am surprised no one has mentioned: your settings for glOrtho's
near_val and far_val are odd, to say the least. The default is exactly
the other way around with near_val=-1.0 and far_val=+1.0. Your values
put the near plane behind the viewer, but the far plane in front. Is
this really what you want?

On Aug 2, 8:47 pm, SChaser <crotalistig...@gmail.com> wrote:
> Source code is below.
>
> Robert Green provides some helpful information, for which I am
> thankful.
>
> However, I am not clear on two of the points.
>
>  I currently have the situation where no lines at all show on the
> emulator (the background color does) and things work perfectly on the
> G1.
>
> On Aug 2, 11:26 am, Robert Green <rbgrn....@gmail.com> wrote:
> ....
>
> > 1)  You are in a native resolution to the screen you're rendering on
> > (turn all the density and screen-size stuff on in the manifest to
> > avoid compat mode)
>
> Are these the  attributes on the "support-screens" tag? I did not have
> that tag, but adding it and turning on all the attributes in the check-
> boxes did not solve the problem.
>
> > 2)  You draw the lines centered on their pixel, so they look a half
> > pixel off.
> > -- To draw a horizontal line across the top row of pixels, you need to
> > make the line with 1.0f and have y be 0.5f (because it will draw from
> > 0 to 1 that way)
>
> I am drawing in fixed point projection(?) space, so the relationship
> of the lines to pixels is not clear. Also, I don't want to have to
> redraw the lines when the scale changes - I want to be able to zoom
> and pan easily. Is there a way to achieve that and have the lines
> show?
>
> > 3)  Make sure you don't have any z-fighting.  Drawing 2 things on the
> > exact same plane with depth-test turned on causes bad results on many
> > opengl implementations.
>
> Depth test turned off. I'm doing 2D only, so I think I'm clear there.
>
> Again, thanks for the help.
>
> ============ CODE SNIPS ==============
>
> ----- Create glSurfaceView -------
>   private GLSurfaceView makeGLSurfaceView(GLSurfaceView.Renderer
> renderer, Context context) {
>     GLSurfaceView view = new GLSurfaceView(context);
>     view.setDebugFlags(GLSurfaceView.DEBUG_CHECK_GL_ERROR |
> GLSurfaceView.DEBUG_LOG_GL_CALLS);
>     view.setEGLConfigChooser(false);
>     if ( renderer != null ) {
>       view.setRenderer(renderer);
>       view.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
>     }
>     view.getHolder().setFormat(PixelFormat.OPAQUE);
>     return view;
>   } // make gl surface view
>
> ------------ onDrawFrame ----------
>
> // Everything stuffed into onDrawFrame to make it easy to read on
> forum
>   @Override
>   public void onDrawFrame(GL10 gl) {
>     gl.glClearColor(0,0,.2f, 1f);
>     gl.glDisable(GL10.GL_CULL_FACE);
>     gl.glShadeModel(GL10.GL_FLAT);
>     gl.glDisable(GL10.GL_DEPTH_TEST);
>     gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
>     gl.glMatrixMode(GL10.GL_PROJECTION);
>     gl.glLoadIdentity();
>     gl.glViewport(0, 0, MyApp._width, MyApp._height);
>     gl.glEnable(GL10.GL_BLEND);
>     gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
>     gl.glEnable(GL10.GL_LINE_SMOOTH);
>     gl.glDisableClientState(GL10.GL_COLOR_ARRAY);
>     _hgt2width = (float) MyApp._width / MyApp._height;
>     gl.glOrthof(-_hgt2width, _hgt2width, -1, 1, 1, -1);
>
>     gl.glScalef(1, _hgt2width, 1);
>     gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
>
>     float lscale = .002f*MyApp._curScale;
>
>     gl.glPushMatrix();
>     gl.glColor4f(1f, 1f, 0f, 1f);
>
>     gl.glTranslatef(.375f, .5f, 0f);
>     gl.glScalef( lscale, lscale, 1f);
>     gl.glVertexPointer(2, GL10.GL_FIXED, 0, _lineVertices);
>     gl.glLineWidthx(0x1);
>     drawArrays(gl);
>     gl.glPopMatrix();
>
>     gl.glPushMatrix();
>     gl.glColor4f(1f, 1f, 1f, 1.0f);
>     gl.glScalef( lscale*8, lscale*8, 1f);
>     gl.glVertexPointer(2, GL10.GL_FIXED, 0, _lineVertices);
>     gl.glLineWidthx(0x1);
>     drawArrays(gl);
>     gl.glPopMatrix();
>
>   }
>   void drawArrays(GL10 gl) {
>     gl.glDrawArrays(GL10.GL_LINE_STRIP, 0, 5); //small square
>     gl.glDrawArrays(GL10.GL_LINE_STRIP, 5, 5); //medium square
>     gl.glDrawArrays(GL10.GL_LINE_STRIP, 10, 5);//large square
>     gl.glDrawArrays(GL10.GL_LINE_STRIP, 15, 2);//x axis
>     gl.glDrawArrays(GL10.GL_LINE_STRIP, 17, 2);//y axis
>     gl.glDrawArrays(GL10.GL_LINE_STRIP, 19, 2);//X half
>     gl.glDrawArrays(GL10.GL_LINE_STRIP, 21, 2);//X half
>   }
>
>   void makeLines() {
>     int hlf = 0x08000;
>     int one = 0x10000+hlf;
>     int sml = one/8;
>     int ten = one;
>     int big = 0x40000000;
>     Log.d("===jrm", String.format("one:%x   big:%x", one, big));
>     int vertices[] = {
>        -sml     ,         sml,    //0 start square - scale 1/10
>         sml     ,         sml,    //1
>         sml     ,        -sml,    //2
>        -sml     ,        -sml,    //3
>        -sml     ,         sml,    //4
>
>        -one     ,         one,    //5 start square - scale 1
>         one     ,         one,    //6
>         one     ,        -one,    //7
>        -one     ,        -one,    //8
>        -one     ,         one,    //9
>
>        -ten     ,         ten,    //10 start square - scale 10
>         ten     ,         ten,    //11
>         ten     ,        -ten,    //12
>        -ten     ,        -ten,    //13
>        -ten     ,         ten,    //14
>
>        -big     ,           0,    //15 start coord axes over huge area
>         big     ,           0,    //16
>
>           0     ,         big,    //17
>           0     ,        -big,    //18
>
>        -big     ,        -big,    //19 start X over huge dimensions
>         big     ,         big,    //20
>
>        -big     ,         big,    //21
>         big     ,        -big,    //22
>         ten     ,         one     // BUT? Without this line, blows up
> if openGL debug is enabled
>
>     };
>     this.numLines = vertices.length/2;
>
>     ByteBuffer vbb = ByteBuffer.allocateDirect(vertices.length*4);
>     vbb.order(ByteOrder.nativeOrder());
>     _lineVertices = vbb.asIntBuffer();
>     _lineVertices.put(vertices);
>     _lineVertices.position(0);
>   }

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to