Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 21 Oct 2003
Offline Last Active Apr 01 2016 09:26 PM

Posts I've Made

In Topic: How do I get a 3D position from a Camera Vector

01 April 2016 - 09:30 PM

Not sure if it will be needed by anyone, but after experimenting I did find a solution.


--first i set up some vectors

local g_up = Vector3.new(0,1,0)  --global up

local v_forward = target.lookVector

local v_right = -g_up:Cross(v_forward)

local v_up = -v_forward:Cross(v_right)

local p = target.position


--get a new position, based off of moving down the vectors (also the 'loc' variable is what was returned by the function in the above post)

p = (v_forward*(-loc.Z))+p

p = (v_right*loc.X)+p

p = (v_up*loc.Y)+p


local cam = Camera

cam.position = p

cam.lookAt = p+(target.lookVector * -2)) 


I dont know if its the best way to do this, but it works, so... unless it gives me issues, ill use this



In Topic: Trouble loading and displaying with transparency, 8bit indexed bitmaps

04 February 2015 - 08:50 AM

Its too bad there is no apparent 'native support' for 8bit images in opengl anymore.  However, I did not know it was getting a copy of the entire palette on each call, I tried to suggestion of making one copy to an array, and using the array, and the results were 100% faster.


I cant even tell how long its taking to load, as it zips through the files.


Thanks so much.

In Topic: Trouble loading and displaying with transparency, 8bit indexed bitmaps

25 January 2015 - 11:47 AM

It is definately the 'looping' through the indexes that is causing the slow operation.


I have been searching and searching online for a solution, and came across something interesting...


I've seen 

GL.TexImage2D(TextureTarget.Texture2D, 0, 
                    bitmap.Width, bitmap.Height, 0,
                    PixelFormat.ColorIndex, PixelType.UnsignedByte, data);

now, the PixelFormat is ColorIndex.... this is what I need... however, when I use this, I get pure black images, no transparency...

So, I think I must be missing the 'color palette' somewhere... I'm trying to discover, how to let opengl know the data of the colorpalette tha the ColorIndex will look at.


I also read this...

"Similarly, to offset the color indices of a bitmap to the palette entries you have defined for it, use

glPixelTransferi(GL_INDEX_OFFSET, bitmap_entry);"


it says 'the palette entries you have defined', and im assuming this is 'bitmap_entry', but nothing shows 'HOW' to define the palette entries



So... I'm feeling more lost than ever, surely surely someone has used indexed graphics, and knows how to do this, but the lack of information on the web is troubling, i'm thinking, is it even possible anymore?  


Thanks for any help

In Topic: Trouble loading and displaying with transparency, 8bit indexed bitmaps

25 January 2015 - 09:46 AM

Thanks so much for your input.


Well, the case with Palette.Entries[0], is that it's alpha value is non 0, and I really don't care what color the pixels are for index 0, as long as it is transparent.  I cant edit the original images, unless there is some magical opengl, trick to mass convert data or something, I'm afraid I'll have to check and set to alpha 0 each time I hit an index 0 byte.


I see what you mean, as far as writing 1x4 bytes, not sure if this would be a speed increase, but its something I will try, just to see if I get different results.


It is a time critical piece of code, and I do have it in a 'title/loading' screen, its just.... slow loading.


Now you mention, am I sure its 'super slow'... yeah, it kinda is... and actually that is a bit surprising, even for an 800x800 image... I would think it would be faster on a modern computer.  So, I'm wondering if the part that is taking up so much time, might be the part of the code where I am reading in the Bitmap, with LockBits, and copying its data.


I plan to keep trying and experimenting


If anyone has any other input or have used 8bit indexed bitmaps.... please share some secrets, thanks.

In Topic: How 'in terms of structure' do I use my shader?

09 December 2014 - 11:24 AM

Thanks for the replies, I wouldn't even begin to know how to batch my sprites, as each of the 100 sprites would contain different textures.  No duplicating textures.


I see what you mean now about not needing to call 'end' on the shader.  


I think I understand about the 'setvariable' once, ,then just bind different textures.  I will give this a try XD 


Thanks again.