Converting CSBWin graphicengine to a OpenGL 3D engine

Discuss Chaos Strikes Back for Windows and Linux, an unofficial port of Chaos Strikes Back to PC by Paul Stevens, as well as CSBuild, an associated dungeon editor.

Moderator: Zyx

Forum rules
Please read the Forum rules and policies before posting.
User avatar
Sphenx
On Master
Posts: 567
Joined: Sun Sep 09, 2001 11:23 am
Contact:

Re: Converting CSBWin graphicengine to a OpenGL 3D engine

Post by Sphenx »

Basically keeping the camera some fixed distance backward from the center of the cell (the center is always ahead of the camera's position in a top-down view). So when rotation, the camera pans along the circle of that distance as well.
You talk about circular movement of the camera itself, but would this give another result than the current pivot? The pivot is like the circular movement, but on a circle that is just a point; because the camera would always target the center of its circle.

Or, I just don't understand what you're meaning, sorry.
User avatar
Rasmus
Ee Master
Posts: 714
Joined: Fri May 08, 2009 1:44 am
Location: Sweden
Contact:

Re: Converting CSBWin graphicengine to a OpenGL 3D engine

Post by Rasmus »

Thanks all, I have a good feeling about this too :)

@Roquen: About the camera, I guess you mean something like this:
Image

As seen the camera is first facing down and are located on the edge of the tile, then when it rotates to face left, it follows a circular path..
Thanks for the suggestion and it has been fixed ;)

@Beo: About the mummy, it still is there, and that goes for all the item and other stuff in the dungeon.. But as long as I haven't "stealed" the graphic from dm and used in the 3dengine it is all invisible..
By pressing "F1" you can switch between the original DM viewport, mixing the DM viewport with the openGL view, or just having OpenGL view.. This comes in handy when the engine isn't complete but that I want to keep exploring the dungeon.
Good to hear some comments about the CPU speed.. I am also alittle bit wondering when it comes to this, it feels like it should go faster, but maybe I should just slow down the animation :)

@Sphenx: The darkness.bmp isn't accually used yet, it was something I experimented with to mix the darkness down the corridor to decress its smoothness.. But the result wasn't as I suspected, have to handle this in a diffrent way..
At the end I am hoping to have removed all the .bmp files in the media folder and just steal it from graphics.dat.. But it may be some problem with the roof and floor..
I was maybe also thinking about adding another graphics3D.dat that has bmp files that replaces the dm graphic, so that it is posible to exceed to 16 color limit..

@Paul: I was thinking, all the graphics in graphics.dat has a limit of 16 colors right? Is it posible to add a palette to all these graphics? I mean if anyone can create a graphic that has 16 colors, but that the palette can be used in any was the designer wishes, then it will be a graphic improvment :)
User avatar
Rasmus
Ee Master
Posts: 714
Joined: Fri May 08, 2009 1:44 am
Location: Sweden
Contact:

Re: Converting CSBWin graphicengine to a OpenGL 3D engine

Post by Rasmus »

@Paul: I have found a way to get item outside graphic with "&d.s5604[0-84]". But I am alittle bit consern..
I was thinking about uploading all these 85 bitmaps into an texturebuffer at the beginning and then use them later on when drawing them in the viewport with OpenGL. My consern here is that it is "d.s5604" has a constant array of 85. Doesn't CSB has more outside items than that? And not to talk about conflux.. Or is this a limit and the only thing happening with these diffrent dungeons are a change of graphic?
User avatar
zoom
Grand Master
Posts: 1819
Joined: Tue Sep 23, 2003 1:27 am
Location: far away but close enough

Re: Converting CSBWin graphicengine to a OpenGL 3D engine

Post by zoom »

works for me without lagging. (have new computer!)
I wonder what this project leads us to!(agian, it does not lag)

some issues:
Hand/cursor drawing error
the hand gets distorted when you place the cursor between a wall decoration and the wall(rim of wall decos)
Image

you notice an overlay(hand is darker where the viewport is, compared to the surrounding area(champion actions).
Nothing to worry about, though!;)

The pivot is good, though some thoughts
just brainstorming, not to be taken over seriously

is it necessary? some may want to turn it off

can you make different pivots for different moves?
eg. forward move would pivot in a half circle down and up(like balancing on a sphere or being on a ship in the sea)
sideways movement /straving pivot (if there was any) would be different than actual turning "pivoting"

is the pivot somehow connected to overloaded carriing capacity or dexterity? Could feel odd to turn very fast and actually being very encumbered . Then again maybe not!!
User avatar
Gambit37
Should eat more pies
Posts: 13718
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Converting CSBWin graphicengine to a OpenGL 3D engine

Post by Gambit37 »

I don't think those pivots would work Zoom, they'd make the game virtually unplayable!
User avatar
Paul Stevens
CSBwin Guru
Posts: 4318
Joined: Sun Apr 08, 2001 6:00 pm
Location: Madison, Wisconsin, USA

Re: Converting CSBWin graphicengine to a OpenGL 3D engine

Post by Paul Stevens »

@Rasmus: You ask questions of me as if I knew
something. I know very little. The reason things
have names such as s5604 is that I never quite
figured out what they are.

But yes, there are at most 85 'miscellaneous'
items in the engine.

I don't know how you could expand the number
of colors in the palette for an apple. You would
have to bypass all the Atari graphics. I don't think
this would be impossible at all. But it would require
a person to understand how the Atari graphics
functions worked....and I do not understand them
sufficiently to undertake such a project. You
seem to know more than me already.

If I wanted to do this I would create a new
screen buffer in 16-bit or 32-bit pixels. We
could throw out most of Viewport.cpp. Then
I would see if I could make a version of TAG0088b2
that could write to the new screen buffer
with the old format bitmaps as input. Then
gradually replace the old format bitmaps
with your new graphics.

But, believe me, I am just brainstorming when
I say these things. Please take it as the
blathering of a very ignorant person.

Would it not make more sense to try and
convert DSB? There you would be starting
with something a little bit more modern
and more structured.
User avatar
zoom
Grand Master
Posts: 1819
Joined: Tue Sep 23, 2003 1:27 am
Location: far away but close enough

Re: Converting CSBWin graphicengine to a OpenGL 3D engine

Post by zoom »

Gambit37 wrote:I don't think those pivots would work Zoom, they'd make the game virtually unplayable!
remember doom? there you had this walk-animation, up and down-like.
nothing more I would suggest for straving.--> Honestly just to see if it works, which could be the case that it-or anything along those lines- does not work.
Csbwin has a different viewport approach in comparison to doom and the like, so maybe you´re right Gambit. Besides it is not worth the effort, but I
still would just like to see it(even if it does not work that is)
User avatar
Adamo
Italodance spammer
Posts: 1534
Joined: Fri Apr 22, 2005 11:59 am
Location: Poland
Contact:

Re: Converting CSBWin graphicengine to a OpenGL 3D engine

Post by Adamo »

Paul Stevens wrote:
If I wanted to do this I would create a new
screen buffer in 16-bit or 32-bit pixels. We
could throw out most of Viewport.cpp. Then
I would see if I could make a version of TAG0088b2
that could write to the new screen buffer
with the old format bitmaps as input. Then
gradually replace the old format bitmaps
with your new graphics.
Dungeon Master II for PC v0.9 Beta, Amiga, Sega CD and PC-980 used 16 colours palettes as well. It was later replaced by 256 colors graphics in the final PC version. I wonder if this function could be anyhow imported to the program? Just curious.
Spoiler
(\__/) (\__/) (\__/) (\__/) (\__/) (\__/) (\__/) (\__/) (\__/) (\__/) (\__/) (\__/)
Spoiler
(@.@) (@.@) (@.@) (@.@) (@.@) (@.@) (@.@) (@.@) (@.@) (@.@) (@.@) (@.@)
Spoiler
(>s<) (>s<) (>s<) (>s<) (>s<) (>s<) (>s<) (>s<) (>s<) (>s<) (>s<) (>s<)
User avatar
Rasmus
Ee Master
Posts: 714
Joined: Fri May 08, 2009 1:44 am
Location: Sweden
Contact:

Re: Converting CSBWin graphicengine to a OpenGL 3D engine

Post by Rasmus »

@Paul: I like the challenge changing in CSBWin, and also I learn alot when doing it.. That is why I choosed CSBWin, besides, I didn't know DSB had a open source :?
And DSB already have 24 bit graphics, and CSBWin doesn't. Thought it would be fun to be able to uppgrade all those dungeons created in CSBWin with some extra effect :)

I didn't mean that you knew everything in CSBWin, but as I see it you still have much more overall knowledge than me with CSBWin. I have just taken one part of it and examinated it alitte bit more..
It is good to know that the engine has a max capacity of certein items. This makes it easier for me to manage..
I wouldn't like to throw out viewport.cpp because it works side by side with the OpenGL engine, I fell like as soon as I start replacing code in viewport.cpp, more problem would accure, and I don't want to make this project too long..

I have been working alot with TAG0088b2, because everytime it draws something to the DM viewport it takes a sidestep and draws the same graphic to the openGL viewport.. In this way the user can choose between a DM viewport and OpenGL viewport by just pressing "F1" while they are still inside the game. But you have given me an idea here, it could work if I uploaded all the graphics like walldecorations, doors, etc. to the OpenGL engine first.. In this way the graphic can easely be replaced at the init procces of the game.. But I will have to think about it, because it would mean that I would have to redo some of my work..

And I'm having alot of problem seeing you as a "blathering of a very ignorant person" because me beeing able to do anything at all is still thanks to you :)

@zoom: I'm aware of the cursor problem, I have just tackled it in the wrong way, that is why it looks like it does.. Will fix it zone..
About the camera pivot point.. It is a nice idea, but I don't know if it is all that nessesery, one step takes a very short amount of time, and doing some "walking animation" on this would be distracting for the player as he runs down the dungeon.. But how knows, maybe I am wrong, I can take a look at this later, but not now :)
User avatar
Rasmus
Ee Master
Posts: 714
Joined: Fri May 08, 2009 1:44 am
Location: Sweden
Contact:

Re: Converting CSBWin graphicengine to a OpenGL 3D engine

Post by Rasmus »

@Adamo: The problem isn't really the viewport, because in by case it is already 24 bit.. The problem is the graphic that are written to it.. I asked Paul about these things because if it was possible to change graphic in CSBuild, it could be a good thing for me.. But only if CSBuild also handled palettes to the graphic. In original CSBWin it would not make sence haveing a diffrent palette because it only shows 16 color at the end, and it would get some error diffusion.. But with a 24 bit viewport it could work, every monster, wall, etc. could have their own 16 colors.. This would make a great graphic improvment, but as it is now I have moved on with another idea :)
User avatar
Rasmus
Ee Master
Posts: 714
Joined: Fri May 08, 2009 1:44 am
Location: Sweden
Contact:

Re: Converting CSBWin graphicengine to a OpenGL 3D engine

Post by Rasmus »

New version uploaded: http://dmtribute.webs.com/Files/CSBWin3 ... 01028).zip

It took some times beetween this and the last verison because I changed the way the 3D was done.. Before I took a "screenshot" of each cell and used it in the 3d engine.. Now I upload all the graphics and then use it to render.. So now items, monster, wallitems etc. are also shown in angles not seen before..

Except from changing the way the 3d is rendered on I have also:
- Inserted missiles (fireball, spinning clubs etc.)
- Inserted clouds (fireball explosion, poison cloud etc.)
- Inserted monsters.
- Fixed the door so that it opens and closes smothly.
- Light comming from the fireball.
- Added support for new 24 bit graphics in the weapon/spell/direction arrows bar, but the only thing that are posible to change from outside the souce is the direction arrows (for now)..

I have tried it on both DM and CSB and it seems to work out alright..

Still to fix before the viewport is complete:
- Adding a posiblity to replace DM graphic with 24 bit graphics.
- The worms and other creatures that takes up 2 positions in cells can have some odd animations when turning in some directions..
- Ressuructing at the VI Altar have wrong animation, it shows expolding open door spells instead of lightning and fire.
- Items can in some cases have a little bit diffrent offset in the dungeon, it is no more than a couple of pixels, so if you can't pick it up first time just try again.. I will fix this in the next version..
- The camera still have a little bit weird turning angle, haven't been able to fix the yet..
I still have to play them thru before I can say that it all works out as it should, and for now I have only tried the first and second level of DM (besides using CSBuild to check out if monsters animates as they should). I have also played CSB a bit on the engine without any problems..

Remember that if something doesn't seem to be as it should, you can always press "F1" to compare it to the original DM view..

And some screenshots:
Image
User avatar
Gambit37
Should eat more pies
Posts: 13718
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Converting CSBWin graphicengine to a OpenGL 3D engine

Post by Gambit37 »

Woo yay! Items on sidewalls at position 0!!! Finally!!!

This looks like some great work. Perhaps this is the way a 3D DM should always have been done: keep the game the same, just change the rendering engine. Great work Rasmus, keep it up :D
User avatar
Bit
Arch Master
Posts: 1064
Joined: Mon Mar 03, 2008 10:53 am
Location: Nuts trees

Re: Converting CSBWin graphicengine to a OpenGL 3D engine

Post by Bit »

/me raises finger: please please think about tiny little notebooks...
User avatar
Sphenx
On Master
Posts: 567
Joined: Sun Sep 09, 2001 11:23 am
Contact:

Re: Converting CSBWin graphicengine to a OpenGL 3D engine

Post by Sphenx »

You're progressing very well!
Did you changed something between your screenshots and your last release? I have a constant blue fog while playing (but that would be a nice ambient thing for a dungeon in some frost lands ...)
The 'sliding' monsters is something new, not yet used to that :P And I still like the turn movement.
One problem with false walls, when on it, you still see the wall and can't view farther.
Ah, and the Gazer (CSB) had a corrupted image when attacking.
User avatar
Rasmus
Ee Master
Posts: 714
Joined: Fri May 08, 2009 1:44 am
Location: Sweden
Contact:

Re: Converting CSBWin graphicengine to a OpenGL 3D engine

Post by Rasmus »

Thanks Gambit, I will try to keep it up :)

@Bit: Accually, this release should render faster than the last.. Is the rendering slow? Because I can speed it up easely here..

@Sphenx: Thanks, I can fix the fake wall and monstergraphic tonight.. The sliding monsters can be alittle bit annoying because there is no animation in the sliding, and it can feel unatural.. It is no more I can do here beause there is no other graphics for the monsters, maybe mirroring them at the sliding when they walk towards or from you.. But otherwise I will just put up some options in the end letting the player choose what kind of features he wants in the new way or the original way..
Do you have a screenshoot of the blue fog? It shouldn't be like that. I am thinking that it has something to do with the fireball light I used in this version.. If you fell like testing one thing out and see if the blue fog disapeares, you could open the "DM.cg" file in the "cg" folder with notepad and change all the code into this:

Code: Select all

struct vertexViewportIN
{
	float4 position : POSITION;
	float4 texcoord : TEXCOORD0;
};

struct vertexViewportOUT
{
	float4 position	: POSITION;
	float2 texcoord	: TEXCOORD0;
	float3 pos	: TEXCOORD1;
};

vertexViewportOUT VertexViewport(vertexViewportIN IN, uniform float4x4 matModel, uniform float4x4 matModelViewProj)
{
	vertexViewportOUT OUT;			// Variable to handle our output from the vertex
					// shader (goes to a fragment shader if available).

	OUT.pos = mul(matModel, IN.position).xyz;

	IN.position.y += (0.8f - OUT.pos.z) * 0.11999997f;
	IN.position.z -= OUT.pos.z * 0.30999997f;
	
	// Transform The Vertex Position Into Homogenous Clip-Space (Required)
	OUT.position = mul(matModelViewProj, IN.position);

	// Set The Color To The Value Specified In IN.color
	OUT.texcoord = IN.texcoord.xy;
	return OUT;
}

struct fragmentViewportIN
{
	half4 color	: COLOR0;
	float2 texcoord	: TEXCOORD0;
	float4 pos	: TEXCOORD1;
};

half4 FragmentViewport(fragmentViewportIN IN, uniform sampler2D diffuseMap, uniform sampler2D darknessMap, uniform float darkness) : COLOR0
{
	float4 color = (float4)tex2D(diffuseMap, IN.texcoord);
	float fdarkness = 1.4f - (length(IN.pos.xyz) / (0.8f + (1.2f * (4.0f - (darkness * 0.9f)))));
	color.rgb *= fdarkness;
	if (color.r > 1.0f - darkness*0.25f) color.r = 1.0f - darkness*0.25f;
	if (color.g > 1.0f - darkness*0.25f) color.g = 1.0f - darkness*0.25f;
	if (color.b > 1.0f - darkness*0.25f) color.b = 1.0f - darkness*0.25f;
	return color;
}


struct fragmentViewportMaskingIN
{
	half4 color	: COLOR0;
	float2 texcoord	: TEXCOORD0;
	float4 pos	: TEXCOORD1;
};

half4 FragmentViewportMasking(fragmentViewportMaskingIN IN, uniform sampler2D diffuseMap, uniform float darkness) : COLOR0
{
	float4 color = (float4)tex2D(diffuseMap, float2(IN.texcoord.x, IN.texcoord.y));
	if ((color.r == 1.0f)&&(color.g == 0.0f)&&(color.b == 1.0f))
	{
		color.a = 0.0f;
	}
	else
	{
		float fdarkness = 1.4f - (length(IN.pos.xyz) / (0.8f + (1.2f * (4.0f - (darkness * 0.9f)))));
		color.rgb *= fdarkness;
		if (color.r > 1.0f - darkness*0.25f) color.r = 1.0f - darkness*0.25f;
		if (color.g > 1.0f - darkness*0.25f) color.g = 1.0f - darkness*0.25f;
		if (color.b > 1.0f - darkness*0.25f) color.b = 1.0f - darkness*0.25f;		
	}
	return color;
}
Then just run the game and see if the blue fog is removed..
User avatar
Paul Stevens
CSBwin Guru
Posts: 4318
Joined: Sun Apr 08, 2001 6:00 pm
Location: Madison, Wisconsin, USA

Re: Converting CSBWin graphicengine to a OpenGL 3D engine

Post by Paul Stevens »

Well, I thought I would take a look.

When I run your CSBwin.exe all I get is an
"Error" dialog saying "Invalid Profile Type".

I am running Vista with a motherboard with
a builtin graphics. Certainly nothing fancy.
DXDiag reports display type is:
Intel 82945G Express Chipset
User avatar
Rasmus
Ee Master
Posts: 714
Joined: Fri May 08, 2009 1:44 am
Location: Sweden
Contact:

Re: Converting CSBWin graphicengine to a OpenGL 3D engine

Post by Rasmus »

It has to do with when the OpenGL gets initialized.. I will have a look around on the web and see if there is a way to get around it..
User avatar
Rasmus
Ee Master
Posts: 714
Joined: Fri May 08, 2009 1:44 am
Location: Sweden
Contact:

Re: Converting CSBWin graphicengine to a OpenGL 3D engine

Post by Rasmus »

Okey then..
- Failing monster attacking graphics where only at those monsters that didn't have side and back graphics (such as screamers).. But it is now fixed..
- It is now posible to see outside a fake wall when standing in it.
- I updated the floating movement, I noticed that turning for example could get in a non stop loop when to many monsters where nearby.
- I removed the fireball lightning in the dungeon, hoping that this will fix Sphenx blue fog problem.
- I have also updated the error handeling a little bit to be able to see what is wrong if the game doesn't start.
- I have included a newer version of cg.dll hoping that this will fix Pauls' problem.

@Paul: Just a question.. You have OpenGL installed on your machine? If so, isn't there any opengl info exe file that shows what your graphiccard support or not (something like directX dxdiag.exe but for opengl).. In that case I was looking for some support for fragment/vertex program/shader..

And here is the new download: http://dmtribute.webs.com/Files/CSBWin3 ... 1028b).zip
User avatar
beowuuf
Archmastiff
Posts: 20687
Joined: Sat Sep 16, 2000 2:00 pm
Location: Basingstoke, UK

Re: Converting CSBWin graphicengine to a OpenGL 3D engine

Post by beowuuf »

wow, it's ccoming on, isn't it! Worms and flying eyess noticeably moving around.

Unfortunately, as I was playing around the 'run and jump' area, my mouse started to get laggy, and then the game basically froze out on me. A memory leak or something somewhere?
User avatar
Rasmus
Ee Master
Posts: 714
Joined: Fri May 08, 2009 1:44 am
Location: Sweden
Contact:

Re: Converting CSBWin graphicengine to a OpenGL 3D engine

Post by Rasmus »

Yeah, I feel that too.. Only some minor adjustments left..
I have noticed the same lagging mouse myself and I hope it is a memory leak, if it is I will find and fix it as soon as possible :)
User avatar
Rasmus
Ee Master
Posts: 714
Joined: Fri May 08, 2009 1:44 am
Location: Sweden
Contact:

Re: Converting CSBWin graphicengine to a OpenGL 3D engine

Post by Rasmus »

Found the problem :)
Everytime before drawing to the window I called a function that helped me get the device context.
Like this: HDC hdc = GetDC(hWnd);
What I forgot to do was to releaseing it afterwards, otherwise it just keeped buffering..

So now this is fixed and I have been able to play for 15 minutes without any lagging..
I am just going to fix some other graphical bugs before uploading next betaversion.
User avatar
Sphenx
On Master
Posts: 567
Joined: Sun Sep 09, 2001 11:23 am
Contact:

Re: Converting CSBWin graphicengine to a OpenGL 3D engine

Post by Sphenx »

I've tested the new version but it is still the same.
Changing the code as you said didn't change.

Image

And on another computer, I do not get the blue thing but miss the interface and gets a second tiny screen with reversed colors ...

Image

But I am thinking it may be something with OpenGL and nVidia ... I have too problem with my OpenGL progs and my current nVidia card.
User avatar
Paul Stevens
CSBwin Guru
Posts: 4318
Joined: Sun Apr 08, 2001 6:00 pm
Location: Madison, Wisconsin, USA

Re: Converting CSBWin graphicengine to a OpenGL 3D engine

Post by Paul Stevens »

Like this: HDC hdc = GetDC(hWnd);
What I forgot to do was to releaseing it afterwards
You are not the first to have done this. You may have
set a record for minimum time to finding the problem.

In the old days, windoze would recycle these excessive
contexts without warning. Then your program would start
writing into someone else's window!!!!!

The new .exe has an:
CSBwin3d: CG Error
Selecting Vertex Profile: The profile is not supported.

I can find no OPENGL files other than 'OPENGL32.dll'

But it is not a problem...I was just curious as to how
it looked. I can get along just looking at the screenshots.
User avatar
Bit
Arch Master
Posts: 1064
Joined: Mon Mar 03, 2008 10:53 am
Location: Nuts trees

Re: Converting CSBWin graphicengine to a OpenGL 3D engine

Post by Bit »

@Bit: Accually, this release should render faster than the last.. Is the rendering slow? Because I can speed it up easely here..
Nono, you know the lack of DirectX-capabilities of my notebook. It draws the movement buttons and then collapses, means, it seems that the graphics driver itself goes down.

When DM2 gives me back some free time, I'd like to help - maybe using AllegroGL.
Such troublemakers like WinHandles don't exist there...
I then maybe can reduce all to the very minimal needs. When it runs at this notebook, Sphenx will lose his beautiful blue fog and Paul gets a torch for the viewport ;)
User avatar
Rasmus
Ee Master
Posts: 714
Joined: Fri May 08, 2009 1:44 am
Location: Sweden
Contact:

Re: Converting CSBWin graphicengine to a OpenGL 3D engine

Post by Rasmus »

@Sphenx: It seems really weird.. Do you have new graphiccard drivers installed?
It seems like every color except blue gets darken with the fog.. This brings me to another sulotion:
What if your graphiccard gets the rgba color channels mixed up.
So that one color infact changes the value on another color..
- So if I want to darken red color I may infact be darkening the alpha color.
- If I want to darken green color I may infact be darkening the red color.
- If I want to darken blue color I may infact be darkening the green color.

If this is the case, then blue never gets darkened, and the result is what you see on your screen..
There is two lines on in DM.cg (line 48 and 75) that has a code like this:

Code: Select all

color.rgb *= fdarkness;
If you change it to this instead:

Code: Select all

color.rgba *= fdarkness;
Then all the colors gets darkened, and it may just work :)

@Paul: Accually I found search for the problem using the task manager. I noticed that the memory used by CSBWin increased with 50 kb every second. Then I tried removing things here and there until I localized the line that was causing the memory increase. Without the taskmanager to help me I may still have been going at it. It is good that you tell me what problems this accually can cause, at first I didn't think that a memory leak would cause the crash, not when it is so low like 50 kb a second, but now when I know that it does other evil things I am glad that I got rid of it :)
These are the things I am a master on missing, mostly because I like to copy and paste code here and there and then later on understanding what it is accually doing. My knowledge is better now than it was when I started on DMT 1, but I still miss these things that are basics for some..

@Bit: I will release the sourcecode as soon as I am finished with it, I think alot of things can be opimized to the better if you also took a look at it :) But you may want to try out this new version because of the problem explained above has been fixed, and this was a BIG problem according to Paul :)

So, the third version released in one day (Sorry about that):
- The mouse lagging problem that ends up in a crash has been fixed.
- I have increased the rendering speed by sorting out cells that aren't visible at each rendering (got rid of atleast half of them).
- I have also speeded up the movement animation. At first I called the viewport rendering at the mainloop in CSBWin.cpp. Then I noticed that this is looped only 30 - 40 times a second, with or without calling the viewport rendering.. Then I moved and called the viewport rendering at the system.cpp file in the function DispatchCSB(), this is because I noticed that this function is called about 200 times a second normaly. So I put the call to the viewportrendering there instead, and still it does a loop on it 200 times a second, meaning that it takes less than 5 milliseconds to render the viewport with OpenGL..
This gave me a small speedincrease, and I say small because CSB:s own program is coming in the way and I am having problems getting a stable call to viewportrendering.. Still have to search for a better place to put it...
- I have inserted a menu in the window called OpenGL. Here you can switch between classic viewport and actionbar, and also decide how many times per second OpenGL should render the viewport.
- Another more interesting thing I have added to the menu is that the viewports resolution can be doubled, displaying the viewport with a true resolution of 448x272, instead of just resizing the original 224x136 resolution.

And here is the download: http://dmtribute.webs.com/Files/CSBWin3 ... 01029).zip

And here is a screenshot with double res:
Image
User avatar
Bit
Arch Master
Posts: 1064
Joined: Mon Mar 03, 2008 10:53 am
Location: Nuts trees

Re: Converting CSBWin graphicengine to a OpenGL 3D engine

Post by Bit »

Roquen
Artisan
Posts: 179
Joined: Fri Jul 11, 2008 11:34 am
Location: Biarritz, France

Re: Converting CSBWin graphicengine to a OpenGL 3D engine

Post by Roquen »

Some minor comments.

You might want to change some code formulation to be more runtime compiler friendly:

Code: Select all

  if (color.r > X) color.r = X;
  if (color.g > X) color.g = X;
  if (color.b > X) color.b = X;

Code: Select all

  color.rgb = min(color.rgb, X);
Also, the shaders might run on a wider array of GPUs if you pull out the colorkey test from the pixel shader and simply generate the alpha value at texture creation time:

Code: Select all

  if ((IN.pos.y>clipY)||((color.r == 1.0f)&&(color.g == 0.0f)&&(color.b == 1.0f)))
  {
    color.a = 0.0f;
  }

Code: Select all

  if (IN.pos.y>clipY)
  {
    // alpha is already zero if this is the colorkey
    color.a = 0.0f;
  }
User avatar
linflas
My other avatar is gay
Posts: 2445
Joined: Tue Nov 04, 2003 9:58 pm
Location: Lille, France
Contact:

Re: Converting CSBWin graphicengine to a OpenGL 3D engine

Post by linflas »

same behaviour on my old Dell Optiplex at work.
"The only way out is another way in." Try Sukumvit's Labyrinth II
User avatar
Rasmus
Ee Master
Posts: 714
Joined: Fri May 08, 2009 1:44 am
Location: Sweden
Contact:

Re: Converting CSBWin graphicengine to a OpenGL 3D engine

Post by Rasmus »

I don't like those dark powers.. But I think it is weird that it doesn't complain in the openGL init.. I guess OpenGL are having problems moving the OpenGL backbuffer to a texture, that is why the last position of the mouse isn't erased. The mouse and the actionbar are later written on the texture that are going to be drawn on the screen and has nothing to do with OpenGL.

@Roquen: Thanks for the advice, I changed it to:

Code: Select all

color.rgb = min(color.rgb, X);
"min" is a good command, haven't used it before.. May save me some codeing :)

About the colorkey, no computer has yet been having trouble with this. I don't really need a alpha channel because I don't do any alphablending, just alpha testing. And even if I did init the texture with a colorkey, I don't think it will be used because I am using pixel/fragment shaders.
But if they do, and that I manually can insert a colorkey, how do I do it? I have searched the net for a long time trying to figure out how to insert it.. Please note that I am using cg.

Thanks again :) I like when getting things like these pointed out for me :)
User avatar
Rasmus
Ee Master
Posts: 714
Joined: Fri May 08, 2009 1:44 am
Location: Sweden
Contact:

Re: Converting CSBWin graphicengine to a OpenGL 3D engine

Post by Rasmus »

I am playing CSB now are a little bit annoyed over not having the map-scroll.. So I was thinking about inserting it into the game.. Does anyone has a screenshot of what the map looks like on CSB for amiga?
Post Reply

Return to “Chaos Strikes Back for Windows & Linux (CSBWin) / CSBuild”