Using TexturedPoly with OpenGL. Can someone help?

BlitzMax Forums/BlitzMax Programming/Using TexturedPoly with OpenGL. Can someone help?

Sokurah(Posted 2010) [#1]
I've had a lot of use from the TexturedPoly module below, and it works fine in both Windows (using dx7 drivers) and natively on OSX.

However, I can't compile it for OpenGL on Windows and that annoys me.
Can someone help me out by tweaking it so it will?

I've included all that's needed here;

> A small test program. If you comment out the 2 GLMax framework lines at the top it will compile on Windows without any problems.
> The TexturedPoly module
> The graphicsfile needed. Get it >here< (right-click and save).

A small testprogram



The TexturedPoly module. Save as 'texturedpoly.bmx'.



slenkar(Posted 2010) [#2]
by the looks of things you want to create colored lines (with vertex colors)

I have a opengl max2d renderer which could do that,

http://www.blitzbasic.com/codearcs/codearcs.php?code=2612


all you would have to do is change the drawline function to accept and use color values, if you are interested i will change it myself.
Just give the word.

I have no experience with the texturedpoly module and i cant use directx either though, sorry.


ImaginaryHuman(Posted 2010) [#3]
Why in your textured poly module, near the top, do you have a ? on a line by itself after the ?Win32 line? Also are you missing some other blitz file that's needed to make GL work? Have you tried taking out all the import lines and just doing a large build?


N(Posted 2010) [#4]
Why in your textured poly module, near the top, do you have a ? on a line by itself after the ?Win32 line?
I would assume he's got that there to terminate the ?Win32 block.


Sokurah(Posted 2010) [#5]
by the looks of things you want to create colored lines (with vertex colors)

The idea not just to make colored lines - the idea is to make neon-like lines like I've done in this game; http://tardis.dk/wordpress/?page_id=181
So things are working just fine - for windows, but I'd like to compile the same kind of thing for OpenGL but still on Windows, but something's missing from the code to let me do that (although I doubt it was there to begin with).


Why in your textured poly module, near the top, do you have a ? on a line by itself after the ?Win32 line? Also are you missing some other blitz file that's needed to make GL work? Have you tried taking out all the import lines and just doing a large build?

I'd like to say, just for the sake of clarity, that I didn't make this module - as far as I remember is Indiepath's. I have however stripped a few things out to be able to use it as an included file instead of an actual module, which I find easier, but I'm pretty sure I didn't remove anything to do with OpenGL. Also, I'm not really sure what you mean by "doing a large build", but I assume it's more relevant if I'd used the code as an actual module.


GW(Posted 2010) [#6]
If your supposed to see a black screen with a red (non glowing) line, then i suppose its working.

EDIT: ok, changing the bg color makes the glow show up.


GaryV(Posted 2010) [#7]
The idea not just to make colored lines - the idea is to make neon-like lines like I've done in this game
Great job, looks really good. I have tried to come up with decent looking "glowing lines" but gave up.


Warpy(Posted 2010) [#8]
In the code archives there is a TexturedPoly function which is a lot less complicated.


TWH(Posted 2010) [#9]
Here's a little copy-and-pastable demo for us lazy copy-paster people :) (no need to load images)

I've added a function that draws a dot image in code and moved the "texturedpoly.bmx" include to the top.

Edit 1: Tested with image. My circle gradient hardly looks as good as dot.png, its too big.

Edit 2: Made a better circle gradient. Now looks like this:





TWH(Posted 2010) [#10]
Edit: I've posted a "better" answer to your post below :)
1. Sokurah: The code you posted works fine in GL here... But I do get a gl invalid enum on the TPoly._End() ... probably because GLFrame=null tries to delete a texture that doesnt exist? Im not sure.

I'm doing this in your code:
Graphics 640, 480, 0
Repeat Until glGetError()=GL_NO_ERROR 'wipe errors 

TPoly.Initialise()
SetBlend LIGHTBLEND

TPoly._Begin()
TPoly.Line(GlowingDot, 0, 0, 0, $ffff0000, 639, 479, $ffff0000, 24)
TPoly._End() '<- guess it tries to delete a texture that doesnt exist.
If glGetError() <> GL_NO_ERROR DebugStop()


2. I've also been mucking about some more with glowing lines. :) Here's the result.



I've used some of the polygon drawing code from TexturedPoly, but TriangleStrips are faster, so I've modded it a bit. Also, Im still using the way to define verticedata/lines (except I didnt bother with color)

The lines look best with the dot.png Sokurah provided.

The Hershey vector font was found on Paul Bourkes homepage.





TWH(Posted 2010) [#11]
Sokurah: Ok. I read your post a little better. You say you want it to compile with GLMax2D as the base framework? ... I get it working fine if I remove the imports from texturedpoly.bmx and place them in the example program like this:



Sokurah(Posted 2010) [#12]
Hey, I've been away for a few days and now see - lots of things to look into. Cool.

@TWH
Thanks. I've tried the two first pieces of code you posted - they run without problems - and they look good, but I'll have to test them against the module I've been using until now, to see how it's different in terms on speed and looks. I can't wait to fiddle around with them. :)

Your third post could be the solution to my problem, but I haven't tried it out yet. I'll post again if it gives me problems once I've had a look at it is not knee-deep in the AI for my latest vector game. ;)

Thanks.


Wiebo(Posted 2010) [#13]
I've been using the indiepath module for ages now. It works really well, but DX9, I cannot get it to work. Still, I think I will go oGL all the way.

I don't want to hijack this thread, but: Something which might interest you: I am working on a line object editor and game world editor using line objects, and I hopefully will introduce full physics for everything. linkie: http://wiebo.wordpress.com/2010/06/08/progress-on-vlibed/

Oh, and can someone tell me how to get this working on a maxgui canvas? That would be really neat =]


Sokurah(Posted 2010) [#14]
You can butt in any time you want Wiebo. You're my neon-hero. :-D


Wiebo(Posted 2010) [#15]
aww, that's nice =]