View Full Version : Help? Yeah Righ!

05-13-2000, 08:15 AM
Is this a help forum or a fudge forum!
If it is a help forumn->

could some one please show me how to draw a subimage with transparent areas on top of another image!

Every time I try using this ****ing code.
The transparent areas turn black instead of showing the image beneath.

glClearColor(0.0f, 0.0f, 0.0f, 1.0f) ;

int x,y;
for(x =0; x < 128; x++)
for(y = 0; y < 128; y++)
Tile[x][y][0] = 255;
Tile[x][y][1] = 0;
Tile[x][y][2] = 0;
Tile[x][y][3] = 255;



glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 128, 128,

glTexSubImage2D(GL_TEXTURE_2D,0,0,0,64,64,GL_RGB,G L_UNSIGNED_BYTE,info[0].Data);
glTexSubImage2D(GL_TEXTURE_2D,0,0,64,64,64,GL_RGB, GL_UNSIGNED_BYTE,info[0].Data);
glTexSubImage2D(GL_TEXTURE_2D,0,64,0,64,64,GL_RGB, GL_UNSIGNED_BYTE,info[0].Data);
glTexSubImage2D(GL_TEXTURE_2D,0,64,64,64,64,GL_RGB ,GL_UNSIGNED_BYTE,info[0].Data);

void COpenGLView: http://www.opengl.org/discussion_boards/ubb/biggrin.gifrawGL()

glAlphaFunc(GL_GREATER, 0.5);
glTexSubImage2D(GL_TEXTURE_2D,0,0,0,64,64,GL_RGBA, GL_UNSIGNED_BYTE,info[1].Data);
glTexCoord2f(0,0); glVertex2i(10,138);
glTexCoord2f(0,1); glVertex2i(10,10);
glTexCoord2f(1,1); glVertex2i(138,10);
glTexCoord2f(1,0); glVertex2i(138,138);


Opengl easier then D3D!
My arsehole!

05-13-2000, 09:13 AM
As far as I know, glTexSubImage2d REPLACE the values of the texture. It is not like multitexturing.

My guess is what your are trying to is some sort of decal. If you want to do that you should look into multitexuring.

Or you could apply a polygon over an another using the stencil buffer to make sure you get no z fighting

05-13-2000, 11:15 AM
Why the f#ck are you so offending?

First of all this is an open forum, so peapole like you could answer questions.
If you are lucky you may get an answer, but there is no rule that you have to get one.

If you had read the spec for the function you are using you would know that it REPLACES the pixel as Gorg just posted to you. If you want to alpha blend your new subimage on the orignal texture, you have to do the alpha blend on your f#cking own.

If you had any idea of graphics in general you would know that.

And this dosen't have anything to do with opengl, you have to do the same in d3d.

You may read the f#cking manual before you ask silly questions and post them into both (beginner/advanced) sections.

I think this was the last time YOU got ANY answers in this forum.

FYI: the alpha value 0 means completly

Get a glue.

05-13-2000, 11:21 AM
I love the arugments of D3D being "easier" than OpenGL

to that I say "Great!"

I bet tracing a picture of Donald Duck is alot "easier" than drawing one yourself...

"easier" does not mean "better"

as soon as people realize this, i think alot of conflict will be dimenished

05-13-2000, 09:46 PM
Originally posted by ironduke:
I have tried it with modulate/decal etc..
with different alpha blending constants but it is always black!

Hey YouPissedMeOff!
Blow Me!

05-15-2000, 04:22 PM
cool. we can resort to insults and bullying to get our way. _very_ mature, ironduke. I shudder to think that one day you might right safety critical software involving trains and people's lives. (I've been there, done that, albeit in a simulation with a toy train in our undergrad course, and it's scary to think what "graduates" are churned out).

read my reply in the same post to the advanced discussion forum.

oh, and try to grow up. it'll make it so much easier for everybody else

05-16-2000, 05:47 AM
Thanx for the tip john, but you didnt answer my question!

Do it NOW!

05-16-2000, 12:10 PM
ironduke, it won't work like that. glTexSubImage2D REPLACE the value of the texture. there is no blending. The replacing is done in memory, not in the framebuffer.

Use multitexturing, or have a second polygon over the first one you make and texture map it with your texture and blend it.

05-17-2000, 07:41 AM
Can't help it. Must reply.

Ya know what... do it in D3D, or figure it out yerself.

An attitude like that, you MUST work for Microsoft.

05-17-2000, 08:09 AM
To Gorg(not the other unhelpful jagoffs)

So what you are saying is gltexsubImage currently doesnt support blending with the texture it is going to be placed on, only blending with the current selected color!

If so Extension please NVidia,SGI!

05-17-2000, 11:56 AM
Sorry ironduke, you wont get any extension for this, 'cause it's a rather useless to alphablend a texture like this. You should use multitexturing.

05-17-2000, 01:16 PM
That's right ironduke, there is no blending done.

And I also don't think there will ever be an extension for that, because there is already one! http://www.opengl.org/discussion_boards/ubb/smile.gif Multitexturing!

Even though Multitexturing seems advanced for what you want to do, it is conceptually the same thing than blending new colors with a texture without using more geometry.

05-17-2000, 01:44 PM
I have heard alot about Multitexturing, but I did not want to use it as I hear many vendors drivers still dont support it!

05-17-2000, 05:55 PM
that's not true. I am not aware of any comme vendor (ATI, NVIDIA, 3DFX, MATROX) that doesn't support multitexturing today.

05-17-2000, 06:09 PM
I may give it a go Gorg if This Idea fails->
The reason I wish to use sub images is to reduce the number of quads by a factor of 4.

Is more images less triangles more efficient?

I am going to manually blend the two images by accessing each byte in a loop and changing that byte if its alpha is a certain value.

does this sound right.

05-18-2000, 12:21 PM
It's going to be slower than multitexuring :

reason : the graphic boards has special instruction to blend a bunch of values together. With your loop, you'll be using the CPU and it's going to be some mov, add, mult intructions(if you know anything about assembly) It's going to be real slow if your texture is big.

The only way you could maybe get the same performance than multitexuring if you do the blending manually is through SSE instructions wich are only on PIII.

My best advice for you is: if you don't want any hassle, just do your loop, but If you want speed, you better go with multitexuring wich is a good technique to learn. You can do a lot of cool stuff with it.

Trust me, multitexuring is worth checking out!

good luck

05-18-2000, 05:47 PM
The thing is gorg i wish to tile each quad 2 by 2 images, when you texture a quad, it either repeats the texture or clamps creating a smear inthe rest of the quad?

The only way around this in multitexturing, is to make a transparent texture in photoshop which is twice the size of each tile, copy my tile to the topleft, then do the same with a new image for the topright and so on?

I hope you get that!

05-18-2000, 06:50 PM
Oh, I see what you want to do. hmm. This should work with glTexSubImage, but I don't see where you want blending tough. Here is what I would do:

1.Create a black 128X128 black Texture.
call glBindTexture on it.

2. Then let's say you have an array(color[4]) of 4 subtexture of with and height = 64 you want to use you call glTexSubImage4 times on that black texture:

glTexSubImage1 : xoffset = 0, yoffset = 128 width = heigth = 64

glTexSubImage2 : xoffset = 64, yoffset = 128,

glTexSubImage3 : xoffset = 0, yoffset = 64

glTexSubImage4 : xoffset = 64, yoffset=64

glTexSubImage replace values from left to right and top to bottom.

Now to use your modified black texture in the code, just call glBindTexture on that texture.

That should do the trick. And yep, for what your are trying to do, doing multitexuring is maybe pushing things a little too much.

I think this is what you tried to do in your code, but there are some weird things in it, like 5 glTexsubImage calls. Try it again with the template I gave you and tell me if it works. If it doesn't I'll try it myself in real code just to see if I haven't overlooked something.

You could still try Multitexturing though, you might still get better performance depending on your card because glTexSubImage2d is not really optimised on all cards. But try with subimage first

05-18-2000, 07:07 PM
The reason I need blending is to place another tile over one of the previous tiles.

I am writig a map editor for Sid Mier's Antietam.

Imagine the corner of each quad is the center of a map square?

its terrain would be in the quads above left/right, below left/right.

The transparency is needed to save me creating dozens of images ie grass with marsh overlayed, wheat with river overlayd and so on.

Do you see?

Thanx for ye help.

05-18-2000, 11:32 PM
Waouhaouahaoauh !

Ironduke, take your pills : you've been almost kind with Gorg and you said "Thank you"......

Are you drunk or what ?!?!?


05-19-2000, 05:34 AM
Originally posted by Eric:
Waouhaouahaoauh !

Ironduke, take your pills : you've been almost kind with Gorg and you said "Thank you"......

Are you drunk or what ?!?!?


Gorg is helpful so he is rewarded with a cookie!

My complaint was not people answering my Q's but being totally unhelpful when they did:P

besides I have saved my obcenities for you!

Stop smoking Crack! Jagoff!

05-19-2000, 05:52 AM
Well, I deserved this one because of my previous post !

http://www.opengl.org/discussion_boards/ubb/smile.gif http://www.opengl.org/discussion_boards/ubb/smile.gif http://www.opengl.org/discussion_boards/ubb/smile.gif http://www.opengl.org/discussion_boards/ubb/smile.gif http://www.opengl.org/discussion_boards/ubb/smile.gif http://www.opengl.org/discussion_boards/ubb/smile.gif http://www.opengl.org/discussion_boards/ubb/smile.gif http://www.opengl.org/discussion_boards/ubb/smile.gif


05-19-2000, 12:12 PM
I see. Multitexure seems like the way to go, but It's a waste of memory to have a transparent part and just a small colored corners.

How to you get the info of the map afteward. Do you just keep the framebuffer?

Explain a little more how you do your conversion and I'll try to help you figure out a more memory friendly solution, if there is one!(there should! http://www.opengl.org/discussion_boards/ubb/smile.gif)

05-19-2000, 02:20 PM
first a few facts.

The max size of the map will be 100 x 100 quads (10,000).

Which is exceptable as fps will only be required when scrolling zooming.

will also require upto 10,000 quads for tree's.

The app will read in 3 text files, all are ascii text, the first provides height in a range of 012345....ABCDEF.

The second text files contains Terrain data
. = grass
R = rocky
r = rocky_trees

The third contains the road network.

fairly standard map editing stuff.

I was planning to use a mapsquare manager class which held an array of mapsquares.
These squares would hold all of the above data.


I was thinking of load all the images into
Byte arrays at start up, I would say there is about 50 images.

I would then texture the heightfield quads inside a dsiplay list as the polys would only change when the user changes the height of a particular square or squares.

I was also thinking of using tessalation when the camera is so far out close detail is unnoticeable.

Does this sound like sense so far?

05-19-2000, 04:46 PM
Yes it does, though I not too sure why you want to split your polygon to fit 4 tiles. Why don't you just make your basic unit 1 poly = 1 tile. You do some culling to get rid of the squares you don't need when you are zoomed in and when you zoom out, you can reduce the precision of the trees and low rez textures.

By the way, don't use a display list for such a huge thing. Use vertex arrays or plain opengl because the display would be way to huge. And it is also harder to do good culling with display list.

What I would do is check the number of squares(and wich squares) that are in the view and just render those. Your data structure can do it. I would use plain opengl for that or you could just make one square in the display list and then call that list for the number of squares you need to render.

Well, that's it, I hope I understand how you tile your map. Just let me know if I am wrong

05-19-2000, 05:21 PM
The reason I have to tile it is that the center of the map square has to be the Point of height for that square, therefore if I did not tile the images I would have to double the quads to get this effect.

ie when you draw a quad the corners are the Y cords not the center of it?

05-22-2000, 10:45 PM
Pourquoi les personnes qui font le plus parler sont celles qui sont les plus détestables?

Maybe you could try to find an awser for that ironduke... http://www.opengl.org/discussion_boards/ubb/eek.gif

05-22-2000, 10:48 PM
Pourquoi les personne qui font les plus parler sont celles qui sont les plus détestables?

Waybe you could answer IronDuke...


05-23-2000, 02:17 AM
Hey french guy, isn't it time to stop picking on ironduke?

05-23-2000, 06:06 AM
Hey french bloke.
you say->

"Why the persons that do the more to speak are the one that are the most detestable ones."

I say

"You make a poor orange sauce!".
"**** tete"

That will scare hime for life!

Why are french roads lined with trees?

So the German Army can march in the shade:P


[This message has been edited by ironduke (edited 05-23-2000).]

05-23-2000, 06:22 AM
i don't think ironduke is detestable, instead i find him original.
maybe we just misunderstood him, and he's playing his part. this topic will enter into history... http://www.opengl.org/discussion_boards/ubb/smile.gif


05-23-2000, 07:41 AM
Are you all people going are going to let a baby like ironduke ruling your life... sheeps...

05-23-2000, 08:24 AM
Mr DoSomething(What a funny name, did your family inherit this name because they where a bunch of Idol B*stards:P)

I am leading no one like sheep Sir!

I was simply angry with my excellently Sh*te openGL skills and took it out on this forum due to the fact people where answering my Q's,but with tosh answer's.

Since this thread started, it has matured into a serious coding thread(Thanx GORG).

It is you who is dragging it back into the toilet, and unfortunately I love a flame or two, so put up your email address and fight like a man or shut up and let the thread die.

I would like to thank everyone who has made this thread an excellent piece of Tosh!

May we all meet up again in another thread somewhere, sometime for a serious mass-debate(good job I split those words, think of the mess:P) and a flame or two.

I thank you! God Bless us one and all!

05-24-2000, 07:28 AM
Originally posted by FindAnHoleAndHideYourSelf:
Pourquoi les personne qui font les plus parler sont celles qui sont les plus détestables?

Waybe you could answer IronDuke...

WHy are they who talk the most, the ones that are detestable?

05-24-2000, 08:39 AM
To Masterpoi!

I already have clown look up the thread

06-14-2004, 06:39 PM
sorry. Duke, u are being very disrespectful to other members. If you are not satisfied with the answers you get, then please, go express your anger elsewhere, for people here, do not go online to listen to you immature, foolish remarks, that clearly demostrate your age. Please, show some respect to the members of this community. It was not made for you, its for everybody, and with that attitude, you actually expect a valuable answer? I personaly think that Gorg has done a big favour for you.

Please. learn your eticket.


06-14-2004, 08:06 PM
why has this thread resurfaced?!

06-14-2004, 08:16 PM
why indeed. looks like it was a stain 4 years ago.