pouët.net

Kickarse 2012 demoeffect blog in C/GDI to the browser (Optimus etc)

category: residue [glöplog]
 
The best blog is the one you write yourself.
Let fools use fb/wp ;-), we need framebuffer/pixel access, right?

It's so easy it's ridiculous. You use C/GDI. This is how:

Use notepad create main.java, write into it:


public class main extends JApplet
{
int g_iWndWidth=0
int g_iWndHeight=0;
public void init()
{
g_iWndWidth=this.getSize().width;
g_iWndHeight=this.getSize().height;
}
public void paint(Graphics hDC)
{
Graphics2D hDC_=(Graphics2D)hDC;
hDC_.setColor(255,0,255);
hDC_.fillrect(0,0,g_iWndWidth,g_iWndHeight);

// ... Your blog here in C code + oldschool SWeffects around it.
// These pixels here stay accurate they don't screw up/move
// etc per implementation, cuz it's lowlevel.
}
}


This is your main() func in C.
And it gets JApplet base to your program. It overrides its internal paint().
This is equivalent to native WM_PAINT msg in WINAPI. Yall sure familiar with that.
Also the Graphics gotten as parm is exactly that WINAPI device context just diff name.

You can screw the rest of the queer Java and write that init() and paint()
like Charles Bronson in C/Gdi/Native.


Java is identical to C in syntax so they all work. Even bitshifting.

Use that hDC to draw any GDI rects, lines, texts, polygons, pixelarray BitBlt() etc
to the browser window.
There are all matching calls in the doc that you can find for GDI, cuz
these calls really wrap to the GDI dlls on the Windows system.

So it can be said "you code GDI". Just forget that bullshit java is in the middle
and do what mr. Bronson would do now...


Bring out ya SWRasterizer and metaballs and sinewave the crap outta the Blog entries.

PS. JApplet hApplet=this; hApplet.repaint(); redraws the paint() any time you like,
it means in C to InvalidateRect(hWnd,NULL,TRUE);


To put the blog to the web, create in notepad MyBlog.html like:


<html>
<title>My demoblog written in C/GDI</title>
<body>
<center>
<applet code="main.class", width=1024, height=768>
fucking douchebag no jre installed
</applet>
</body>
</html>


That .class file like .exe/.obj ie. the interpretor can run it. You compile
that .class file outta yo main.java by using JDK cmdline compiler called 'javac.exe'
it's in the bin folder after you have installed JDK (you must install the devkit):


javac main


These are all the steps in order to transfer all your C oldschool effects to your
own blog and the web browser and get complete framebuffer/pixel access to the page.


PPS. You don't need to install any dev IDE for java just use MSVC and make it open
.java files as C+ files to get the coloring and tabs + unlimited undo.


PPPS. It aint slow, can be done 60fps to update the frame in SW3DRenderer with
some texmapped perspective-correct/lighted polys, they are kinda nice with the diary/blog.


PPPPS. Yep I hate that class too (cuz i'm C/Asm man since my daddy's dick got wet).
But it's all you need, u can screw rest. Tada.
Maybe I'm just stupid (scrap that, I am) but the one thing I don't see is how you actually draw pixels fast. Let's say you're doing a super nice SW renderer. How do you blit an array onto the screen or whatever? I'm assuming you don't mean we should do
hDC_.setColor(r,g,b);
hDC_.fillrect(x,y,1,1);
for each pixel.
added on the 2011-11-25 17:47:38 by nitro2k01 nitro2k01
The best blog is the one you write in a blog.. Not here.
added on the 2011-11-25 18:26:54 by gloom gloom
nice trolling!
added on the 2011-11-25 18:31:36 by kusma kusma
java applets on wbsites are so 90s!
added on the 2011-11-25 18:49:27 by wysiwtf wysiwtf
i don't get the point?!

1) who uses java applets these days
2) who writes a blog about software rendering
3) if it facinates you - why not do it yourself
4) blob
well surely you implement your dblbuffering method in there (like everbody should know), it is just an example how to start

PS.

It misses some #include statements above the main(), put there:

import java.awt.*
import java.swing.*

those include abstract windowing toolkit which is like
#include <windows.h>
To detect keyboard input put to the class
"implements ActionListener"

and the callback

void actionEvent(...

Also to implement timers put there
"implements Runnable"

Then run() function inside the class is the thread
which runs independently from the other stuff, here
you can post repaints/anim updates etc

...

Yeah yeah I know html5/webgl is the thing in there, but this is an alt way.

I did already webgl with some physics libs like 3 years back, nothing new in that
Put to this thread if you are trying to use this and have some questions etc you know there are still people who might find stuff useful
I still dont get it. Why build something noone requested and you dont ude yourself?
I've heard the Hugi guys are still looking for quality tutorials, tried to contact them?
added on the 2011-11-26 16:57:33 by kb_ kb_
Haha. Nice kb ;)

login