OpenGL ES Render Texture from PNG to Screen not working correctly OpenGL ES 3.0

Recommended Posts

How to set those renderstate ?

Expected result is that png in attach files.

A square round courners (color bright blue).

Share on other sites

Ok, i think you have Z-fighting problem.

1) You can set different Z coordinates for texture/font(additional uniform variable for vertex shader,  0.5 - for text, 0.0 - for texture) or use glPolygonOffset function.

2) also you can use glBlendFunc with Z-Write Disable.

Share on other sites
Posted (edited)
31 minutes ago, Andrey OGL_D3D said:

You can set different Z coordinates for texture/font(additional uniform variable for vertex shader,  0.5 - for text, 0.0 - for texture) or use glPolygonOffset﻿ function.

I'm not sure to correctly understand this method. Should I add a glPolygonOffset(0,0) before the draw ?

31 minutes ago, Andrey OGL_D3D said:

also you can use glBlendFunc﻿﻿ with Z-Write Disable.

I have those two lines that make work the font rendering.

glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

Should I add an other glBlendFunc ? Which one exactly ?

Maybe it could be the ALPHA problem ?

Please, I need some clarifications about those steps on my code, thank you!

EDIT:

I added those two lines on the init() but nothing changed :

glDisable(GL_DEPTH_TEST);
glDepthFunc(GL_NEVER);

Edited by DevAndroid

Share on other sites
6 hours ago, DevAndroid said:

I'm not sure to correctly understand this method

const char           gVertexShader[] =
"#version 320 es\n"
"layout (location = 0) in vec4 vertex;\n"
"out vec2 TexCoords;\n"
"uniform mat4 projection;\n"
"uniform float z;\n"
"void main() {\n"
"  gl_Position = projection * vec4(vertex.xy, z, 1.0);\n"
"  TexCoords = vertex.xy;\n"
"}\n"

Cluster::printTexture
{
glUniform1f(uniformHandleZ, 0.0f);
}

Cluster::printText
{
glUniform1f(uniformHandleZ, 0.5f);
}

// Order Rendering
printTexture(...)
printText(...)

Also you should consider order rendering of texture/text

Share on other sites

Hello Andrey,

I tried this code and it seems that I have no display at all now...

16 hours ago, Andrey OGL_D3D said:

" gl_Position = projection * vec4(vertex.xy, z, 1.0);\n"

"This line is setting the texture coordinates to be the same as the vertex coordinates. So if you're drawing a quad at (96,96) to (128, 128), then your texture coordinates will be (96, 96) to (128, 128). But since you're using the GL_TEXTURE_2D target, the texture coordinates should be normalized. Otherwise, you'll be seeing just the edge color of the texture repeated across the quad. That probably not what you want. You probably do want to use 0-1 as the texture coords in both x and y directions."

What do you think? Should I just modify the way I put my vertices and it will resolve the problem ?

Share on other sites

Ok, Again it is my mistake:

"#version 320 es\n"
"layout (location = 0) in vec4 vertex;\n"
"out vec2 TexCoords;\n"
"uniform mat4 projection;\n"
"uniform float z;\n"
"void main() {\n"
"  gl_Position = projection * vec4(vertex.xy, z, 1.0);\n"
"  TexCoords = vertex.zw;\n﻿"
"}\n"

Share on other sites
Posted (edited)

Still nothing... I'm not even able to get back this result ...

On 5/23/2018 at 1:15 PM, DevAndroid said:

In attach you'll see what's the result. I expect a full blue square in the middle like the png is but it's not. (But position is correct, that's a good point)

Here you'll find the details of what I'm doing.

Thank you so much for your patience... I'm not that good in OpenGL. I'm still learning

Edited by DevAndroid

Share on other sites
printText()
{
...
...
}
printTexture(
{
...
...
}

printAll()
{
printText...
printTexture...
}

It's time to try to create simple project for Windows :)) and attach it to github  !

Share on other sites

Yes ok I'll try, I'll keep you in touch if I find a solution Thank you !!

Create an account

Register a new account

1. 1
2. 2
Rutin
21
3. 3
4. 4
frob
13
5. 5

• 12
• 9
• 9
• 17
• 21
• Forum Statistics

• Total Topics
632601
• Total Posts
3007345

×