SoftPixel Forum

Official community of the SoftPixel Engine and the SoftPixel Sandbox (REGISTRATION only with consultation with the Admin)
It is currently Fri May 25, 2018 11:10 am

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: GLSL texture to programm
PostPosted: Sat Mar 29, 2014 9:31 pm 
Offline

Joined: Tue Jan 07, 2014 6:38 pm
Posts: 90
Location: Germany
Hello.
Is there a way of binding a texture to a GLSL-Shader, so I can acces it with "uniform sampler2D"?
I mean, as an uniform.

Edit:
Okay, I tried this:
Code:
if (dof_tex->valid())
    dof_tex->bind(1);
shd_dof1->Frag_Shader->setConstant("dof_tex", 1);
//shd_dof1 is a class which contains
//shaderclass,vertexshader and fragmentshader.
//dof_tex is a video::Texture*

The bind-function return a segmentation fault.
I looked over the bind-function, but can't find a mistake.
May it be because of a empty texture?
But I mean, I check the texture with valid().
Also I set the texture as rendertarget before and have rendered into it.


Last edited by coder++ on Sun Mar 30, 2014 7:26 am, edited 1 time in total.

Top
 Profile  
 
PostPosted: Sun Mar 30, 2014 7:25 am 
Offline

Joined: Tue Jan 07, 2014 6:38 pm
Posts: 90
Location: Germany
Ah, I forgot sth. important.
To create the texture.
Is
Code:
texture->setRenderTarget(true);

important to set it as rendertarget, or does it only prevent to be changed via cpu?


Top
 Profile  
 
PostPosted: Sun Mar 30, 2014 9:52 am 
Offline
Site Admin
User avatar

Joined: Sat Jul 07, 2012 5:58 pm
Posts: 540
Location: Germany
The call of
Code:
setConstant("dof_tex", 1)
is correct.
You need to call
Code:
tex->setRenderTarget(true)
, when you want to make the texture to a render target, i.e. you want to render the scene into the texture and not directly onto the screen.

Is the "dof_tex" really not a null pointer at this point?
And what render system do you use?

_________________
My latest project:
- The XièXiè Programming Language

My hardware:
- GIGABYTE GeForce GTX 670
- Intel Core i7 (Ivy-Bridge)
- 16 GB DDR3


Top
 Profile  
 
PostPosted: Sun Mar 30, 2014 10:38 am 
Offline

Joined: Tue Jan 07, 2014 6:38 pm
Posts: 90
Location: Germany
Im using OpenGl, or what do u mean?

And look above, it was a nullpointer and I already fixed it by using renderer->createTexture(...).

Edit: Ops, I havent said before, that I already fixed it^^


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group