Author Topic: oldschool 2d and opengl  (Read 22791 times)

0 Members and 1 Guest are viewing this topic.

Offline Stonemonkey

  • Pentium
  • *****
  • Posts: 1315
  • Karma: 96
    • View Profile
Re: oldschool 2d and opengl
« Reply #20 on: August 12, 2007 »
Thanks Jim, seems to be working now but I had to put this at the start of the code:

#include "stdafx.h"


Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: oldschool 2d and opengl
« Reply #21 on: August 12, 2007 »
Project->Properties->C/C++/Precompiled Headers
change to 'Not Using Precompiled Headers'
:)

Basically, that's an compiler speed optimisation that prevents it having to recompile the headers every time you do a build (since they don't change).  Can be useful for big projects that take a long time to build.

Glad it's working.

Jim
Challenge Trophies Won:

Offline Stonemonkey

  • Pentium
  • *****
  • Posts: 1315
  • Karma: 96
    • View Profile
Re: oldschool 2d and opengl
« Reply #22 on: August 12, 2007 »
Ah right, thanks again k++

Offline hellsangel

  • C= 64
  • **
  • Posts: 46
  • Karma: 10
    • View Profile
Re: oldschool 2d and opengl
« Reply #23 on: August 12, 2007 »
 :clap:
thank you Jim for the framework and this wonderful RGB copperbars example  :cheers:

work perfectly for me

keep up good examples and tuts  ;D

 :cheers:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: oldschool 2d and opengl
« Reply #24 on: August 12, 2007 »
No problem  :kewl:
Is this what you were looking for?  Are you interested in any particular old school effect?

Jim
Challenge Trophies Won:

Offline hellsangel

  • C= 64
  • **
  • Posts: 46
  • Karma: 10
    • View Profile
Re: oldschool 2d and opengl
« Reply #25 on: August 12, 2007 »
I wanted to test my raster routine, but I didn't write it with ortho mode and nothing appears on the screen
Code: [Select]
Raster[j].y = (GLfloat)sin(Raster[j].angle * 3.1415f / 180) + (Raster[j].height / 2);
glBegin(GL_QUADS);
for(i=0; i<Raster[j].height; i++)
{
           glColor3f(Raster[j].col1.r, Raster[j].col1.g, Raster[j].col1.b);
glVertex2f(-1.0f, Raster[j].y);
glColor3f(Raster[j].col2.r, Raster[j].col2.g, Raster[j].col2.b);
glVertex2f(-1.0f, Raster[j].y - (Raster[j].height / 2));
glColor3f(Raster[j].col2.r, Raster[j].col2.g, Raster[j].col2.b);
glVertex2f(1.0f, Raster[j].y - (Raster[j].height / 2));
glColor3f(Raster[j].col1.r, Raster[j].col1.g, Raster[j].col1.b);
glVertex2f(1.0f, Raster[j].y);

glColor3f(Raster[j].col2.r, Raster[j].col2.g, Raster[j].col2.b);
glVertex2f(-1.0f, Raster[j].y - (Raster[j].height / 2));
glColor3f(Raster[j].col3.r, Raster[j].col3.g, Raster[j].col3.b);
glVertex2f(-1.0f, Raster[j].y - Raster[j].height);
glColor3f(Raster[j].col3.r, Raster[j].col3.g, Raster[j].col3.b);
glVertex2f(1.0f, Raster[j].y - Raster[j].height);
glColor3f(Raster[j].col2.r, Raster[j].col2.g, Raster[j].col2.b);
glVertex2f(1.0f, Raster[j].y - (Raster[j].height / 2));
}           
glEnd();
...
something wrong with old coord and ortho mode
or is it possible to mix 2D and 3D in a same drawing routine ? for example if I want to add a 3D textured/shaded cube...

about old effects, err...so much !  ;D
texts effects with bitmap fonts : I didn't test it yet with ortho
« Last Edit: August 12, 2007 by [Y] »

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: oldschool 2d and opengl
« Reply #26 on: August 12, 2007 »
Sure, it's relatively easy to switch between Orthographic and Perspective, you just have to set up the GL_PROJECTION matrix properly.  You can do that multiple times during a scene.  Same with texturing.

The coordinates look odd to me, remember -1 is now 1 pixel off the left of the screen!

It looks like it's only drawing from -1 to 1 in X.  You can fix that by

X = X + 1
X = X * SCREEN_WIDTH/2

Jim
Challenge Trophies Won:

Offline taj

  • Bytes hurt
  • DBF Aficionado
  • ******
  • Posts: 4810
  • Karma: 189
  • Scene there, done that.
    • View Profile
Re: oldschool 2d and opengl
« Reply #27 on: August 13, 2007 »
Jim,

I tried running your exe here (glsample.exe) sand I get:

"This application failed to start becuase the application configuration is incorrect. Reinstalling the application..." etc

Any idea why? Win XP, SP2, Ati x800, Omega drivers.

Chris
Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: oldschool 2d and opengl
« Reply #28 on: August 14, 2007 »
Challenge Trophies Won:

Offline taj

  • Bytes hurt
  • DBF Aficionado
  • ******
  • Posts: 4810
  • Karma: 189
  • Scene there, done that.
    • View Profile
Re: oldschool 2d and opengl
« Reply #29 on: August 14, 2007 »
You don't have the VC2005 runtime libraries installed.
http://www.microsoft.com/downloads/details.aspx?familyid=32bc1bee-a3f9-4c13-9c99-220b62a191ee&displaylang=en

Jim


I have VC++ Express installed (and used daily) which I think means I must have the VC2005 doesnt it?

Chris
Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: oldschool 2d and opengl
« Reply #30 on: August 14, 2007 »
That's definitely what that error means.  Perhaps it's to do with the fact I have VS2005 SP1 installed so my runtime requirements are slightly newer?

Jim
Challenge Trophies Won:

Offline Rbz

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 2757
  • Karma: 493
    • View Profile
    • https://www.rbraz.com/
Re: oldschool 2d and opengl
« Reply #31 on: August 15, 2007 »
You don't have the VC2005 runtime libraries installed.
http://www.microsoft.com/downloads/details.aspx?familyid=32bc1bee-a3f9-4c13-9c99-220b62a191ee&displaylang=en

Jim


I have VC++ Express installed (and used daily) which I think means I must have the VC2005 doesnt it?

Chris

Works fine here, and the only non standard dll that it import is MSVCR80.dll, maybe you have one corrupted dll or it was deleted ???

Challenge Trophies Won:

Offline taj

  • Bytes hurt
  • DBF Aficionado
  • ******
  • Posts: 4810
  • Karma: 189
  • Scene there, done that.
    • View Profile
Re: oldschool 2d and opengl
« Reply #32 on: August 15, 2007 »
Thanks for the help guys, its weird and I'm going to leave this alone as its so much hassle getting VC++ to work in the first place. This is the only application I have ever known to fail :-(.

Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: oldschool 2d and opengl
« Reply #33 on: August 15, 2007 »
Grab the dll from here
http://www.dll-files.com/dllindex/dll-files.shtml?msvcr80
and stick it in the directory with the exe.

It's possible that's not the right version though - there are many versions of msvcr80.dll, because it had security issues originally, so it's been updated.  VC2005 SP1 executables require (via a manifest) a specific minimum revision of the dll to link to at run time.

The only other fix for me is to post an exe linked to a static runtime...(attached)

Jim
« Last Edit: August 15, 2007 by Jim »
Challenge Trophies Won:

Offline taj

  • Bytes hurt
  • DBF Aficionado
  • ******
  • Posts: 4810
  • Karma: 189
  • Scene there, done that.
    • View Profile
Re: oldschool 2d and opengl
« Reply #34 on: August 24, 2007 »
That cured the problem Jim - thanks.
So, what does that mean - that I have an old version of that dll?
Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: oldschool 2d and opengl
« Reply #35 on: August 25, 2007 »
I think so.  VS2005 has had a service pack and, as I stated in another thread, I think it now generates exes that require a newer version of msvcr80.dll due to security patches.  Do you have the latest .net framework patches from Mcrosoft Update?

Jim
Challenge Trophies Won:

Offline taj

  • Bytes hurt
  • DBF Aficionado
  • ******
  • Posts: 4810
  • Karma: 189
  • Scene there, done that.
    • View Profile
Re: oldschool 2d and opengl
« Reply #36 on: August 25, 2007 »
Actually no (I adopt a policy of upgrade when I must). So that explains it all.
Challenge Trophies Won:

Offline energy

  • Amiga 1200
  • ****
  • Posts: 280
  • Karma: 25
    • View Profile
Re: oldschool 2d and opengl
« Reply #37 on: December 15, 2007 »
Hi ...
Just started coding in OPenGL and im interrested in the same effects as here written.
So it would be cool if someone has a bit code for scrollers etc...

Cheers and thanks
eNeRGy
coding: jwasm,masm
hobby: www.scd2003.de

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: oldschool 2d and opengl
« Reply #38 on: December 15, 2007 »
If you'd like to start a new thread with specific questions that would be cool :)

Jim
Challenge Trophies Won:

Offline relsoft

  • DBF Aficionado
  • ******
  • Posts: 3303
  • Karma: 47
    • View Profile
Re: oldschool 2d and opengl
« Reply #39 on: December 16, 2007 »
One way to do oldskool type 2d effects in openGL (and this is the way I used) is to code like you always do and never mind the openGL part.
Here's how:

Code ala PTC (which means on a buffer better to use 32 bits since it's easier to upload it later but there's a way to upload 8 bit images to opengl)
Be sure that your software buffer size is a power of 2 (if you want a 640x480 screen), you should use a 1024x1024 buffer)
Then for each frame...
Code your effect on the buffer
upload the buffer to an opengl texture(using glteximage2d or gltexsubimage2d)
blit the texture to screen using glquads

that's it.

I used it on one of my games. Note that the screen is rendered on a buffer whether you use OGL or Software as the render engine.
Code is FB17b though so there are lots of pointer hacks.

http://rel.betterwebber.com/index.php?action=contents&item=marvelous_twilight

I found a better and smaller demo on how to do this, check out effects.bas and display.bas.
Spacebar to skip effect
Challenge Trophies Won: