DGL
https://delphigl.com/forum/

TextSuite problem - text visible but nothing else
https://delphigl.com/forum/viewtopic.php?f=19&t=11544
Seite 1 von 1

Autor:  SpaM [ Mo Jan 16, 2017 07:35 ]
Betreff des Beitrags:  TextSuite problem - text visible but nothing else

Dear DelphiGL community.

Can you help me with one TextSuite problem (http://www.dev-center.de/projects/textsuite). This tool is easy to implement but when I call text drawings, my whole 3D models (created before and after) dissapears. I can see only text generated by TextSuite but background is black all over the screen. But Camera movement and rotation works.

I will try to type out my OpenGL code below:

Code:
  1.  
  2. > START OF THE RENDERING
  3.  
  4.   if (CanvasWidth <> Canvas.ClientWidth) or (CanvasHeight <> Canvas.ClientHeight) then ReCreate;
  5.   ActivateRenderingContext(DC, RC);
  6.  
  7.   SetAntiAliasing;   // ON
  8.   SetBlend;           // ON
  9.   SetDepthTest;     // ON
  10.   SetFaceCulling;   // ON
  11.   SetLights;          // ON
  12.   SetFog;             // OFF
  13.  
  14.   glClearColor(r, g, b, w); // BLACK COLOR
  15.   glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
  16.  
  17.   glLoadIdentity;
  18.  
  19.   // CAMERA
  20.   gluLookAt(CameraPosX, CameraPosY, CameraPosZ, CameraPosX + CameraViewX, CameraPosY + CameraViewY, CameraPosZ + CameraViewZ, CameraUpX, CameraUpY, CameraUpZ);
  21.  
  22.   // SCENE
  23.   glRotatef(RotateZ, 0.0, 0.0, 1.0);
  24.   glRotatef(RotateY, 0.0, 1.0, 0.0);
  25.   glRotatef(RotateX, 1.0, 0.0, 0.0);
  26.   glTranslatef(TranslateX, TranslateY, TranslateZ);
  27.   glScalef(ScaleX, ScaleY, ScaleZ);
  28.  
  29.   // SAVE FOR LONGER USE
  30.   glGetDoublev(GL_PROJECTION_MATRIX, @ProjectionMatrix);
  31.   glGetDoublev(GL_MODELVIEW_MATRIX, @ModelViewMatrix);
  32.   glGetIntegerv(GL_VIEWPORT, @ViewPortMatrix);
  33.  
  34. > DRAWINGS SOME 3D OBJECTS
  35.  
  36.   //DRAWINGS TEXTSUITE TEXT
  37.   tsTextColor3f(r, g, b); // RED COLOR
  38.   glDisable(GL_LIGHTING);
  39.   glPushMatrix;
  40.   glTranslatef(v.X, v.Y, v.Z);
  41.   tsTextOutW(PWideChar(WideString(text)));
  42.   glPopMatrix;
  43.   glEnable(GL_LIGHTING);
  44.  
  45. > DRAWINGS SOME 3D OBJECTS
  46.  
  47.   SwapBuffers(DC);
  48.  
  49. > END OF THE RENDERING
  50.  
  51.  


Thanks for help!
SpaM

Autor:  Lord Horazont [ Di Jan 17, 2017 08:46 ]
Betreff des Beitrags:  Re: TextSuite problem - text visible but nothing else

Are your objects using textures?

If they are not using textures, it is possible that the text suite enables texturing and it stays enabled after the textsuite finishes. In that case, texturing would still be enabled for your objects, breaking their rendering. Try disabling texturing after textsuite finishes drawing.

best regards,
Horazont

Autor:  SpaM [ Di Jan 17, 2017 09:44 ]
Betreff des Beitrags:  Re: TextSuite problem - text visible but nothing else

Lord Horazont hat geschrieben:
Are your objects using textures?

If they are not using textures, it is possible that the text suite enables texturing and it stays enabled after the textsuite finishes. In that case, texturing would still be enabled for your objects, breaking their rendering. Try disabling texturing after textsuite finishes drawing.

best regards,
Horazont


That was it!! Thanks!! ... at this moment I can see all scene with text. But text is drawn in small quads (see picture attached). Because I never use textures in OpenGL I am totally lost. Can you please help me with this too?

Thanks!

Dateianhänge:
example.png
example.png [ 32.42 KiB | 8404-mal betrachtet ]

Autor:  Lord Horazont [ Di Jan 17, 2017 19:29 ]
Betreff des Beitrags:  Re: TextSuite problem - text visible but nothing else

The texture of the quads has an alpha channel (transparency), but it is not applied (correctly).

You should read about blending, specifically how to enable it and the aspects of transparency sorting.

If you have follow-up questions, feel free to open a new thread :).

best regards,
Horazont

Autor:  SpaM [ Mi Jan 18, 2017 08:01 ]
Betreff des Beitrags:  Re: TextSuite problem - text visible but nothing else

I finally made it. Problem was I draw text in middle of whole rendering. If I render text at the end, all work perfect.

Thank you!

Seite 1 von 1 Alle Zeiten sind UTC + 1 Stunde
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/