PDA

View Full Version : CG + simple texture combine



Bystrov Sergey
01-11-2007, 03:14 AM
I want to do Hardware accelerated JPEG viewer.
Hardware accelerated JPEG viewer - means that video card (not CPU) will be obtain different components of the color( by means of CG) . And I have an opportunity do obtain in 3 different textures. In each texture will be one component of the color.

In simple words (it’s not actually true ) in texture1 I’ll have RED color. In texture2 – BLUE, texture3 – RED. Now I have to create texture4 in witch I have to combine first 3 textures and than draw it. Do you know how can I do it by means of CG ?

I’ don’t know CG at all. And all I need – example of CG code( I know how to do the other). Or could you give me a link on good cg book or forum.

Bruce Merry
01-11-2007, 04:49 AM
The user's manual that is included in the Cg download is reasonable, especially if you're already familiar with GLSL/HLSL. Your fragment program is going to look something like this (might not actually compile...)

uniform sampler2D texture1 : TEXTURE0;
uniform sampler2D texture2 : TEXTURE1;
uniform sampler2D texture3 : TEXTURE2;

float3 main(const float2 texcoords : TEXCOORD0)
{
return float3(tex2D(texture1, texcoords).x,
tex2D(texture2, texcoords).x,
tex2D(textuer3, texcoords).x);
}

Bystrov Sergey
01-12-2007, 03:11 AM
I'm tryin to do what you sad. As a first step i'm trying to draw color texture( i'm loading it with red square). But It does't work. Can you say me what am I doing wrong ?

Here is example of minimum code (http://www.opengl.org/discussion_boards/ubb/ultimatebb.php?ubb=get_topic;f=2;t=021043)

Bystrov Sergey
01-12-2007, 03:37 AM
Sorry It was a stupid question.